VOID ScanVolumes(VOID)
{
EFI_STATUS Status;
- UINTN HandleCount = 0;
- UINTN HandleIndex;
EFI_HANDLE *Handles;
REFIT_VOLUME *Volume, *WholeDiskVolume;
- UINTN VolumeIndex, VolumeIndex2;
MBR_PARTITION_INFO *MbrTable;
+ UINTN HandleCount = 0;
+ UINTN HandleIndex;
+ UINTN VolumeIndex, VolumeIndex2;
UINTN PartitionIndex;
+ UINTN SectorSum, i, VolNumber = 0;
UINT8 *SectorBuffer1, *SectorBuffer2;
- UINTN SectorSum, i;
MyFreePool(Volumes);
Volumes = NULL;
Volume = AllocateZeroPool(sizeof(REFIT_VOLUME));
Volume->DeviceHandle = Handles[HandleIndex];
ScanVolume(Volume);
+ if (Volume->IsReadable)
+ Volume->VolNumber = VolNumber++;
+ else
+ Volume->VolNumber = VOL_UNREADABLE;
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,
// Implement FreePool the way it should have been done to begin with, so that
// it doesn't throw an ASSERT message if fed a NULL pointer....
-VOID MyFreePool(IN OUT VOID *Pointer) {
+VOID MyFreePool(IN VOID *Pointer) {
if (Pointer != NULL)
FreePool(Pointer);
}