]> code.delx.au - refind/blobdiff - refind/config.c
Fixed a bug that cause Tianocore builds to not mount filesystems.
[refind] / refind / config.c
index d3b06017b1c08a094b054142eacce9ec80f821ea..72bffd7f05ef6cbb28be7a17a20fd74409d5c6b3 100644 (file)
@@ -35,7 +35,7 @@
  */
 
 /*
- * Modifications copyright (c) 2012-2013 Roderick W. Smith
+ * Modifications copyright (c) 2012-2014 Roderick W. Smith
  * 
  * Modifications distributed under the terms of the GNU General Public
  * License (GPL) version 3 (GPLv3), a copy of which must be distributed
@@ -532,6 +532,8 @@ VOID ReadConfig(CHAR16 *FileName)
                     GlobalConfig.ShowTools[i - 1] = TAG_SHELL;
                 } else if (StriCmp(FlagName, L"gptsync") == 0) {
                     GlobalConfig.ShowTools[i - 1] = TAG_GPTSYNC;
+                } else if (StriCmp(FlagName, L"gdisk") == 0) {
+                   GlobalConfig.ShowTools[i - 1] = TAG_GDISK;
                 } else if (StriCmp(FlagName, L"about") == 0) {
                    GlobalConfig.ShowTools[i - 1] = TAG_ABOUT;
                 } else if (StriCmp(FlagName, L"exit") == 0) {
@@ -657,18 +659,23 @@ VOID ReadConfig(CHAR16 *FileName)
     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.
+// Finds a volume with the specified Identifier (a filesystem label, a
+// partition name, a partition GUID, or a number followed by a colon). 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;
+   UINTN     i = 0, CountedVolumes = 0, Length;
    INTN      Number = -1;
-   BOOLEAN   Found = FALSE;
+   BOOLEAN   Found = FALSE, IdIsGuid = FALSE;
+   EFI_GUID  VolGuid, NullGuid = NULL_GUID_VALUE;
 
-   if ((StrLen(Identifier) >= 2) && (Identifier[StrLen(Identifier) - 1] == L':') &&
+   VolGuid = StringAsGuid(Identifier);
+   Length = StrLen(Identifier);
+   if ((Length >= 2) && (Identifier[Length - 1] == L':') &&
        (Identifier[0] >= L'0') && (Identifier[0] <= L'9')) {
       Number = (INTN) Atoi(Identifier);
+   } else if (IsGuid(Identifier)) {
+      IdIsGuid = TRUE;
    }
    while ((i < VolumesCount) && (!Found)) {
       if (Number >= 0) { // User specified a volume by number
@@ -679,11 +686,18 @@ static BOOLEAN FindVolume(REFIT_VOLUME **Volume, CHAR16 *Identifier) {
             }
             CountedVolumes++;
          } // if
-      } else { // User specified a volume by label
-         if (StriCmp(Identifier, Volumes[i]->VolName) == 0) {
+      } else { // User specified a volume by label or GUID
+         if ((StriCmp(Identifier, Volumes[i]->VolName) == 0) ||
+             (StriCmp(Identifier, Volumes[i]->PartName) == 0)) {
             *Volume = Volumes[i];
             Found = TRUE;
          } // if
+         if (IdIsGuid && !Found) {
+            if (GuidsAreEqual(&VolGuid, &(Volumes[i]->PartGuid)) && !GuidsAreEqual(&NullGuid, &(Volumes[i]->PartGuid))) {
+               *Volume = Volumes[i];
+               Found = TRUE;
+            } // if
+         } // if
       } // if/else
       i++;
    } // while()