summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2015-12-10 10:35:07 +0000
committerae <ae@FreeBSD.org>2015-12-10 10:35:07 +0000
commit088c9d3832b82e99cbb8c982016372e79cfa0770 (patch)
tree1d767785b13a4d19073452c6ef472d94f1012253 /sys/geom
parent0eb513d31cd9475cdd8af65fdc5761d96ff78c15 (diff)
downloadFreeBSD-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/geom')
-rw-r--r--sys/geom/part/g_part_gpt.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c
index 922e814..fa9973c 100644
--- a/sys/geom/part/g_part_gpt.c
+++ b/sys/geom/part/g_part_gpt.c
@@ -823,22 +823,23 @@ g_part_gpt_probe(struct g_part_table *table, struct g_consumer *cp)
return (error);
res = le16dec(buf + DOSMAGICOFFSET);
pri = G_PART_PROBE_PRI_LOW;
- for (index = 0; index < NDOSPART; index++) {
- if (buf[DOSPARTOFF + DOSPARTSIZE * index + 4] == 0xee)
- pri = G_PART_PROBE_PRI_HIGH;
- }
- g_free(buf);
- if (res != DOSMAGIC)
- return (ENXIO);
+ if (res == DOSMAGIC) {
+ for (index = 0; index < NDOSPART; index++) {
+ if (buf[DOSPARTOFF + DOSPARTSIZE * index + 4] == 0xee)
+ pri = G_PART_PROBE_PRI_HIGH;
+ }
+ g_free(buf);
- /* Check that there's a primary header. */
- buf = g_read_data(cp, pp->sectorsize, pp->sectorsize, &error);
- if (buf == NULL)
- return (error);
- res = memcmp(buf, GPT_HDR_SIG, 8);
- g_free(buf);
- if (res == 0)
- return (pri);
+ /* Check that there's a primary header. */
+ buf = g_read_data(cp, pp->sectorsize, pp->sectorsize, &error);
+ if (buf == NULL)
+ return (error);
+ res = memcmp(buf, GPT_HDR_SIG, 8);
+ g_free(buf);
+ if (res == 0)
+ return (pri);
+ } else
+ g_free(buf);
/* No primary? Check that there's a secondary. */
buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
OpenPOWER on IntegriCloud