summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-06-08 04:59:08 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-06-08 04:59:08 +0000
commit41663440599d592f777310ed8c11e89fb470a2aa (patch)
tree00eab43ffec09bd3cb2d993496acea54fd1c3e3e /sys/arch
parent9600b0212141318444461afbb4dddeed07cd07d3 (diff)
- always set the partition disk size to full disk info (from driver)
- always store our new fatty 16-partitions-with-full-cpg-info style sun disklabels on the disk. - correct an error in matching old-style 16-partition matching code; the checksum spanned a different region tested by me, groked by krw, which is a lot more than the rest of the post-hackathon exhausted slackers
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc/sparc/disksubr.c70
-rw-r--r--sys/arch/sparc64/sparc64/disksubr.c70
2 files changed, 60 insertions, 80 deletions
diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c
index 9ab424c2cfc..46ad9066639 100644
--- a/sys/arch/sparc/sparc/disksubr.c
+++ b/sys/arch/sparc/sparc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.54 2007/06/07 03:41:52 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.55 2007/06/08 04:59:06 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */
/*
@@ -48,7 +48,7 @@
static char *disklabel_sun_to_bsd(char *, struct disklabel *);
static int disklabel_bsd_to_sun(struct disklabel *, char *);
-static __inline u_int sun_extended_sum(struct sun_disklabel *);
+static __inline u_int sun_extended_sum(struct sun_disklabel *, void *);
#if NCD > 0
extern void cdstrategy(struct buf *);
@@ -152,6 +152,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *),
msg = "disk label corrupted";
goto done;
}
+ DL_SETDSIZE(dlp, DL_GETDSIZE(lp));
*lp = *dlp; /* struct assignment */
msg = NULL;
goto done;
@@ -352,12 +353,12 @@ sun_fstypes[16] = {
* table and compute the correct value for sl_xpsum.
*/
static __inline u_int
-sun_extended_sum(struct sun_disklabel *sl)
+sun_extended_sum(struct sun_disklabel *sl, void *end)
{
u_int sum, *xp, *ep;
xp = (u_int *)&sl->sl_xpmag;
- ep = (u_int *)&sl->sl_xxx1[0];
+ ep = (u_int *)end;
sum = 0;
for (; xp < ep; xp++)
@@ -446,9 +447,15 @@ disklabel_sun_to_bsd(char *cp, struct disklabel *lp)
npp->p_fstype = FS_UNUSED;
}
- /* Check to see if there's an "extended" partition table */
- if ((sl->sl_xpmag == SL_XPMAG || sl->sl_xpmag == SL_XPMAGTYP) &&
- sun_extended_sum(sl) == sl->sl_xpsum) { /* ...yes! */
+ /* Check to see if there's an "extended" partition table
+ * SL_XPMAG partitions had checksums up to just before the
+ * (new) sl_types variable, while SL_XPMAGTYP partitions have
+ * checksums up to the just before the (new) sl_xxx1 variable.
+ */
+ if ((sl->sl_xpmag == SL_XPMAG &&
+ sun_extended_sum(sl, &sl->sl_types) == sl->sl_xpsum) ||
+ (sl->sl_xpmag == SL_XPMAGTYP &&
+ sun_extended_sum(sl, &sl->sl_xxx1) == sl->sl_xpsum)) {
/*
* There is. Copy over the "extended" partitions.
* This code parallels the loop for partitions a-h.
@@ -527,45 +534,28 @@ disklabel_bsd_to_sun(struct disklabel *lp, char *cp)
}
sl->sl_magic = SUN_DKMAGIC;
- /*
- * The reason we store the extended table stuff only conditionally
- * is so that a label that doesn't need it will have NULs there, like
- * a "traditional" Sun label. Since Suns seem to ignore everything
- * between sl_text and sl_rpm, this probably doesn't matter, but it
- * certainly doesn't hurt anything and it's easy to do.
- */
for (i = 0; i < SUNXPART; i++) {
if (DL_GETPOFFSET(&lp->d_partitions[i+8]) ||
DL_GETPSIZE(&lp->d_partitions[i+8]))
break;
}
- /* We do need to load the extended table? */
- if (i < SUNXPART) {
- sl->sl_xpmag = SL_XPMAGTYP;
- for (i = 0; i < SUNXPART; i++) {
- spp = &sl->sl_xpart[i];
- npp = &lp->d_partitions[i+8];
- if (DL_GETPOFFSET(npp) % secpercyl)
- return (EINVAL);
- sl->sl_xpart[i].sdkp_cyloffset =
- DL_GETPOFFSET(npp) / secpercyl;
- sl->sl_xpart[i].sdkp_nsectors = DL_GETPSIZE(npp);
- }
- for (i = 0; i < MAXPARTITIONS; i++) {
- npp = &lp->d_partitions[i];
- sl->sl_types[i] = npp->p_fstype;
- sl->sl_fragblock[i] = npp->p_fragblock;
- sl->sl_cpg[i] = npp->p_cpg;
- }
- sl->sl_xpsum = sun_extended_sum(sl);
- } else {
- sl->sl_xpmag = 0;
- for (i = 0; i < SUNXPART; i++) {
- sl->sl_xpart[i].sdkp_cyloffset = 0;
- sl->sl_xpart[i].sdkp_nsectors = 0;
- }
- sl->sl_xpsum = 0;
+ for (i = 0; i < SUNXPART; i++) {
+ spp = &sl->sl_xpart[i];
+ npp = &lp->d_partitions[i+8];
+ if (DL_GETPOFFSET(npp) % secpercyl)
+ return (EINVAL);
+ sl->sl_xpart[i].sdkp_cyloffset =
+ DL_GETPOFFSET(npp) / secpercyl;
+ sl->sl_xpart[i].sdkp_nsectors = DL_GETPSIZE(npp);
+ }
+ for (i = 0; i < MAXPARTITIONS; i++) {
+ npp = &lp->d_partitions[i];
+ sl->sl_types[i] = npp->p_fstype;
+ sl->sl_fragblock[i] = npp->p_fragblock;
+ sl->sl_cpg[i] = npp->p_cpg;
}
+ sl->sl_xpmag = SL_XPMAGTYP;
+ sl->sl_xpsum = sun_extended_sum(sl, &sl->sl_xxx1);
/* Correct the XOR check. */
sp1 = (u_short *)sl;
diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c
index 3f7fae515ae..f46e08db0bb 100644
--- a/sys/arch/sparc64/sparc64/disksubr.c
+++ b/sys/arch/sparc64/sparc64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.33 2007/06/07 03:41:52 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.34 2007/06/08 04:59:07 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */
/*
@@ -47,7 +47,7 @@
static char *disklabel_sun_to_bsd(char *, struct disklabel *);
static int disklabel_bsd_to_sun(struct disklabel *, char *);
-static __inline u_int sun_extended_sum(struct sun_disklabel *);
+static __inline u_int sun_extended_sum(struct sun_disklabel *, void *);
#if NCD > 0
extern void cdstrategy(struct buf *);
@@ -151,6 +151,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *),
msg = "disk label corrupted";
goto done;
}
+ DL_SETDSIZE(dlp, DL_GETDSIZE(lp));
*lp = *dlp; /* struct assignment */
msg = NULL;
goto done;
@@ -351,12 +352,12 @@ sun_fstypes[16] = {
* table and compute the correct value for sl_xpsum.
*/
static __inline u_int
-sun_extended_sum(struct sun_disklabel *sl)
+sun_extended_sum(struct sun_disklabel *sl, void *end)
{
u_int sum, *xp, *ep;
xp = (u_int *)&sl->sl_xpmag;
- ep = (u_int *)&sl->sl_xxx1[0];
+ ep = (u_int *)end;
sum = 0;
for (; xp < ep; xp++)
@@ -445,9 +446,15 @@ disklabel_sun_to_bsd(char *cp, struct disklabel *lp)
npp->p_fstype = FS_UNUSED;
}
- /* Check to see if there's an "extended" partition table */
- if ((sl->sl_xpmag == SL_XPMAG || sl->sl_xpmag == SL_XPMAGTYP) &&
- sun_extended_sum(sl) == sl->sl_xpsum) { /* ...yes! */
+ /* Check to see if there's an "extended" partition table
+ * SL_XPMAG partitions had checksums up to just before the
+ * (new) sl_types variable, while SL_XPMAGTYP partitions have
+ * checksums up to the just before the (new) sl_xxx1 variable.
+ */
+ if ((sl->sl_xpmag == SL_XPMAG &&
+ sun_extended_sum(sl, &sl->sl_types) == sl->sl_xpsum) ||
+ (sl->sl_xpmag == SL_XPMAGTYP &&
+ sun_extended_sum(sl, &sl->sl_xxx1) == sl->sl_xpsum)) {
/*
* There is. Copy over the "extended" partitions.
* This code parallels the loop for partitions a-h.
@@ -526,45 +533,28 @@ disklabel_bsd_to_sun(struct disklabel *lp, char *cp)
}
sl->sl_magic = SUN_DKMAGIC;
- /*
- * The reason we store the extended table stuff only conditionally
- * is so that a label that doesn't need it will have NULs there, like
- * a "traditional" Sun label. Since Suns seem to ignore everything
- * between sl_text and sl_rpm, this probably doesn't matter, but it
- * certainly doesn't hurt anything and it's easy to do.
- */
for (i = 0; i < SUNXPART; i++) {
if (DL_GETPOFFSET(&lp->d_partitions[i+8]) ||
DL_GETPSIZE(&lp->d_partitions[i+8]))
break;
}
- /* We do need to load the extended table? */
- if (i < SUNXPART) {
- sl->sl_xpmag = SL_XPMAGTYP;
- for (i = 0; i < SUNXPART; i++) {
- spp = &sl->sl_xpart[i];
- npp = &lp->d_partitions[i+8];
- if (DL_GETPOFFSET(npp) % secpercyl)
- return (EINVAL);
- sl->sl_xpart[i].sdkp_cyloffset =
- DL_GETPOFFSET(npp) / secpercyl;
- sl->sl_xpart[i].sdkp_nsectors = DL_GETPSIZE(npp);
- }
- for (i = 0; i < MAXPARTITIONS; i++) {
- npp = &lp->d_partitions[i];
- sl->sl_types[i] = npp->p_fstype;
- sl->sl_fragblock[i] = npp->p_fragblock;
- sl->sl_cpg[i] = npp->p_cpg;
- }
- sl->sl_xpsum = sun_extended_sum(sl);
- } else {
- sl->sl_xpmag = 0;
- for (i = 0; i < SUNXPART; i++) {
- sl->sl_xpart[i].sdkp_cyloffset = 0;
- sl->sl_xpart[i].sdkp_nsectors = 0;
- }
- sl->sl_xpsum = 0;
+ for (i = 0; i < SUNXPART; i++) {
+ spp = &sl->sl_xpart[i];
+ npp = &lp->d_partitions[i+8];
+ if (DL_GETPOFFSET(npp) % secpercyl)
+ return (EINVAL);
+ sl->sl_xpart[i].sdkp_cyloffset =
+ DL_GETPOFFSET(npp) / secpercyl;
+ sl->sl_xpart[i].sdkp_nsectors = DL_GETPSIZE(npp);
+ }
+ for (i = 0; i < MAXPARTITIONS; i++) {
+ npp = &lp->d_partitions[i];
+ sl->sl_types[i] = npp->p_fstype;
+ sl->sl_fragblock[i] = npp->p_fragblock;
+ sl->sl_cpg[i] = npp->p_cpg;
}
+ sl->sl_xpmag = SL_XPMAGTYP;
+ sl->sl_xpsum = sun_extended_sum(sl, &sl->sl_xxx1);
/* Correct the XOR check. */
sp1 = (u_short *)sl;