loader: r354415 did miss to sort subpaths below the partitions

Tested on actual system (MBP with UEFI 1.10).
This commit is contained in:
Toomas Soome 2019-11-15 18:57:00 +00:00
parent 5877e649f0
commit 254fe63897

View File

@ -506,9 +506,12 @@ efipart_initcd(void)
static bool static bool
efipart_hdinfo_add_node(pdinfo_t *hd, EFI_DEVICE_PATH *node) efipart_hdinfo_add_node(pdinfo_t *hd, EFI_DEVICE_PATH *node)
{ {
pdinfo_t *pd, *last; pdinfo_t *pd, *ptr;
VENDOR_DEVICE_PATH *ven_node;
if (node == NULL)
return (false);
/* Find our disk device. */
STAILQ_FOREACH(pd, &hdinfo, pd_link) { STAILQ_FOREACH(pd, &hdinfo, pd_link) {
if (efi_devpath_is_prefix(pd->pd_devpath, hd->pd_devpath)) if (efi_devpath_is_prefix(pd->pd_devpath, hd->pd_devpath))
break; break;
@ -516,13 +519,28 @@ efipart_hdinfo_add_node(pdinfo_t *hd, EFI_DEVICE_PATH *node)
if (pd == NULL) if (pd == NULL)
return (false); return (false);
/* If the node is not MEDIA_HARDDRIVE_DP, it is sub-partition. */
if (DevicePathSubType(node) != MEDIA_HARDDRIVE_DP) {
STAILQ_FOREACH(ptr, &pd->pd_part, pd_link) {
if (efi_devpath_is_prefix(ptr->pd_devpath,
hd->pd_devpath))
break;
}
/*
* ptr == NULL means we have handles in unexpected order
* and we would need to re-order the partitions later.
*/
if (ptr != NULL)
pd = ptr;
}
/* Add the partition. */ /* Add the partition. */
if (DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) { if (DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) {
hd->pd_unit = ((HARDDRIVE_DEVICE_PATH *)node)->PartitionNumber; hd->pd_unit = ((HARDDRIVE_DEVICE_PATH *)node)->PartitionNumber;
} else { } else {
last = STAILQ_LAST(&pd->pd_part, pdinfo, pd_link); ptr = STAILQ_LAST(&pd->pd_part, pdinfo, pd_link);
if (last != NULL) if (ptr != NULL)
hd->pd_unit = last->pd_unit + 1; hd->pd_unit = ptr->pd_unit + 1;
else else
hd->pd_unit = 0; hd->pd_unit = 0;
} }