]> code.delx.au - refind/commitdiff
Added support for "volume" token in "submenuentry" items in manual
authorsrs5694 <srs5694@users.sourceforge.net>
Sat, 10 Nov 2012 00:13:55 +0000 (19:13 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Sat, 10 Nov 2012 00:13:55 +0000 (19:13 -0500)
boot stanzas.

refind/config.c
refind/main.c

index a2c36fe33749d69ff7097f18b476f06af4330d47..e70d6b23d1fd985002879a06e5e258a21082b3a2 100644 (file)
@@ -436,6 +436,39 @@ VOID ReadConfig(VOID)
     MyFreePool(File.Buffer);
 } /* VOID ReadConfig() */
 
+// Finds a volume with the specified Identifier (a volume label or a number
+// followed by a colon, for the moment). If found, sets *Volume to point to
+// that volume. If not, leaves it unchanged.
+// Returns TRUE if a match was found, FALSE if not.
+static BOOLEAN FindVolume(REFIT_VOLUME **Volume, CHAR16 *Identifier) {
+   UINTN     i = 0, CountedVolumes = 0;
+   INTN      Number = -1;
+   BOOLEAN   Found = FALSE;
+
+   if ((StrLen(Identifier) >= 2) && (Identifier[StrLen(Identifier) - 1] == L':') &&
+       (Identifier[0] >= L'0') && (Identifier[0] <= L'9')) {
+      Number = (INTN) Atoi(Identifier);
+   }
+   while ((i < VolumesCount) && (!Found)) {
+      if (Number >= 0) { // User specified a volume by number
+         if (Volumes[i]->IsReadable) {
+            if (CountedVolumes == Number) {
+               *Volume = Volumes[i];
+               Found = TRUE;
+            }
+            CountedVolumes++;
+         } // if
+      } else { // User specified a volume by label
+         if (StriCmp(Identifier, Volumes[i]->VolName) == 0) {
+            *Volume = Volumes[i];
+            Found = TRUE;
+         } // if
+      } // if/else
+      i++;
+   } // while()
+   return (Found);
+} // static VOID FindVolume()
+
 static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volume, CHAR16 *Title) {
    REFIT_MENU_SCREEN  *SubScreen;
    LOADER_ENTRY       *SubEntry;
@@ -458,6 +491,15 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu
          SubEntry->LoaderPath = StrDuplicate(TokenList[1]);
          SubEntry->DevicePath = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath);
 
+      } else if ((StriCmp(TokenList[0], L"volume") == 0) && (TokenCount > 1)) {
+         if (FindVolume(&Volume, TokenList[1])) {
+            MyFreePool(SubEntry->me.Title);
+            SubEntry->me.Title        = AllocateZeroPool(256 * sizeof(CHAR16));
+            SPrint(SubEntry->me.Title, 255, L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", Volume->VolName);
+            SubEntry->me.BadgeImage   = Volume->VolBadgeImage;
+            SubEntry->VolName         = Volume->VolName;
+         } // if match found
+
       } else if (StriCmp(TokenList[0], L"initrd") == 0) {
          MyFreePool(SubEntry->InitrdPath);
          SubEntry->InitrdPath = NULL;
@@ -497,39 +539,6 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu
    Entry->me.SubScreen = SubScreen;
 } // VOID AddSubmenu()
 
-// Finds a volume with the specified Identifier (a volume label or a number
-// followed by a colon, for the moment). If found, sets *Volume to point to
-// that volume. If not, leaves it unchanged.
-// Returns TRUE if a match was found, FALSE if not.
-static BOOLEAN FindVolume(REFIT_VOLUME **Volume, CHAR16 *Identifier) {
-   UINTN     i = 0, CountedVolumes = 0;
-   INTN      Number = -1;
-   BOOLEAN   Found = FALSE;
-
-   if ((StrLen(Identifier) >= 2) && (Identifier[StrLen(Identifier) - 1] == L':') &&
-       (Identifier[0] >= L'0') && (Identifier[0] <= L'9')) {
-      Number = (INTN) Atoi(Identifier);
-   }
-   while ((i < VolumesCount) && (!Found)) {
-      if (Number >= 0) { // User specified a volume by number
-         if (Volumes[i]->IsReadable) {
-            if (CountedVolumes == Number) {
-               *Volume = Volumes[i];
-               Found = TRUE;
-            }
-            CountedVolumes++;
-         } // if
-      } else { // User specified a volume by label
-         if (StriCmp(Identifier, Volumes[i]->VolName) == 0) {
-            *Volume = Volumes[i];
-            Found = TRUE;
-         } // if
-      } // if/else
-      i++;
-   } // while()
-   return (Found);
-} // static VOID FindVolume()
-
 // Adds the options from a SINGLE refind.conf stanza to a new loader entry and returns
 // that entry. The calling function is then responsible for adding the entry to the
 // list of entries.
index 11a41813e49ead26222b0a59466f719fd9c8253e..721dbe72e849c25b38a13843f5f37160988934f4 100644 (file)
@@ -115,7 +115,7 @@ static VOID AboutrEFInd(VOID)
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.7.1");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.7.2");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");