]> code.delx.au - refind/commitdiff
Add ability to use volume names with also_scan_dirs token.
authorsrs5694 <srs5694@users.sourceforge.net>
Sat, 5 Jan 2013 21:20:41 +0000 (16:20 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Sat, 5 Jan 2013 21:20:41 +0000 (16:20 -0500)
NEWS.txt
docs/refind/configfile.html
docs/refind/todo.html
refind/config.c
refind/main.c

index c5ce4048463fa7281c6c7b50e2166c1d42f11af1..139dd2b6e50257845c224637c0ba837f7c0a518d 100644 (file)
--- 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.
index 9fa9eaa85e4b34a64b246274f22d895e6cd7a905..3ca8977f4d4629ba7d50b4f4f3cab132a1e5115e 100644 (file)
@@ -215,7 +215,7 @@ timeout 20
 <tr>
    <td><tt>also_scan_dirs</tt></td>
    <td>directory path(s)</td>
-   <td>Adds the specified directory or directories to the directory list that rEFInd scans for EFI boot loaders when <tt>scanfor</tt> includes the <tt>internal</tt>, <tt>external</tt>, or <tt>optical</tt> options. Directories are specified relative to the filesystem's root directory. If this option is used, it's applied to <i>all</i> the filesystems that rEFInd scans. If a specified directory doesn't exist, rEFInd ignores it (no error results). The default value is <tt>boot</tt>, which is useful for locating Linux kernels when you have an EFI driver for your Linux root (<tt>/</tt>) filesystem.</td>
+   <td>Adds the specified directory or directories to the directory list that rEFInd scans for EFI boot loaders when <tt>scanfor</tt> includes the <tt>internal</tt>, <tt>external</tt>, or <tt>optical</tt> 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 <tt>somevol:/extra/path</tt>, to restrict the extra scan to a single volume. A volume number, preceded by <tt>fs</tt>, can be used for volumes that lack names, as in <tt>fs1:/extra/path</tt>. If you don't specify a volume name or number, this option is applied to <i>all</i> the filesystems that rEFInd scans. If a specified directory doesn't exist, rEFInd ignores it (no error results). The default value is <tt>boot</tt>, which is useful for locating Linux kernels when you have an EFI driver for your Linux root (<tt>/</tt>) filesystem.</td>
 </tr>
 <tr>
    <td><tt>dont_scan_volumes</tt> or <tt>don't_scan_volumes</tt></td>
@@ -225,7 +225,7 @@ timeout 20
 <tr>
    <td><tt>dont_scan_dirs</tt> or <tt>don't_scan_dirs</tt></td>
    <td>directory path(s)</td>
-   <td>Adds the specified directory or directories to a directory "blacklist"&mdash;these directories are <i>not</i> 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, <tt>EFI/BOOT</tt> prevents scanning the <tt>EFI/BOOT</tt> directory on <i>all</i> volumes, whereas <tt>ESP:EFI/BOOT</tt> blocks scans of <tt>EFI/BOOT</tt> on the volume called <tt>ESP</tt> but not on other volumes. You can use a filesystem number, as in <tt>fs0</tt>, in place of a volume name. This token may be useful to keep duplicate boot loaders out of the menu (say, if <tt>EFI/BOOT/bootx64.efi</tt> 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 <tt>EFI</tt>. This option takes precedence over <tt>also_scan_dirs</tt>; if a directory appears in both lists, it will <i>not</i> be scanned.</td>
+   <td>Adds the specified directory or directories to a directory "blacklist"&mdash;these directories are <i>not</i> 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, <tt>EFI/BOOT</tt> prevents scanning the <tt>EFI/BOOT</tt> directory on <i>all</i> volumes, whereas <tt>ESP:EFI/BOOT</tt> blocks scans of <tt>EFI/BOOT</tt> on the volume called <tt>ESP</tt> but not on other volumes. You can use a filesystem number, as in <tt>fs0</tt>, in place of a volume name. This token may be useful to keep duplicate boot loaders out of the menu (say, if <tt>EFI/BOOT/bootx64.efi</tt> 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 <tt>EFI</tt>. This option takes precedence over <tt>also_scan_dirs</tt>; if a directory appears in both lists, it will <i>not</i> be scanned.</td>
 </tr>
 <tr>
    <td><tt>dont_scan_files</tt> or <tt>don't_scan_files</tt></td>
index caeed82f1bafeb3bd16d5d6db5a95ab54ae5b00d..bbf0d54b7ba3a1bc9d3cdf9754b232d8d47a107e 100644 (file)
@@ -264,6 +264,13 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
        caused by a truncated DevicePath to the shell, which includes the
        shell's pathname but not the device identifier.</li>
 
+    <li>When specifying a volume by name in <tt>dont_scan_dirs</tt>,
+       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 <tt>Fedora
+       /boot</tt>). Workarounds are to rename the volume to omit the slash
+       and to use a filesystem number rather than a volume label.</li>
+
     <li>The code is in need of review to search for memory leaks and
        similar problems.</li>
 
index 63d0f312857601b373667f3a9f41957d5c08a739..81f87dd648b3b9a852c719e29561c22142049510 100644 (file)
@@ -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));
index 67381c65158affd7b9cb015b1a8a61ae407b621d..290d73eb51acc78b5195cadc39ace4c213986cb5 100644 (file)
@@ -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()