summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_mbr.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-11-02 12:01:12 +0000
committermarcel <marcel@FreeBSD.org>2002-11-02 12:01:12 +0000
commitb737405ed3f60ffc7ff0bf8906512833f490b180 (patch)
tree85370a43bb41f7420d0d1f2ced6d742fbbb6e26a /sys/geom/geom_mbr.c
parent3ff7b038063976d0bcd1bea1983727b407f626c7 (diff)
downloadFreeBSD-src-b737405ed3f60ffc7ff0bf8906512833f490b180.zip
FreeBSD-src-b737405ed3f60ffc7ff0bf8906512833f490b180.tar.gz
Remove the GEOM_GPT hack. We now check for partition type 0xEE and
skip those. This handles the Protective MBR (PMBR) which consists of a single partition of type 0xEE that covers the whole disk and as such protects the GPT partitioning. We allow other partitions to be present besides partitions of type 0xEE and as such interpret partition type 0xEE as a "hands-off" partition only. While here, fix g_mbrext_dumpconf to test if indent is NULL and dump the data in a form that libdisk can grok. Change the logic in g_mbr_dumpconf to match that of g_mbrext_dumpconf. This does not change the output, but prevents a NULL-pointer dereference when indent == NULL && pp == NULL.
Diffstat (limited to 'sys/geom/geom_mbr.c')
-rw-r--r--sys/geom/geom_mbr.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/sys/geom/geom_mbr.c b/sys/geom/geom_mbr.c
index d53b4f9..e0784db 100644
--- a/sys/geom/geom_mbr.c
+++ b/sys/geom/geom_mbr.c
@@ -57,8 +57,6 @@
#include <geom/geom.h>
#include <geom/geom_slice.h>
-#define GEOM_GPT
-
#define MBR_CLASS_NAME "MBR"
#define MBREXT_CLASS_NAME "MBREXT"
@@ -134,13 +132,12 @@ g_mbr_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consum
gsp = gp->softc;
mp = gsp->softc;
g_slice_dumpconf(sb, indent, gp, cp, pp);
- if (indent == NULL) {
- sbuf_printf(sb, " ty %d", mp->type[pp->index]);
- return;
- }
if (pp != NULL) {
- sbuf_printf(sb, "%s<type>%d</type>\n",
- indent, mp->type[pp->index]);
+ if (indent == NULL)
+ sbuf_printf(sb, " ty %d", mp->type[pp->index]);
+ else
+ sbuf_printf(sb, "%s<type>%d</type>\n", indent,
+ mp->type[pp->index]);
}
}
@@ -201,28 +198,13 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
if (sectorsize != 512)
break;
gsp->frontstuff = sectorsize * fwsectors;
-#ifdef GEOM_GPT
- /*
- * XXX: GPT hack: Read the second sector as well and back-off
- * if it has the GPT signature. The ultimate behaviour would
- * be to back-off if we detect a protective MBR (PMBR).
- */
- buf = g_read_data(cp, 0, 2 * sectorsize, &error);
-#else
buf = g_read_data(cp, 0, sectorsize, &error);
-#endif
if (buf == NULL || error != 0)
break;
if (buf[0x1fe] != 0x55 && buf[0x1ff] != 0xaa) {
g_free(buf);
break;
}
-#ifdef GEOM_GPT
- if (!memcmp(buf + 512, "EFI PART", 8)) {
- g_free(buf);
- break;
- }
-#endif
for (i = 0; i < NDOSPART; i++)
g_dec_dos_partition(
buf + DOSPARTOFF + i * sizeof(struct dos_partition),
@@ -242,6 +224,19 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
}
npart = 0;
for (i = 0; i < NDOSPART; i++) {
+ /*
+ * A Protective MBR (PMBR) has a single partition of
+ * type 0xEE spanning the whole disk. Such a MBR
+ * protects a GPT on the disk from MBR tools that
+ * don't know anything about GPT. We're interpreting
+ * it a bit more loosely: any partition of type 0xEE
+ * is to be skipped as it doesn't contain any data
+ * that we should care about. We still allow other
+ * partitions to be present in the MBR. A PMBR will
+ * be handled correctly anyway.
+ */
+ if (dp[i].dp_typ == 0xee)
+ continue;
if (dp[i].dp_flag != 0 && dp[i].dp_flag != 0x80)
continue;
if (dp[i].dp_size == 0)
@@ -319,8 +314,11 @@ g_mbrext_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_con
gsp = gp->softc;
mp = gsp->softc;
if (pp != NULL) {
- sbuf_printf(sb, "%s<type>%d</type>\n",
- indent, mp->type[pp->index]);
+ if (indent == NULL)
+ sbuf_printf(sb, " ty %d", mp->type[pp->index]);
+ else
+ sbuf_printf(sb, "%s<type>%d</type>\n", indent,
+ mp->type[pp->index]);
}
}
OpenPOWER on IntegriCloud