summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/boot/uboot/lib/disk.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/boot/uboot/lib/disk.c b/sys/boot/uboot/lib/disk.c
index 4cbdbea..3af4c79 100644
--- a/sys/boot/uboot/lib/disk.c
+++ b/sys/boot/uboot/lib/disk.c
@@ -376,6 +376,14 @@ stor_open_gpt(struct open_dev *od, struct uboot_devdesc *dev)
}
dev->d_disk.ptype = PTYPE_GPT;
+ /*
+ * If index of partition to open (dev->d_disk.pnum) is not defined
+ * we set it to the index of the first existing partition. This
+ * handles cases when only a disk device is specified (without full
+ * partition information) by the caller.
+ */
+ if ((od->od_nparts > 0) && (dev->d_disk.pnum == 0))
+ dev->d_disk.pnum = od->od_partitions[0].gp_index;
for (i = 0; i < od->od_nparts; i++)
if (od->od_partitions[i].gp_index == dev->d_disk.pnum)
OpenPOWER on IntegriCloud