From 09af091384c09aa036b50d912596a95fb07c5c4c Mon Sep 17 00:00:00 2001 From: Eduardo Casino Date: Fri, 27 May 2022 22:42:46 +0200 Subject: Fix hash short names when host file system is case sensitive --- sfmain.c | 2 +- sftsr.c | 13 ++++++++++--- sftsr.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sfmain.c b/sfmain.c index 68029c1..a1a9518 100644 --- a/sfmain.c +++ b/sfmain.c @@ -167,7 +167,7 @@ static int mount_shfl(LPTSRDATA data, int drive, const char *folder) } // This is not a bug! VirtualBox sets SHFL_MIF_HOST_ICASE if host file system is case sensitive - data->drives[drive].case_insensitive = ~(flags & SHFL_MIF_HOST_ICASE); + data->drives[drive].case_insensitive = !(flags & SHFL_MIF_HOST_ICASE); return 0; } diff --git a/sftsr.c b/sftsr.c index f87aac0..34992b4 100644 --- a/sftsr.c +++ b/sftsr.c @@ -1015,13 +1015,13 @@ static vboxerr find_volume_label(SHFLROOT root) /** Gets and fills in the next directory entry from VirtualBox. */ static vboxerr find_next_from_vbox(unsigned openfile, char __far *path) { - int drive = drive_letter_to_index(path[0]); - SHFLROOT root = data.drives[drive].root; DOSSDB __far *sdb = &data.dossda->sdb; DOSDIR __far *found_file = &data.dossda->found_file; uint16_t search_mask; vboxerr err; uint32_t hash; + int drive; + bool case_insensitive; // Always accept files with these attributes, even if mask says otherwise search_mask = ~(sdb->search_attr | _A_ARCH | _A_RDONLY); @@ -1030,6 +1030,10 @@ static vboxerr find_next_from_vbox(unsigned openfile, char __far *path) // a correct absolute mask with the correct wildcards; // this is what VirtualBox will use in future calls. if (path) { + SHFLROOT root; + drive = drive_letter_to_index(path[0]); + root = data.drives[drive].root; + copy_drive_relative_filename(root, &shflstr.shflstr, path); fix_wildcards(&shflstr.shflstr); @@ -1040,11 +1044,14 @@ static vboxerr find_next_from_vbox(unsigned openfile, char __far *path) return VERR_NO_MORE_FILES; } } else { + drive = sdb->drive & DOS_SDB_DRIVE_MASK; // For find next calls, it's not really important what we pass here, // as long as it's not empty. shflstring_strcpy(&shflstr.shflstr, " "); } + case_insensitive = data.drives[drive].case_insensitive; + while (1) { // Loop until we have a valid file (or an error) unsigned size = sizeof(shfldirinfo), resume = 0, count = 0; bool valid; @@ -1103,7 +1110,7 @@ static vboxerr find_next_from_vbox(unsigned openfile, char __far *path) dprintf(" Host short filename: '%s'\n", shfldirinfo.dirinfo.name.ach); } else { - valid = translate_filename_from_host(&shfldirinfo.dirinfo.name, data.drives[drive].case_insensitive, true); + valid = translate_filename_from_host(&shfldirinfo.dirinfo.name, case_insensitive, true); } if (valid) { diff --git a/sftsr.h b/sftsr.h index 5fc7b0f..171511a 100644 --- a/sftsr.h +++ b/sftsr.h @@ -56,7 +56,7 @@ typedef struct { // but we still waste a full uint64_t to store a value that is always < 4K. // Similarly, at most 64 roots are supported, but we waste a uint32_t. -typedef _Packed struct { +typedef struct { // TSR installation data /** Previous int2f ISR, storing it for uninstall. */ void (__interrupt __far *prev_int2f_handler)(); -- cgit v1.2.3