From 4981d89ed05e2cf6058309d92094b693b5d92e1b Mon Sep 17 00:00:00 2001 From: srs5694 Date: Fri, 5 Jul 2013 22:11:24 -0400 Subject: [PATCH] Fixed bug that caused also_scan_dirs to ignore volume specifier. --- NEWS.txt | 3 +++ filesystems/fsw_efi.c | 3 ++- refind/main.c | 37 ++++++++++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index bdc1a33..519c53c 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -7,6 +7,9 @@ (bkpbootmgfw.efi). If found, give separate entries for it and for bootmgfw.efi, each with its own descriptive text label. +- Fixed also_scan_dirs; used to have bug that caused it to ignore + volume specification, if present. + 0.7.0 (6/27/2013): ------------------ diff --git a/filesystems/fsw_efi.c b/filesystems/fsw_efi.c index 6acfcbc..bed6a80 100644 --- a/filesystems/fsw_efi.c +++ b/filesystems/fsw_efi.c @@ -354,7 +354,8 @@ EFI_STATUS EFIAPI fsw_efi_DriverBinding_Start(IN EFI_DRIVER_BINDING_PROTOCOL *T ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); if (EFI_ERROR(Status)) { - return Status; + Print(L"Fsw ERROR: OpenProtocol(DiskIo) returned %r\n", Status); + return Status; } // allocate volume structure diff --git a/refind/main.c b/refind/main.c index 47588ee..af51b59 100644 --- a/refind/main.c +++ b/refind/main.c @@ -1039,7 +1039,7 @@ static VOID CleanUpLoaderList(struct LOADER_LIST *LoaderList) { // Returns TRUE if none of these conditions is met -- that is, if the path is // eligible for scanning. static BOOLEAN ShouldScan(REFIT_VOLUME *Volume, CHAR16 *Path) { - CHAR16 *VolName = NULL, *DontScanDir; + CHAR16 *VolName = NULL, *DontScanDir, *PathCopy = NULL; UINTN i = 0, VolNum; BOOLEAN ScanIt = TRUE; @@ -1049,6 +1049,25 @@ static BOOLEAN ShouldScan(REFIT_VOLUME *Volume, CHAR16 *Path) { if ((StriCmp(Path, SelfDirPath) == 0) && (Volume->DeviceHandle == SelfVolume->DeviceHandle)) return FALSE; + // See if Path includes an explicit volume declaration that's NOT Volume.... + PathCopy = StrDuplicate(Path); + if (SplitVolumeAndFilename(&PathCopy, &VolName)) { + if (StriCmp(VolName, Volume->VolName) != 0) { + if ((StrLen(VolName) > 2) && (VolName[0] == L'f') && (VolName[1] == L's') && (VolName[2] >= L'0') && (VolName[2] <= L'9')) { + VolNum = Atoi(VolName + 2); + if (VolNum != Volume->VolNumber) { + ScanIt = FALSE; + } + } else { + ScanIt = FALSE; + } + } // if + } // if Path includes volume specification + MyFreePool(PathCopy); + MyFreePool(VolName); + VolName = NULL; + + // See if Volume is in GlobalConfig.DontScanDirs.... while ((DontScanDir = FindCommaDelimited(GlobalConfig.DontScanDirs, i++)) && ScanIt) { SplitVolumeAndFilename(&DontScanDir, &VolName); CleanUpPathNameSlashes(DontScanDir); @@ -1065,8 +1084,10 @@ static BOOLEAN ShouldScan(REFIT_VOLUME *Volume, CHAR16 *Path) { ScanIt = FALSE; } MyFreePool(DontScanDir); + MyFreePool(VolName); DontScanDir = NULL; - } + } // while() + return ScanIt; } // BOOLEAN ShouldScan() @@ -1339,11 +1360,13 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) { // Scan user-specified (or additional default) directories.... i = 0; while ((Directory = FindCommaDelimited(GlobalConfig.AlsoScan, i++)) != NULL) { - SplitVolumeAndFilename(&Directory, &VolName); - CleanUpPathNameSlashes(Directory); - Length = StrLen(Directory); - if ((Length > 0) && ScanLoaderDir(Volume, Directory, MatchPatterns)) - ScanFallbackLoader = FALSE; + if (ShouldScan(Volume, Directory)) { + SplitVolumeAndFilename(&Directory, &VolName); + CleanUpPathNameSlashes(Directory); + Length = StrLen(Directory); + if ((Length > 0) && ScanLoaderDir(Volume, Directory, MatchPatterns)) + ScanFallbackLoader = FALSE; + } // if MyFreePool(Directory); MyFreePool(VolName); } // while -- 2.39.2