]> code.delx.au - refind/commitdiff
New ability to specify volume labels in "dont_scan_dirs" token to
authorsrs5694 <srs5694@users.sourceforge.net>
Sat, 5 Jan 2013 19:57:23 +0000 (14:57 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Sat, 5 Jan 2013 19:57:23 +0000 (14:57 -0500)
limit blacklist to just one volume.

Makefile
NEWS.txt
docs/refind/configfile.html
filesystems/Makefile
mkdistrib
refind/config.c
refind/global.h
refind/lib.c
refind/lib.h
refind/main.c

index e219fef4a02b5bc4883a7a11de8f68a25a4723ab..e5e157b6480921e58bb0d7ee790b96725196c5fe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,22 +16,22 @@ EFILIB_DIR=EfiLib
 all:   tiano
 
 gnuefi:
 all:   tiano
 
 gnuefi:
-       make -C $(LIBEG_DIR)
-       make -C $(MOK_DIR)
-       make -C $(LOADER_DIR)
-#      make -C $(FS_DIR) all_gnuefi
+       +make -C $(LIBEG_DIR)
+       +make -C $(MOK_DIR)
+       +make -C $(LOADER_DIR)
+#      +make -C $(FS_DIR) all_gnuefi
 
 fs:
 
 fs:
-       make -C $(FS_DIR)
+       +make -C $(FS_DIR)
 
 fs_gnuefi:
 
 fs_gnuefi:
-       make -C $(FS_DIR) all_gnuefi
+       +make -C $(FS_DIR) all_gnuefi
 
 tiano:
 
 tiano:
-       make AR_TARGET=EfiLib -C $(EFILIB_DIR) -f Make.tiano
-       make AR_TARGET=libeg -C $(LIBEG_DIR) -f Make.tiano
-       make AR_TARGET=mok -C $(MOK_DIR) -f Make.tiano
-       make BUILDME=refind DLL_TARGET=refind -C $(LOADER_DIR) -f Make.tiano
+       +make AR_TARGET=EfiLib -C $(EFILIB_DIR) -f Make.tiano
+       +make AR_TARGET=libeg -C $(LIBEG_DIR) -f Make.tiano
+       +make AR_TARGET=mok -C $(MOK_DIR) -f Make.tiano
+       +make BUILDME=refind DLL_TARGET=refind -C $(LOADER_DIR) -f Make.tiano
 
 clean:
        make -C $(LIBEG_DIR) clean
 
 clean:
        make -C $(LIBEG_DIR) clean
index a6a8859762791bdc7cf2c291c2b5cf0175f1abd5..c5ce4048463fa7281c6c7b50e2166c1d42f11af1 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,6 +1,12 @@
 0.6.3 (?/?/2013):
 -----------------
 
 0.6.3 (?/?/2013):
 -----------------
 
+- Added the ability to specify a volume name or number in the
+  "dont_scan_dirs" token.
+
+- 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.
+
 - Modified ISO-9660 driver so that it can handle discs with other than
   2048-byte sectors. This makes it useful for reading "hybrid ISO" images
   burned to USB flash disks.
 - Modified ISO-9660 driver so that it can handle discs with other than
   2048-byte sectors. This makes it useful for reading "hybrid ISO" images
   burned to USB flash disks.
index 345608e340995513ccb870ebcc95fd69fbdb2036..9fa9eaa85e4b34a64b246274f22d895e6cd7a905 100644 (file)
@@ -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>
 <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, on <i>any</i> partition. This 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. 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>
 </tr>
 <tr>
    <td><tt>dont_scan_files</tt> or <tt>don't_scan_files</tt></td>
index bc22314789b0ac08a28d0aaf84cc0648bd336445..cf600670f43f5998469b8eec74b7cd70eeca4e82 100644 (file)
@@ -18,23 +18,23 @@ all:        $(FILESYSTEMS)
 
 ext2:
        rm -f fsw_efi.obj
 
 ext2:
        rm -f fsw_efi.obj
-       make DRIVERNAME=ext2 -f Make.tiano
+       +make DRIVERNAME=ext2 -f Make.tiano
 
 ext4:
        rm -f fsw_efi.obj
 
 ext4:
        rm -f fsw_efi.obj
-       make DRIVERNAME=ext4 -f Make.tiano
+       +make DRIVERNAME=ext4 -f Make.tiano
 
 reiserfs:
        rm -f fsw_efi.obj
 
 reiserfs:
        rm -f fsw_efi.obj
-       make DRIVERNAME=reiserfs -f Make.tiano
+       +make DRIVERNAME=reiserfs -f Make.tiano
 
 iso9660:
        rm -f fsw_efi.obj
 
 iso9660:
        rm -f fsw_efi.obj
-       make DRIVERNAME=iso9660 -f Make.tiano
+       +make DRIVERNAME=iso9660 -f Make.tiano
 
 hfs:
        rm -f fsw_efi.obj
 
 hfs:
        rm -f fsw_efi.obj
-       make DRIVERNAME=hfs -f Make.tiano
+       +make DRIVERNAME=hfs -f Make.tiano
 
 # Build the drivers with GNU-EFI....
 
 
 # Build the drivers with GNU-EFI....
 
@@ -44,29 +44,29 @@ all_gnuefi: $(FILESYSTEMS_GNUEFI)
 
 ext2_gnuefi:
        rm -f fsw_efi.o
 
 ext2_gnuefi:
        rm -f fsw_efi.o
-       make DRIVERNAME=ext2 -f Make.gnuefi
+       +make DRIVERNAME=ext2 -f Make.gnuefi
 
 ext4_gnuefi:
        rm -f fsw_efi.o
 
 ext4_gnuefi:
        rm -f fsw_efi.o
-       make DRIVERNAME=ext4 -f Make.gnuefi
+       +make DRIVERNAME=ext4 -f Make.gnuefi
 
 reiserfs_gnuefi:
        rm -f fsw_efi.o
 
 reiserfs_gnuefi:
        rm -f fsw_efi.o
-       make DRIVERNAME=reiserfs -f Make.gnuefi
+       +make DRIVERNAME=reiserfs -f Make.gnuefi
 
 iso9660_gnuefi:
        rm -f fsw_efi.o
 
 iso9660_gnuefi:
        rm -f fsw_efi.o
-       make DRIVERNAME=iso9660 -f Make.gnuefi
+       +make DRIVERNAME=iso9660 -f Make.gnuefi
 
 hfs_gnuefi:
        rm -f fsw_efi.o
 
 hfs_gnuefi:
        rm -f fsw_efi.o
-       make DRIVERNAME=hfs -f Make.gnuefi
+       +make DRIVERNAME=hfs -f Make.gnuefi
 
 # utility rules
 
 clean:
        rm -f *~ *.bak *.o *.obj *.so *.efi *.dll err.txt $(TEXTFILES)
 
 # utility rules
 
 clean:
        rm -f *~ *.bak *.o *.obj *.so *.efi *.dll err.txt $(TEXTFILES)
-       make -C test clean
+       +make -C test clean
 
 
 install:
 
 
 install:
index 972d74e119df58cdfaea78aabfad6d4a2ecd93e0..45fa0dfe4832a15f022343ebf139996d14e6ed79 100755 (executable)
--- a/mkdistrib
+++ b/mkdistrib
@@ -56,7 +56,7 @@ zip -9r refind-src-$1.zip refind-$1
 # Build the IA32 binaries
 cd refind-$1
 ARCH=ia32 make -j4
 # Build the IA32 binaries
 cd refind-$1
 ARCH=ia32 make -j4
-ARCH=ia32 make -j4 fs
+ARCH=ia32 make fs
 mkdir -p refind-bin-$1/refind/drivers_ia32
 cp --preserve=timestamps drivers_ia32/*_ia32.efi refind-bin-$1/refind/drivers_ia32/
 cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_ia32/
 mkdir -p refind-bin-$1/refind/drivers_ia32
 cp --preserve=timestamps drivers_ia32/*_ia32.efi refind-bin-$1/refind/drivers_ia32/
 cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_ia32/
@@ -66,7 +66,7 @@ cp refind/refind_ia32.efi $StartDir/
 # Build the X64 binaries
 make clean
 make -j4
 # Build the X64 binaries
 make clean
 make -j4
-make -j4 fs
+make fs
 mkdir -p refind-bin-$1/refind/drivers_x64
 cp -a icons refind-bin-$1/refind/
 if [[ $SignIt == 1 ]] ; then
 mkdir -p refind-bin-$1/refind/drivers_x64
 cp -a icons refind-bin-$1/refind/
 if [[ $SignIt == 1 ]] ; then
index b1e09294ca558a9e78d5c3043da362d67ce1704b..63d0f312857601b373667f3a9f41957d5c08a739 100644 (file)
@@ -341,6 +341,7 @@ VOID ReadConfig(CHAR16 *FileName)
     REFIT_FILE      File;
     CHAR16          **TokenList;
     CHAR16          *FlagName;
     REFIT_FILE      File;
     CHAR16          **TokenList;
     CHAR16          *FlagName;
+    CHAR16          *SelfPath = NULL;
     UINTN           TokenCount, i;
 
     // Set a few defaults only if we're loading the default file.
     UINTN           TokenCount, i;
 
     // Set a few defaults only if we're loading the default file.
@@ -350,7 +351,14 @@ VOID ReadConfig(CHAR16 *FileName)
 //        MyFreePool(GlobalConfig.DontScanVolumes);
 //        GlobalConfig.DontScanVolumes = StrDuplicate(L" ");
        MyFreePool(GlobalConfig.DontScanDirs);
 //        MyFreePool(GlobalConfig.DontScanVolumes);
 //        GlobalConfig.DontScanVolumes = StrDuplicate(L" ");
        MyFreePool(GlobalConfig.DontScanDirs);
-       GlobalConfig.DontScanDirs = StrDuplicate(SelfDirPath);
+       if (SelfVolume->VolName) {
+          SelfPath = StrDuplicate(SelfVolume->VolName);
+       } else {
+          SelfPath = AllocateZeroPool(256 * sizeof(CHAR16));
+          SPrint(SelfPath, 255, L"fs%d", SelfVolume->VolNumber);
+       } // if/else
+       MergeStrings(&SelfPath, SelfDirPath, L':');
+       GlobalConfig.DontScanDirs = SelfPath;
        MyFreePool(GlobalConfig.DontScanFiles);
        GlobalConfig.DontScanFiles = StrDuplicate(DONT_SCAN_FILES);
     }
        MyFreePool(GlobalConfig.DontScanFiles);
        GlobalConfig.DontScanFiles = StrDuplicate(DONT_SCAN_FILES);
     }
index 8fa2320a50a1b818b3333ca9178b12765c8a49b7..9d6b667745b7a95e4477e6651817ae80f741fe15 100644 (file)
@@ -144,6 +144,7 @@ typedef struct {
    EFI_HANDLE          DeviceHandle;
    EFI_FILE            *RootDir;
    CHAR16              *VolName;
    EFI_HANDLE          DeviceHandle;
    EFI_FILE            *RootDir;
    CHAR16              *VolName;
+   UINTN               VolNumber;
    EG_IMAGE            *VolIconImage;
    EG_IMAGE            *VolBadgeImage;
    UINTN               DiskKind;
    EG_IMAGE            *VolIconImage;
    EG_IMAGE            *VolBadgeImage;
    UINTN               DiskKind;
index b04b2d41975b9a238f0c7a25312ce58a27d71d58..3c9e4c4b66a4d28beb4bb056970cd2ae1cbc66f7 100644 (file)
@@ -929,7 +929,7 @@ VOID ScanVolumes(VOID)
     MBR_PARTITION_INFO      *MbrTable;
     UINTN                   PartitionIndex;
     UINT8                   *SectorBuffer1, *SectorBuffer2;
     MBR_PARTITION_INFO      *MbrTable;
     UINTN                   PartitionIndex;
     UINT8                   *SectorBuffer1, *SectorBuffer2;
-    UINTN                   SectorSum, i;
+    UINTN                   SectorSum, i, VolNumber = 0;
 
     MyFreePool(Volumes);
     Volumes = NULL;
 
     MyFreePool(Volumes);
     Volumes = NULL;
@@ -949,6 +949,8 @@ VOID ScanVolumes(VOID)
         Volume = AllocateZeroPool(sizeof(REFIT_VOLUME));
         Volume->DeviceHandle = Handles[HandleIndex];
         ScanVolume(Volume);
         Volume = AllocateZeroPool(sizeof(REFIT_VOLUME));
         Volume->DeviceHandle = Handles[HandleIndex];
         ScanVolume(Volume);
+        if (Volume->IsReadable)
+           Volume->VolNumber = VolNumber++;
 
         AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
 
 
         AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
 
@@ -1520,6 +1522,39 @@ VOID FindVolumeAndFilename(IN EFI_DEVICE_PATH *loadpath, OUT REFIT_VOLUME **Devi
    MyFreePool(DeviceString);
 } // VOID FindVolumeAndFilename()
 
    MyFreePool(DeviceString);
 } // VOID FindVolumeAndFilename()
 
+// Splits a volume/filename string (e.g., "fs0:\EFI\BOOT") into separate
+// volume and filename components (e.g., "fs0" and "\EFI\BOOT"), returning
+// the filename component in the original *Path variable and the split-off
+// volume component in the *VolName variable.
+// Returns TRUE if both components are found, FALSE otherwise.
+BOOLEAN SplitVolumeAndFilename(IN OUT CHAR16 **Path, OUT CHAR16 **VolName) {
+   UINTN i = 0, Length;
+   CHAR16 *Filename;
+
+   if (*Path == NULL)
+      return FALSE;
+
+   if (*VolName != NULL) {
+      MyFreePool(*VolName);
+      *VolName = NULL;
+   }
+
+   Length = StrLen(*Path);
+   while ((i < Length) && ((*Path)[i] != L':')) {
+      i++;
+   } // while
+
+   if (i < Length) {
+      Filename = StrDuplicate((*Path) + i + 1);
+      (*Path)[i] = 0;
+      *VolName = *Path;
+      *Path = Filename;
+      return TRUE;
+   } else {
+      return FALSE;
+   }
+} // BOOLEAN SplitVolumeAndFilename()
+
 // Returns all the digits in the input string, including intervening
 // non-digit characters. For instance, if InString is "foo-3.3.4-7.img",
 // this function returns "3.3.4-7". If InString contains no digits,
 // Returns all the digits in the input string, including intervening
 // non-digit characters. For instance, if InString is "foo-3.3.4-7.img",
 // this function returns "3.3.4-7". If InString contains no digits,
index f1e288526da2cd9124ef716067a2f3a50e515509..35a3740d00fe5eb08353015105f367b483b53bdb 100644 (file)
@@ -109,6 +109,7 @@ CHAR16 *FindExtension(IN CHAR16 *Path);
 CHAR16 *FindLastDirName(IN CHAR16 *Path);
 CHAR16 *FindPath(IN CHAR16* FullPath);
 VOID FindVolumeAndFilename(IN EFI_DEVICE_PATH *loadpath, OUT REFIT_VOLUME **DeviceVolume, OUT CHAR16 **loader);
 CHAR16 *FindLastDirName(IN CHAR16 *Path);
 CHAR16 *FindPath(IN CHAR16* FullPath);
 VOID FindVolumeAndFilename(IN EFI_DEVICE_PATH *loadpath, OUT REFIT_VOLUME **DeviceVolume, OUT CHAR16 **loader);
+BOOLEAN SplitVolumeAndFilename(IN OUT CHAR16 **Path, OUT CHAR16 **VolName);
 CHAR16 *FindNumbers(IN CHAR16 *InString);
 CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index);
 BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List);
 CHAR16 *FindNumbers(IN CHAR16 *InString);
 CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index);
 BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List);
index 7dbc80a6d21ac801e730795582ac377c58007656..67381c65158affd7b9cb015b1a8a61ae407b621d 100644 (file)
@@ -132,7 +132,7 @@ static VOID AboutrEFInd(VOID)
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.2.1");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.2.2");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
@@ -893,6 +893,42 @@ static VOID CleanUpLoaderList(struct LOADER_LIST *LoaderList) {
    } // while
 } // static VOID CleanUpLoaderList()
 
    } // while
 } // static VOID CleanUpLoaderList()
 
+// Returns FALSE if the specified file/volume matches the GlobalConfig.DontScanDirs
+// or GlobalConfig.DontScanVolumes specification, or if Path points to a volume
+// other than the one specified by Volume. Returns TRUE if none of these conditions
+// is true. Also reduces *Path to a path alone, with no volume specification.
+static BOOLEAN ShouldScan(REFIT_VOLUME *Volume, CHAR16 *Path) {
+   CHAR16   *VolName = NULL, *DontScanDir;
+   UINTN    i = 0, VolNum;
+   BOOLEAN  ScanIt = TRUE;
+
+   if (IsIn(Volume->VolName, GlobalConfig.DontScanVolumes)) {
+      Print(L"Not scanning volume %s\n", Volume->VolName);
+      PauseForKey();
+      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)))
+            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)))
+               ScanIt = FALSE;
+         }
+      } else {
+         if (StriCmp(DontScanDir, Path) == 0)
+            ScanIt = FALSE;
+      }
+      MyFreePool(DontScanDir);
+      DontScanDir = NULL;
+   }
+   return ScanIt;
+} // BOOLEAN ShouldScan()
+
 // Scan an individual directory for EFI boot loader files and, if found,
 // add them to the list. Sorts the entries within the loader directory
 // so that the most recent one appears first in the list.
 // Scan an individual directory for EFI boot loader files and, if found,
 // add them to the list. Sorts the entries within the loader directory
 // so that the most recent one appears first in the list.
@@ -906,8 +942,9 @@ 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)) &&
 
     if ((!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && (Volume->DeviceHandle != SelfVolume->DeviceHandle)) ||
            (StriCmp(Path, SelfDirPath) != 0)) &&
-         (!IsIn(Path, GlobalConfig.DontScanDirs)) &&
-         (!IsIn(Volume->VolName, GlobalConfig.DontScanVolumes))) {
+           (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)) {
        // look through contents of the directory
        DirIterOpen(Volume->RootDir, Path, &DirIter);
        while (DirIterNext(&DirIter, 2, Pattern, &DirEntry)) {