]> code.delx.au - refind/commitdiff
Added "dont_scan_dirs" option to configuration file.
authorsrs5694 <srs5694@users.sourceforge.net>
Tue, 29 May 2012 02:20:53 +0000 (22:20 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Tue, 29 May 2012 02:20:53 +0000 (22:20 -0400)
NEWS.txt
docs/refind/todo.html
refind.conf-sample
refind/config.c
refind/global.h
refind/lib.c
refind/lib.h
refind/main.c

index 5c89c5e5dad1bb921faf3130710f10534beb31f2..9b2333734b44530be923567c48a3a5f7615be4d6 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,3 +1,9 @@
+0.4.2 (?/??/2012):
+------------------
+
+- Added "dont_scan_dirs" configuration file option, which adds directories
+  to a "blacklist" of directories that are NOT scanned for boot loaders.
+
 0.4.1 (5/25/2012):
 ------------------
 
index 952e74e3412b32b0df957687fa118cf17a8b8069..7e7356bdac53203a9638564dbf466b0da10a5b6d 100644 (file)
@@ -276,6 +276,11 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
     <li>I'd like to give the user the ability to set custom options on a
        single-boot basis, similar to what's possible in GRUB.</li>
 
+    <li>A GUI configuration tool would be nice, but it's low on my personal
+       priority list. If you'd like to contribute, I prefer something
+       written in a cross-platform GUI toolkit, so that a single code base
+       can be used on any of the major OSes.</li>
+
     </ul></li> <!-- New features -->
 
     <li><b>Improvements to the EFI drivers:</b>
index 7e7855566559dbb21cfa1a20cc96915c98618dd7..bfdeaa110b24f1eaa29b508e4dd5877ae60fc1e3 100644 (file)
@@ -115,6 +115,18 @@ timeout 20
 #
 #also_scan_dirs boot,EFI/linux/kernels
 
+# Directories that should NOT be scanned for boot loaders. By default,
+# rEFInd doesn't scan its own directory or the EFI/tools directory.
+# You can "blacklist" additional directories with this option, which
+# takes a list of directory names as options. You might do this to
+# keep EFI/boot/bootx64.efi out of the menu if that's a duplicate of
+# another boot loader or to exclude a directory that holds drivers
+# or non-bootloader utilities provided by a hardware manufacturer. If
+# a directory is listed both here and in also_scan_dirs, dont_scan_dirs
+# takes precedence.
+#
+#dont_scan_dirs EFI/boot,EFI/Dell
+
 # Scan for Linux kernels that lack a ".efi" filename extension. This is
 # useful for better integration with Linux distributions that provide
 # kernels with EFI stub loaders but that don't give those kernels filenames
index 7e99dcf1abfd4d4099669a017573b1eb88069fbe..63b0a22734937a2041505a44cd7ff54c1e9620f0 100644 (file)
@@ -284,7 +284,8 @@ static VOID HandleString(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16
 } // static VOID HandleString()
 
 // Handle a parameter with a series of string arguments, to be added to a comma-delimited
-// list
+// list. Passes each token through the CleanUpPathNameSlashes() function to ensure
+// consistency in subsequent comparisons of filenames.
 static VOID HandleStrings(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16 **Target) {
    UINTN i;
 
@@ -292,8 +293,10 @@ static VOID HandleStrings(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16
       FreePool(*Target);
       *Target = NULL;
    } // if
-    for (i = 1; i < TokenCount; i++)
-       MergeStrings(Target, TokenList[i], L',');
+   for (i = 1; i < TokenCount; i++) {
+      CleanUpPathNameSlashes(TokenList[i]);
+      MergeStrings(Target, TokenList[i], L',');
+   }
 } // static VOID HandleStrings()
 
 // read config file
@@ -356,6 +359,9 @@ VOID ReadConfig(VOID)
         } else if (StriCmp(TokenList[0], L"also_scan_dirs") == 0) {
             HandleStrings(TokenList, TokenCount, &(GlobalConfig.AlsoScan));
 
+        } else if ((StriCmp(TokenList[0], L"don't_scan_dirs") == 0) || (StriCmp(TokenList[0], L"dont_scan_dirs") == 0)) {
+            HandleStrings(TokenList, TokenCount, &(GlobalConfig.DontScan));
+
         } else if (StriCmp(TokenList[0], L"scan_driver_dirs") == 0) {
             HandleStrings(TokenList, TokenCount, &(GlobalConfig.DriverDirs));
 
index 678054b6ac3b8b33a9d994f768bb2c1ac3cda243..b2b38b81c9f28d06ee73a3e5c6d4d889296edb30 100644 (file)
@@ -164,6 +164,7 @@ typedef struct {
    CHAR16      *SelectionBigFileName;
    CHAR16      *DefaultSelection;
    CHAR16      *AlsoScan;
+   CHAR16      *DontScan;
    CHAR16      *DriverDirs;
    CHAR16      *IconsDir;
    UINTN       ShowTools[NUM_TOOLS];
index be95e0c23d703f2058b39466a3582d3dab1eb0fe..71f76c57b9294ab41c53aa5c5017c78bed1bf844 100644 (file)
@@ -1200,7 +1200,8 @@ CHAR16 *FindLastDirName(IN CHAR16 *Path) {
 
 // Returns the directory portion of a pathname. For instance,
 // if FullPath is 'EFI\foo\bar.efi', this function returns the
-// string 'EFI\foo'.
+// string 'EFI\foo'. The calling function is responsible for
+// freeing the returned string's memory.
 CHAR16 *FindPath(IN CHAR16* FullPath) {
    UINTN i, LastBackslash = 0;
    CHAR16 *PathOnly;
@@ -1278,6 +1279,22 @@ CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index) {
    return (FoundString);
 } // CHAR16 *FindCommaDelimited()
 
+// Returns TRUE if SmallString is an element in the comma-delimited List,
+// FALSE otherwise. Performs comparison case-insensitively (except on
+// buggy EFIs with case-sensitive StriCmp() functions).
+BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List) {
+   UINTN     i = 0;
+   BOOLEAN   Found = FALSE;
+   CHAR16    *OneElement;
+
+   if (SmallString && List) {
+      while (!Found && (OneElement = FindCommaDelimited(List, i++))) {
+         if (StriCmp(OneElement, SmallString) == 0)
+            Found = TRUE;
+      } // while
+   } // if
+   return Found;
+} // BOOLEAN IsIn()
 
 static EFI_GUID AppleRemovableMediaGuid = APPLE_REMOVABLE_MEDIA_PROTOCOL_GUID;
 
index f7e9eda964eac71282481e255496c78a0dfdd92a..17af8bd21e0fa7addcf156ebcf64d2cb40db68ce 100644 (file)
@@ -104,6 +104,7 @@ CHAR16 *FindLastDirName(IN CHAR16 *Path);
 CHAR16 *FindPath(IN CHAR16* FullPath);
 CHAR16 *FindNumbers(IN CHAR16 *InString);
 CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index);
+BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List);
 
 BOOLEAN EjectMedia(VOID);
 
index 1e4dfd1286c5d4253bbb72c4150bbccee54d2907..66d51ff0549623e195e9fae1c737c819aacc89c0 100644 (file)
@@ -87,7 +87,7 @@ static REFIT_MENU_ENTRY MenuEntryExit     = { L"Exit rEFInd", TAG_EXIT, 1, 0, 0,
 static REFIT_MENU_SCREEN MainMenu       = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" };
 static REFIT_MENU_SCREEN AboutMenu      = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL };
 
-REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                               {TAG_SHELL, TAG_ABOUT, TAG_SHUTDOWN, TAG_REBOOT, 0, 0, 0, 0, 0 }};
 
 // Structure used to hold boot loader filenames and time stamps in
@@ -106,7 +106,7 @@ static VOID AboutrEFInd(VOID)
 {
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.1");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.1.1");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
@@ -787,8 +787,8 @@ static VOID ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16 *P
     CHAR16                  FileName[256], *Extension;
     struct LOADER_LIST      *LoaderList = NULL, *NewLoader;
 
-    if (!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && Volume->DeviceHandle != SelfVolume->DeviceHandle) ||
-        (StriCmp(Path, SelfDirPath) != 0)) {
+    if ((!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && Volume->DeviceHandle != SelfVolume->DeviceHandle) ||
+        (StriCmp(Path, SelfDirPath) != 0)) && (!IsIn(Path, GlobalConfig.DontScan))) {
        // look through contents of the directory
        DirIterOpen(Volume->RootDir, Path, &DirIter);
        while (DirIterNext(&DirIter, 2, Pattern, &DirEntry)) {
@@ -844,20 +844,22 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) {
 
    if ((Volume->RootDir != NULL) && (Volume->VolName != NULL)) {
       // check for Mac OS X boot loader
-      StrCpy(FileName, MACOSX_LOADER_PATH);
-      if (FileExists(Volume->RootDir, FileName)) {
-         AddLoaderEntry(FileName, L"Mac OS X", Volume);
-      }
+      if (!IsIn(L"System\\Library\\CoreServices", GlobalConfig.DontScan)) {
+         StrCpy(FileName, MACOSX_LOADER_PATH);
+         if (FileExists(Volume->RootDir, FileName)) {
+            AddLoaderEntry(FileName, L"Mac OS X", Volume);
+         }
 
-      // check for XOM
-      StrCpy(FileName, L"System\\Library\\CoreServices\\xom.efi");
-      if (FileExists(Volume->RootDir, FileName)) {
-         AddLoaderEntry(FileName, L"Windows XP (XoM)", Volume);
-      }
+         // check for XOM
+         StrCpy(FileName, L"System\\Library\\CoreServices\\xom.efi");
+         if (FileExists(Volume->RootDir, FileName)) {
+            AddLoaderEntry(FileName, L"Windows XP (XoM)", Volume);
+         }
+      } // if Mac directory not in GlobalConfig.DontScan list
 
       // check for Microsoft boot loader/menu
       StrCpy(FileName, L"EFI\\Microsoft\\Boot\\Bootmgfw.efi");
-      if (FileExists(Volume->RootDir, FileName)) {
+      if (FileExists(Volume->RootDir, FileName) && !IsIn(L"EFI\\Microsoft\\Boot", GlobalConfig.DontScan)) {
          AddLoaderEntry(FileName, L"Microsoft EFI boot", Volume);
       }