Skip to content

Commit 6b89313

Browse files
committed
[FREELDR] Improve disk detection
1 parent 81edd1f commit 6b89313

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

boot/freeldr/freeldr/arch/uefi/uefidisk.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -431,30 +431,24 @@ UefiSetupBlockDevices(VOID)
431431
}
432432
else if (handles[i] == PublicBootHandle)
433433
{
434-
ULONG increment = 0;
434+
ULONG increment = i;
435435
ULONG i;
436436

437-
/* 3) Grab the offset into the array of handles and decrement per volume (valid partition) */
438-
for (increment = OffsetToBoot; increment > 0; increment--)
437+
GlobalSystemTable->BootServices->HandleProtocol(handles[increment], &bioGuid, (void**)&bio);
438+
if (bio->Media->LogicalPartition == FALSE)
439439
{
440-
GlobalSystemTable->BootServices->HandleProtocol(handles[increment], &bioGuid, (void**)&bio);
441-
if (bio->Media->LogicalPartition == FALSE)
442-
{
443-
TRACE("Found root at increment %u\n", increment);
444-
UefiBootRootIdentifier = increment;
440+
TRACE("Found root at increment %u\n", increment);
441+
UefiBootRootIdentifier = increment;
445442

446-
for (i = 0; i <= PcBiosDiskCount; ++i)
443+
for (i = 0; i <= PcBiosDiskCount; ++i)
444+
{
445+
/* Now only of the root drive number is equal to this drive we found above */
446+
if (InternalUefiDisk[i].UefiRootNumber == UefiBootRootIdentifier)
447447
{
448-
/* Now only of the root drive number is equal to this drive we found above */
449-
if (InternalUefiDisk[i].UefiRootNumber == UefiBootRootIdentifier)
450-
{
451-
InternalUefiDisk[i].IsThisTheBootDrive = TRUE;
452-
PublicBootArcDisk = i;
453-
TRACE("Found Boot drive\n");
454-
}
448+
InternalUefiDisk[i].IsThisTheBootDrive = TRUE;
449+
PublicBootArcDisk = i;
450+
TRACE("Found Boot drive\n");
455451
}
456-
457-
break;
458452
}
459453
}
460454
}

0 commit comments

Comments
 (0)