From 1a20b0a72c2e35ab33246c6886d39e8e0d0c10d7 Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sat, 5 Jan 2013 16:20:41 -0500 Subject: [PATCH] Add ability to use volume names with also_scan_dirs token. --- NEWS.txt | 2 +- docs/refind/configfile.html | 4 ++-- docs/refind/todo.html | 7 +++++++ refind/config.c | 10 +++++----- refind/main.c | 19 ++++++++----------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index c5ce404..139dd2b 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -2,7 +2,7 @@ ----------------- - Added the ability to specify a volume name or number in the - "dont_scan_dirs" token. + "dont_scan_dirs" and "also_scan_dirs" tokens. - Fixed a bug that caused removable EFI media to not appear in scan lists if rEFInd was installed as EFI/BOOT/boot{arch}.efi on a hard disk. diff --git a/docs/refind/configfile.html b/docs/refind/configfile.html index 9fa9eaa..3ca8977 100644 --- a/docs/refind/configfile.html +++ b/docs/refind/configfile.html @@ -215,7 +215,7 @@ timeout 20 also_scan_dirs directory path(s) - Adds the specified directory or directories to the directory list that rEFInd scans for EFI boot loaders when scanfor includes the internal, external, or optical options. Directories are specified relative to the filesystem's root directory. If this option is used, it's applied to all the filesystems that rEFInd scans. If a specified directory doesn't exist, rEFInd ignores it (no error results). The default value is boot, which is useful for locating Linux kernels when you have an EFI driver for your Linux root (/) filesystem. + Adds the specified directory or directories to the directory list that rEFInd scans for EFI boot loaders when scanfor includes the internal, external, or optical options. Directories are specified relative to the filesystem's root directory. You may precede a directory path with a volume name and colon, as in somevol:/extra/path, to restrict the extra scan to a single volume. A volume number, preceded by fs, can be used for volumes that lack names, as in fs1:/extra/path. If you don't specify a volume name or number, this option is applied to all the filesystems that rEFInd scans. If a specified directory doesn't exist, rEFInd ignores it (no error results). The default value is boot, which is useful for locating Linux kernels when you have an EFI driver for your Linux root (/) filesystem. dont_scan_volumes or don't_scan_volumes @@ -225,7 +225,7 @@ timeout 20 dont_scan_dirs or don't_scan_dirs directory path(s) - Adds the specified directory or directories to a directory "blacklist"—these directories are not scanned for boot loaders. You may optionally precede a directory path with a volume name and a colon to limit the blacklist to that volume. For instance, EFI/BOOT prevents scanning the EFI/BOOT directory on all volumes, whereas ESP:EFI/BOOT blocks scans of EFI/BOOT on the volume called ESP but not on other volumes. You can use a filesystem number, as in fs0, in place of a volume name. This token may be useful to keep duplicate boot loaders out of the menu (say, if EFI/BOOT/bootx64.efi is a duplicate of another boot loader); or to keep drivers or utilities out of the boot menu, if you've stored them in a subdirectory of EFI. This option takes precedence over also_scan_dirs; if a directory appears in both lists, it will not be scanned. + Adds the specified directory or directories to a directory "blacklist"—these directories are not scanned for boot loaders. You may optionally precede a directory path with a volume name and a colon to limit the blacklist to that volume; otherwise all volumes are affected. For instance, EFI/BOOT prevents scanning the EFI/BOOT directory on all volumes, whereas ESP:EFI/BOOT blocks scans of EFI/BOOT on the volume called ESP but not on other volumes. You can use a filesystem number, as in fs0, in place of a volume name. This token may be useful to keep duplicate boot loaders out of the menu (say, if EFI/BOOT/bootx64.efi is a duplicate of another boot loader); or to keep drivers or utilities out of the boot menu, if you've stored them in a subdirectory of EFI. This option takes precedence over also_scan_dirs; if a directory appears in both lists, it will not be scanned. dont_scan_files or don't_scan_files diff --git a/docs/refind/todo.html b/docs/refind/todo.html index caeed82..bbf0d54 100644 --- a/docs/refind/todo.html +++ b/docs/refind/todo.html @@ -264,6 +264,13 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

caused by a truncated DevicePath to the shell, which includes the shell's pathname but not the device identifier. +
  • When specifying a volume by name in dont_scan_dirs, + slashes are converted to backslashes in the specification but not + in the actual volume name read from disk. Thus, you can't specify a + volume by name if it includes a slash (as in Fedora + /boot). Workarounds are to rename the volume to omit the slash + and to use a filesystem number rather than a volume label.
  • +
  • The code is in need of review to search for memory leaks and similar problems.
  • diff --git a/refind/config.c b/refind/config.c index 63d0f31..81f87dd 100644 --- a/refind/config.c +++ b/refind/config.c @@ -424,11 +424,11 @@ VOID ReadConfig(CHAR16 *FileName) } else if ((StriCmp(TokenList[0], L"don't_scan_volumes") == 0) || (StriCmp(TokenList[0], L"dont_scan_volumes") == 0)) { HandleStrings(TokenList, TokenCount, &(GlobalConfig.AlsoScan)); // Note: Don't use HandleStrings() because it modifies slashes, which might be present in volume name - MyFreePool(GlobalConfig.DontScanVolumes); - GlobalConfig.DontScanVolumes = NULL; - for (i = 1; i < TokenCount; i++) { - MergeStrings(&GlobalConfig.DontScanVolumes, TokenList[i], L','); - } + MyFreePool(GlobalConfig.DontScanVolumes); + GlobalConfig.DontScanVolumes = NULL; + for (i = 1; i < TokenCount; i++) { + MergeStrings(&GlobalConfig.DontScanVolumes, TokenList[i], L','); + } } else if ((StriCmp(TokenList[0], L"don't_scan_dirs") == 0) || (StriCmp(TokenList[0], L"dont_scan_dirs") == 0)) { HandleStrings(TokenList, TokenCount, &(GlobalConfig.DontScanDirs)); diff --git a/refind/main.c b/refind/main.c index 67381c6..290d73e 100644 --- a/refind/main.c +++ b/refind/main.c @@ -132,7 +132,7 @@ static VOID AboutrEFInd(VOID) if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.2.2"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.2.3"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith"); @@ -902,21 +902,18 @@ static BOOLEAN ShouldScan(REFIT_VOLUME *Volume, CHAR16 *Path) { UINTN i = 0, VolNum; BOOLEAN ScanIt = TRUE; - if (IsIn(Volume->VolName, GlobalConfig.DontScanVolumes)) { - Print(L"Not scanning volume %s\n", Volume->VolName); - PauseForKey(); + if (IsIn(Volume->VolName, GlobalConfig.DontScanVolumes)) return FALSE; - } while ((DontScanDir = FindCommaDelimited(GlobalConfig.DontScanDirs, i++)) && ScanIt) { SplitVolumeAndFilename(&DontScanDir, &VolName); CleanUpPathNameSlashes(DontScanDir); if (VolName != NULL) { - if ((StriCmp(VolName, Volume->VolName) == 0) && (StriCmp(DontScanDir, Path))) + if ((StriCmp(VolName, Volume->VolName) == 0) && (StriCmp(DontScanDir, Path) == 0)) ScanIt = FALSE; if ((VolName[0] == L'f') && (VolName[1] == L's') && (VolName[2] >= L'0') && (VolName[2] <= '9')) { VolNum = Atoi(VolName + 2); - if ((VolNum == Volume->VolNumber) && (StriCmp(DontScanDir, Path))) + if ((VolNum == Volume->VolNumber) && (StriCmp(DontScanDir, Path) == 0)) ScanIt = FALSE; } } else { @@ -943,8 +940,6 @@ static VOID ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16 *P if ((!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && (Volume->DeviceHandle != SelfVolume->DeviceHandle)) || (StriCmp(Path, SelfDirPath) != 0)) && (ShouldScan(Volume, Path))) { -// (!IsIn(Path, GlobalConfig.DontScanDirs)) && -// (!IsIn(Volume->VolName, GlobalConfig.DontScanVolumes))) { // look through contents of the directory DirIterOpen(Volume->RootDir, Path, &DirIter); while (DirIterNext(&DirIter, 2, Pattern, &DirEntry)) { @@ -989,7 +984,7 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) { EFI_STATUS Status; REFIT_DIR_ITER EfiDirIter; EFI_FILE_INFO *EfiDirEntry; - CHAR16 FileName[256], *Directory, *MatchPatterns; + CHAR16 FileName[256], *Directory, *MatchPatterns, *VolName = NULL; UINTN i, Length; MatchPatterns = StrDuplicate(LOADER_MATCH_PATTERNS); @@ -1036,11 +1031,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) + if ((Length > 0) && ((VolName == NULL) || (StriCmp(VolName, Volume->VolName) == 0))) ScanLoaderDir(Volume, Directory, MatchPatterns); MyFreePool(Directory); + MyFreePool(VolName); } // while } // if } // static VOID ScanEfiFiles() -- 2.39.2