From c1e213930348ef4ec466fba5d10ef7d5561e9223 Mon Sep 17 00:00:00 2001 From: Rafal Jaworowski Date: Thu, 4 Mar 2010 20:12:12 +0000 Subject: [PATCH] MFC r204317 Fix handling of GPT disk partition index. Obtained from: Semihalf --- 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 4cbdbea445f..3af4c795694 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)