From 8bf1f0cc2c3c427ae64e99f2402a4ebb0da433d3 Mon Sep 17 00:00:00 2001 From: raj Date: Thu, 25 Feb 2010 15:29:41 +0000 Subject: Fix handling of GPT disk partition index. Obtained from: Semihalf MFC after: 1 week --- sys/boot/uboot/lib/disk.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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) -- cgit v1.1