diff options
author | ae <ae@FreeBSD.org> | 2015-12-10 10:35:07 +0000 |
---|---|---|
committer | ae <ae@FreeBSD.org> | 2015-12-10 10:35:07 +0000 |
commit | 088c9d3832b82e99cbb8c982016372e79cfa0770 (patch) | |
tree | 1d767785b13a4d19073452c6ef472d94f1012253 /sys/boot | |
parent | 0eb513d31cd9475cdd8af65fdc5761d96ff78c15 (diff) | |
download | FreeBSD-src-088c9d3832b82e99cbb8c982016372e79cfa0770.zip FreeBSD-src-088c9d3832b82e99cbb8c982016372e79cfa0770.tar.gz |
Make detection of GPT a bit more reliable.
When we are detecting a partition table and didn't find PMBR, try to
read backup GPT header from the last sector and if it is correct,
assume that we have GPT.
Reviewed by: rpokala
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D4282
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/common/part.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/boot/common/part.c b/sys/boot/common/part.c index f978663..8638f02 100644 --- a/sys/boot/common/part.c +++ b/sys/boot/common/part.c @@ -301,12 +301,12 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread) } } } - DEBUG("GPT detected"); if (pri == 0 && sec == 0) { /* Both primary and backup tables are invalid. */ table->type = PTABLE_NONE; goto out; } + DEBUG("GPT detected"); size = MIN(hdr.hdr_entries * hdr.hdr_entsz, MAXTBLSZ * table->sectorsize); for (i = 0; i < size / hdr.hdr_entsz; i++) { @@ -635,6 +635,11 @@ ptable_open(void *dev, off_t sectors, uint16_t sectorsize, if (buf[DOSMAGICOFFSET] != 0x55 || buf[DOSMAGICOFFSET + 1] != 0xaa) { DEBUG("magic sequence not found"); +#if defined(LOADER_GPT_SUPPORT) + /* There is no PMBR, check that we have backup GPT */ + table->type = PTABLE_GPT; + table = ptable_gptread(table, dev, dread); +#endif goto out; } /* Check that we have PMBR. Also do some validation. */ |