summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-10-28 07:50:47 +0000
committerphk <phk@FreeBSD.org>2002-10-28 07:50:47 +0000
commite3283252f9faf305c9d6485bf3a3e172fe91bfed (patch)
tree867bce9cc0d4f06833025c5ae5decd39b0d043d2 /sys
parentfb65dc6cd6e7f2518756ef29dae14ffb950cbc29 (diff)
downloadFreeBSD-src-e3283252f9faf305c9d6485bf3a3e172fe91bfed.zip
FreeBSD-src-e3283252f9faf305c9d6485bf3a3e172fe91bfed.tar.gz
Add more compatibility junk.
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/geom_bsd.c26
-rw-r--r--sys/geom/geom_mbr.c19
2 files changed, 34 insertions, 11 deletions
diff --git a/sys/geom/geom_bsd.c b/sys/geom/geom_bsd.c
index 9446186..8e10e1b 100644
--- a/sys/geom/geom_bsd.c
+++ b/sys/geom/geom_bsd.c
@@ -70,6 +70,7 @@
*/
struct g_bsd_softc {
off_t labeloffset;
+ off_t mbroffset;
off_t rawoffset;
struct disklabel ondisk;
struct disklabel inram;
@@ -227,13 +228,10 @@ ondisk2inram(struct g_bsd_softc *sc)
sc->rawoffset = 0;
}
if (sc->rawoffset > 0) {
-
- if (dl->d_partitions[RAW_PART].p_size +
- sc->rawoffset == dl->d_secperunit) {
- }
for (i = 0; i < dl->d_npartitions; i++) {
ppp = &dl->d_partitions[i];
- ppp->p_offset -= sc->rawoffset;
+ if (ppp->p_offset != 0)
+ ppp->p_offset -= sc->rawoffset;
}
}
dl->d_checksum = 0;
@@ -247,10 +245,15 @@ inram2ondisk(struct g_bsd_softc *sc)
int i;
sc->ondisk = sc->inram;
+ if (sc->mbroffset != 0)
+ sc->rawoffset = sc->mbroffset / sc->inram.d_secsize;
if (sc->rawoffset != 0) {
for (i = 0; i < sc->inram.d_npartitions; i++) {
ppp = &sc->ondisk.d_partitions[i];
- ppp->p_offset += sc->rawoffset;
+ if (ppp->p_size > 0)
+ ppp->p_offset += sc->rawoffset;
+ else
+ ppp->p_offset = 0;
}
}
sc->ondisk.d_checksum = 0;
@@ -595,11 +598,15 @@ g_bsd_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consum
gsp = gp->softc;
ms = gsp->softc;
- if (pp == NULL && cp == NULL) {
+ g_slice_dumpconf(sb, indent, gp, cp, pp);
+ if (indent != NULL && pp == NULL && cp == NULL) {
sbuf_printf(sb, "%s<labeloffset>%jd</labeloffset>\n",
indent, (intmax_t)ms->labeloffset);
+ sbuf_printf(sb, "%s<rawoffset>%jd</rawoffset>\n",
+ indent, (intmax_t)ms->rawoffset);
+ sbuf_printf(sb, "%s<mbroffset>%jd</mbroffset>\n",
+ indent, (intmax_t)ms->mbroffset);
}
- g_slice_dumpconf(sb, indent, gp, cp, pp);
}
/*
@@ -694,6 +701,9 @@ g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
if (!error && i != 165 && flags == G_TF_NORMAL)
break;
+ ms->mbroffset = 0;
+ g_getattr("MBR::offset", cp, &ms->mbroffset);
+
/* Get sector size, we need it to read data. */
secsize = cp->provider->sectorsize;
if (secsize < 512)
diff --git a/sys/geom/geom_mbr.c b/sys/geom/geom_mbr.c
index 23b50c3..d1d761c 100644
--- a/sys/geom/geom_mbr.c
+++ b/sys/geom/geom_mbr.c
@@ -118,6 +118,9 @@ g_mbr_start(struct bio *bp)
if (bp->bio_cmd == BIO_GETATTR) {
if (g_handleattr_int(bp, "MBR::type", mp->type[index]))
return (1);
+ if (g_handleattr_off_t(bp, "MBR::offset",
+ gsp->slices[index].offset))
+ return (1);
}
return (0);
}
@@ -128,9 +131,13 @@ g_mbr_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consum
struct g_mbr_softc *mp;
struct g_slicer *gsp;
- g_slice_dumpconf(sb, indent, gp, cp, pp);
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]);
@@ -222,11 +229,17 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
dp + i);
g_free(buf);
if (bcmp(dp, historical_bogus_partition_table,
- sizeof historical_bogus_partition_table) == 0)
+ sizeof historical_bogus_partition_table) == 0) {
+ if (bootverbose)
+ printf("Ignoring known bogus MBR #0\n");
break;
+ }
if (bcmp(dp, historical_bogus_partition_table_fixed,
- sizeof historical_bogus_partition_table_fixed) == 0)
+ sizeof historical_bogus_partition_table_fixed) == 0) {
+ if (bootverbose)
+ printf("Ignoring known bogus MBR #1\n");
break;
+ }
npart = 0;
for (i = 0; i < NDOSPART; i++) {
if (dp[i].dp_flag != 0 && dp[i].dp_flag != 0x80)
OpenPOWER on IntegriCloud