From aac5c3d394ed93a4f5db4078eaf4d4303a500dbf Mon Sep 17 00:00:00 2001 From: ae Date: Thu, 12 Apr 2012 12:37:53 +0000 Subject: [PATCH] Read backup GPT header from the last LBA only when primary GPT header and table aren't valid. If they are ok, use hdr_lba_alt value to read backup header. This will make gptboot happy when GPT used atop of some GEOM provider, e.g. GEOM_MIRROR. Reviewed by: pjd MFC after: 2 weeks --- sys/boot/common/gpt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/boot/common/gpt.c b/sys/boot/common/gpt.c index 0078abc01e32..8baa64c37e75 100644 --- a/sys/boot/common/gpt.c +++ b/sys/boot/common/gpt.c @@ -337,16 +337,16 @@ gptread(const uuid_t *uuid, struct dsk *dskp, char *buf) gpttable = table_primary; } - altlba = drvsize(dskp); - if (altlba > 0) - altlba--; - else if (hdr_primary_lba > 0) { + if (hdr_primary_lba > 0) { /* - * If we cannot obtain disk size, but primary header - * is valid, we can get backup header location from - * there. + * If primary header is valid, we can get backup + * header location from there. */ altlba = hdr_primary.hdr_lba_alt; + } else { + altlba = drvsize(dskp); + if (altlba > 0) + altlba--; } if (altlba == 0) printf("%s: unable to locate backup GPT header\n", BOOTPROG);