MBR_PARTITION_INFO *MbrTable;
UINTN PartitionIndex;
UINT8 *SectorBuffer1, *SectorBuffer2;
- UINTN SectorSum, i;
+ UINTN SectorSum, i, VolNumber = 0;
MyFreePool(Volumes);
Volumes = NULL;
Volume = AllocateZeroPool(sizeof(REFIT_VOLUME));
Volume->DeviceHandle = Handles[HandleIndex];
ScanVolume(Volume);
+ if (Volume->IsReadable)
+ Volume->VolNumber = VolNumber++;
AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
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,
} // VOID EjectMedia()
-// // Return the GUID as a string, suitable for display to the user. Note that the calling
-// // function is responsible for freeing the allocated memory.
-// CHAR16 * GuidAsString(EFI_GUID *GuidData) {
-// CHAR16 *TheString;
-//
-// TheString = AllocateZeroPool(42 * sizeof(CHAR16));
-// if (TheString != 0) {
-// SPrint (TheString, 82, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-// (UINTN)GuidData->Data1, (UINTN)GuidData->Data2, (UINTN)GuidData->Data3,
-// (UINTN)GuidData->Data4[0], (UINTN)GuidData->Data4[1], (UINTN)GuidData->Data4[2],
-// (UINTN)GuidData->Data4[3], (UINTN)GuidData->Data4[4], (UINTN)GuidData->Data4[5],
-// (UINTN)GuidData->Data4[6], (UINTN)GuidData->Data4[7]);
-// }
-// return TheString;
-// } // GuidAsString(EFI_GUID *GuidData)
+// Return the GUID as a string, suitable for display to the user. Note that the calling
+// function is responsible for freeing the allocated memory.
+CHAR16 * GuidAsString(EFI_GUID *GuidData) {
+ CHAR16 *TheString;
+
+ TheString = AllocateZeroPool(42 * sizeof(CHAR16));
+ if (TheString != 0) {
+ SPrint (TheString, 82, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ (UINTN)GuidData->Data1, (UINTN)GuidData->Data2, (UINTN)GuidData->Data3,
+ (UINTN)GuidData->Data4[0], (UINTN)GuidData->Data4[1], (UINTN)GuidData->Data4[2],
+ (UINTN)GuidData->Data4[3], (UINTN)GuidData->Data4[4], (UINTN)GuidData->Data4[5],
+ (UINTN)GuidData->Data4[6], (UINTN)GuidData->Data4[7]);
+ }
+ return TheString;
+} // GuidAsString(EFI_GUID *GuidData)