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
This commit is contained in:
ae 2012-04-12 12:37:53 +00:00
parent 3d2bebcc35
commit aac5c3d394

View File

@ -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);