summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-05-04 19:27:22 +0000
committerphk <phk@FreeBSD.org>2003-05-04 19:27:22 +0000
commit1067d41da342f5c7aa50d0571c090c1acf696c90 (patch)
tree2431745ae964ff1c79ba6ebea08890cae1190fb5
parentaac4aea7595824f27df3054cc2c11e5c5fb1cc6e (diff)
downloadFreeBSD-src-1067d41da342f5c7aa50d0571c090c1acf696c90.zip
FreeBSD-src-1067d41da342f5c7aa50d0571c090c1acf696c90.tar.gz
Add transparent handling of mbroffset for backwards compatibility.
-rw-r--r--sbin/bsdlabel/bsdlabel.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index fd20814..4c77a35 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -125,6 +125,7 @@ static int installboot; /* non-zero if we should install a boot program */
static int allfields; /* present all fields in edit */
static char const *xxboot; /* primary boot */
+static off_t mbroffset;
static int labeloffset = LABELOFFSET + LABELSECTOR * DEV_BSIZE;
static int bbsize = BBSIZE;
static int alphacksum =
@@ -343,6 +344,9 @@ writelabel(void)
lp->d_checksum = dkcksum(lp);
if (installboot)
readboot();
+ for (i = 0; i < lab.d_npartitions; i++)
+ if (lab.d_partitions[i].p_size)
+ lab.d_partitions[i].p_offset += mbroffset;
bsd_disklabel_le_enc(bootarea + labeloffset, lp);
if (alphacksum) {
/* Generate the bootblock checksum for the SRM console. */
@@ -397,8 +401,10 @@ writelabel(void)
static int
readlabel(int flag)
{
- int f;
+ int f, i;
int error;
+ struct gctl_req *grq;
+ char const *errstr;
f = open(specname, O_RDONLY);
if (f < 0)
@@ -410,6 +416,24 @@ readlabel(int flag)
error = bsd_disklabel_le_dec(bootarea + labeloffset, &lab, MAXPARTITIONS);
if (flag && error)
errx(1, "%s: no valid label found", specname);
+
+ grq = gctl_get_handle(GCTL_CONFIG_GEOM);
+ gctl_ro_param(grq, "class", -1, "BSD");
+ gctl_ro_param(grq, "geom", -1, dkname);
+ gctl_ro_param(grq, "verb", -1, "read mbroffset");
+ gctl_rw_param(grq, "mbroffset", sizeof(mbroffset), &mbroffset);
+ errstr = gctl_issue(grq);
+ if (errstr != NULL) {
+ warnx("%s", errstr);
+ mbroffset = 0;
+ gctl_free(grq);
+ return (error);
+ }
+ mbroffset /= lab.d_secsize;
+ if (lab.d_partitions[RAW_PART].p_offset == mbroffset)
+ for (i = 0; i < lab.d_npartitions; i++)
+ if (lab.d_partitions[i].p_size)
+ lab.d_partitions[i].p_offset -= mbroffset;
return (error);
}
OpenPOWER on IntegriCloud