1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

Add more compatibility junk.

This commit is contained in:
Poul-Henning Kamp 2002-10-28 07:50:47 +00:00
parent 72465621ff
commit 8c847e9020
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106076
2 changed files with 34 additions and 11 deletions

View File

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

View File

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