]> code.delx.au - refind/commitdiff
Minor code optimization in ScanLoaderDir() and related functions.
authorsrs5694 <srs5694@users.sourceforge.net>
Wed, 1 Mar 2017 20:20:43 +0000 (15:20 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Wed, 1 Mar 2017 20:20:43 +0000 (15:20 -0500)
debian/changelog
refind.conf-sample
refind.spec
refind/main.c

index 3126dc9b089823e2fa0f213dd2fe6c36dde9f1ac..4f099efeb3adb1b7ac9744469968a6aa9f52f44e 100644 (file)
@@ -1,3 +1,9 @@
+refind (0.10.4.2-0ppa1) xenial; urgency=medium
+
+  * Version bump
+
+ -- Roderick Smith <rodsmith@rodsbooks.com>  Wed, 22 Feb 2017 09:25:33 -0400
+
 refind (0.10.4-0ppa1) xenial; urgency=medium
 
   * Version bump
index 33f2db236869225a7348692923f68c2e6598648c..d023b0001581def8f9f1425c9832f81c5905f741 100644 (file)
@@ -479,6 +479,28 @@ menuentry Linux {
     disabled
 }
 
+# Below is a more complex Linux example, specifically for Arch Linux.
+# This example MUST be modified for your specific installation; if nothing
+# else, the PARTUUID code must be changed for your disk. Because Arch Linux
+# does not include version numbers in its kernel and initrd filenames, you
+# may need to use manual boot stanzas when using fallback initrds or
+# multiple kernels with Arch. This example is modified from one in the Arch
+# wiki page on rEFInd (https://wiki.archlinux.org/index.php/rEFInd).
+menuentry "Arch Linux" {
+    icon     /EFI/refind/icons/os_arch.png
+    volume   "Arch Linux"
+    loader   /boot/vmlinuz-linux
+    initrd   /boot/initramfs-linux.img
+    options  "root=PARTUUID=5028fa50-0079-4c40-b240-abfaf28693ea rw add_efi_memmap"
+    submenuentry "Boot using fallback initramfs" {
+        initrd /boot/initramfs-linux-fallback.img
+    }
+    submenuentry "Boot to terminal" {
+        add_options "systemd.unit=multi-user.target"
+    }
+    disabled
+}
+
 # A sample entry for loading Ubuntu using its standard name for
 # its GRUB 2 boot loader. Note uses of Linux-style forward slashes
 menuentry Ubuntu {
index fd3c92fdc99e284004139c5d2a1dd4fa39976e97..da61e8e8f909daabb2c27fcbc7420e1b6729a6a2 100644 (file)
@@ -1,6 +1,6 @@
 Summary: EFI boot manager software
 Name: refind
-Version: 0.10.4
+Version: 0.10.5
 Release: 1%{?dist}
 Summary: EFI boot manager software
 License: GPLv3
@@ -177,6 +177,8 @@ fi
 # thus wiping out the just-updated files.
 
 %changelog
+* Wed Mar 1 2017 R Smith <rodsmith@rodsbooks.com> - 0.10.5
+- Updated spec file for 0.10.5
 * Sun Oct 9 2016 R Smith <rodsmith@rodsbooks.com> - 0.10.4
 - Updated spec file for 0.10.4
 * Sun Apr 24 2016 R Smith <rodsmith@rodsbooks.com> - 0.10.3
index d183e836d4110e8e728a478803a768039f5035ea..7bbd8fca9782927fb525226617d30652e51937b8 100644 (file)
@@ -1300,9 +1300,7 @@ static BOOLEAN DuplicatesFallback(IN REFIT_VOLUME *Volume, IN CHAR16 *FileName)
         return FALSE;
     }
 
-    if (FallbackSize != FileSize) { // not same size, so can't be identical
-        AreIdentical = FALSE;
-    } else { // could be identical; do full check....
+    if (FallbackSize == FileSize) { // could be identical; do full check....
         FileContents = AllocatePool(FileSize);
         FallbackContents = AllocatePool(FallbackSize);
         if (FileContents && FallbackContents) {
@@ -1333,25 +1331,20 @@ static BOOLEAN DuplicatesFallback(IN REFIT_VOLUME *Volume, IN CHAR16 *FileName)
 // file to fail to open, which would return a false positive -- but as I use
 // this function to exclude symbolic links from the list of boot loaders,
 // that would be fine, since such boot loaders wouldn't work.)
-static BOOLEAN IsSymbolicLink(REFIT_VOLUME *Volume, CHAR16 *Path, EFI_FILE_INFO *DirEntry) {
+// CAUTION: *FullName MUST be properly cleaned up (via CleanUpPathNameSlashes())
+static BOOLEAN IsSymbolicLink(REFIT_VOLUME *Volume, CHAR16 *FullName, EFI_FILE_INFO *DirEntry) {
     EFI_FILE_HANDLE FileHandle;
     EFI_FILE_INFO   *FileInfo = NULL;
     EFI_STATUS      Status;
     UINTN           FileSize2 = 0;
-    CHAR16          *FileName;
 
-    FileName = StrDuplicate(Path);
-    MergeStrings(&FileName, DirEntry->FileName, L'\\');
-    CleanUpPathNameSlashes(FileName);
-
-    Status = refit_call5_wrapper(Volume->RootDir->Open, Volume->RootDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0);
+    Status = refit_call5_wrapper(Volume->RootDir->Open, Volume->RootDir, &FileHandle, FullName, EFI_FILE_MODE_READ, 0);
     if (Status == EFI_SUCCESS) {
         FileInfo = LibFileInfo(FileHandle);
         if (FileInfo != NULL)
             FileSize2 = FileInfo->FileSize;
     }
 
-    MyFreePool(FileName);
     MyFreePool(FileInfo);
 
     return (DirEntry->FileSize != FileSize2);
@@ -1363,15 +1356,14 @@ static BOOLEAN IsSymbolicLink(REFIT_VOLUME *Volume, CHAR16 *Path, EFI_FILE_INFO
 // there's no point in cluttering the display with two kernels that will
 // behave identically on non-SB systems, or when one will fail when SB
 // is active.
-static BOOLEAN HasSignedCounterpart(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16 *Filename) {
+// CAUTION: *FullName MUST be properly cleaned up (via CleanUpPathNameSlashes())
+static BOOLEAN HasSignedCounterpart(IN REFIT_VOLUME *Volume, IN CHAR16 *FullName) {
     CHAR16 *NewFile = NULL;
     BOOLEAN retval = FALSE;
 
-    MergeStrings(&NewFile, Path, 0);
-    MergeStrings(&NewFile, Filename, L'\\');
+    MergeStrings(&NewFile, FullName, 0);
     MergeStrings(&NewFile, L".efi.signed", 0);
     if (NewFile != NULL) {
-        CleanUpPathNameSlashes(NewFile);
         if (FileExists(Volume->RootDir, NewFile))
             retval = TRUE;
         MyFreePool(NewFile);
@@ -1390,7 +1382,7 @@ static BOOLEAN ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16
     EFI_STATUS              Status;
     REFIT_DIR_ITER          DirIter;
     EFI_FILE_INFO           *DirEntry;
-    CHAR16                  FileName[256], *Extension;
+    CHAR16                  Message[256], *Extension, *FullName;
     struct LOADER_LIST      *LoaderList = NULL, *NewLoader;
     LOADER_ENTRY            *FirstKernel = NULL, *LatestEntry = NULL;
     BOOLEAN                 FoundFallbackDuplicate = FALSE, IsLinux = FALSE, InSelfPath;
@@ -1402,35 +1394,31 @@ static BOOLEAN ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16
        DirIterOpen(Volume->RootDir, Path, &DirIter);
        while (DirIterNext(&DirIter, 2, Pattern, &DirEntry)) {
           Extension = FindExtension(DirEntry->FileName);
+          FullName = StrDuplicate(Path);
+          MergeStrings(&FullName, DirEntry->FileName, L'\\');
+          CleanUpPathNameSlashes(FullName);
           if (DirEntry->FileName[0] == '.' ||
               MyStriCmp(Extension, L".icns") ||
               MyStriCmp(Extension, L".png") ||
               (MyStriCmp(DirEntry->FileName, FALLBACK_BASENAME) && (MyStriCmp(Path, L"EFI\\BOOT"))) ||
               FilenameIn(Volume, Path, DirEntry->FileName, SHELL_NAMES) ||
-              IsSymbolicLink(Volume, Path, DirEntry) || /* is symbolic link */
-              HasSignedCounterpart(Volume, Path, DirEntry->FileName) || /* a file with same name plus ".efi.signed" is present */
-              FilenameIn(Volume, Path, DirEntry->FileName, GlobalConfig.DontScanFiles)) {
+              IsSymbolicLink(Volume, FullName, DirEntry) || /* is symbolic link */
+              HasSignedCounterpart(Volume, FullName) || /* a file with same name plus ".efi.signed" is present */
+              FilenameIn(Volume, Path, DirEntry->FileName, GlobalConfig.DontScanFiles) ||
+              !IsValidLoader(Volume->RootDir, FullName)) {
                 continue;   // skip this
           }
 
-          if (Path)
-             SPrint(FileName, 255, L"\\%s\\%s", Path, DirEntry->FileName);
-          else
-             SPrint(FileName, 255, L"\\%s", DirEntry->FileName);
-          CleanUpPathNameSlashes(FileName);
-
-          if(!IsValidLoader(Volume->RootDir, FileName))
-             continue;
-
           NewLoader = AllocateZeroPool(sizeof(struct LOADER_LIST));
           if (NewLoader != NULL) {
-             NewLoader->FileName = StrDuplicate(FileName);
+             NewLoader->FileName = StrDuplicate(FullName);
              NewLoader->TimeStamp = DirEntry->ModificationTime;
              LoaderList = AddLoaderListEntry(LoaderList, NewLoader);
-             if (DuplicatesFallback(Volume, FileName))
+             if (DuplicatesFallback(Volume, FullName))
                 FoundFallbackDuplicate = TRUE;
           } // if
           MyFreePool(Extension);
+          MyFreePool(FullName);
        } // while
 
        NewLoader = LoaderList;
@@ -1458,10 +1446,10 @@ static BOOLEAN ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16
        // it down to buggy EFI implementations and ignoring that particular error....
        if ((Status != EFI_NOT_FOUND) && (Status != EFI_INVALID_PARAMETER)) {
           if (Path)
-             SPrint(FileName, 255, L"while scanning the %s directory", Path);
+             SPrint(Message, 255, L"while scanning the %s directory", Path);
           else
-             StrCpy(FileName, L"while scanning the root directory");
-          CheckError(Status, FileName);
+             StrCpy(Message, L"while scanning the root directory");
+          CheckError(Status, Message);
        } // if (Status != EFI_NOT_FOUND)
     } // if not scanning a blacklisted directory