summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraj <raj@FreeBSD.org>2010-02-25 15:29:41 +0000
committerraj <raj@FreeBSD.org>2010-02-25 15:29:41 +0000
commit8bf1f0cc2c3c427ae64e99f2402a4ebb0da433d3 (patch)
treef89391007d9f9d88ea942450edb80c3c33ded35d
parentfe08a5b895be0640eccbcd4fc0307cab13acf148 (diff)
downloadFreeBSD-src-8bf1f0cc2c3c427ae64e99f2402a4ebb0da433d3.zip
FreeBSD-src-8bf1f0cc2c3c427ae64e99f2402a4ebb0da433d3.tar.gz
Fix handling of GPT disk partition index.
Obtained from: Semihalf MFC after: 1 week
-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