summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-19 13:52:19 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-19 13:52:19 +0000
commit6d35ff13cc29eb9cd292017efbb59f61a9c615b1 (patch)
tree8bcabed87ef7c4b30fc7158b78232cec3cb6ed3c /sys/arch
parent9a05fdd4b794876325d6a3b47fc6a0d3b4545633 (diff)
from netbsd; Give translated label a valid magic number
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sun3/sun3/disksubr.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/sys/arch/sun3/sun3/disksubr.c b/sys/arch/sun3/sun3/disksubr.c
index 779d1569831..f16a50520ca 100644
--- a/sys/arch/sun3/sun3/disksubr.c
+++ b/sys/arch/sun3/sun3/disksubr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: disksubr.c,v 1.9.2.1 1995/10/30 23:36:34 gwr Exp $ */
+/* $NetBSD: disksubr.c,v 1.9.2.2 1995/11/18 06:58:03 gwr Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@@ -151,9 +151,9 @@ setdisklabel(olp, nlp, openmask, clp)
int i;
/* sanity clause */
- if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0
- || (nlp->d_secsize % DEV_BSIZE) != 0)
- return(EINVAL);
+ if ((nlp->d_secpercyl == 0) || (nlp->d_secsize == 0) ||
+ (nlp->d_secsize % DEV_BSIZE) != 0)
+ return(EINVAL);
/* special case to allow disklabel to be invalidated */
if (nlp->d_magic == 0xffffffff) {
@@ -161,7 +161,8 @@ setdisklabel(olp, nlp, openmask, clp)
return (0);
}
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
+ if (nlp->d_magic != DISKMAGIC ||
+ nlp->d_magic2 != DISKMAGIC ||
dkcksum(nlp) != 0)
return (EINVAL);
@@ -172,21 +173,12 @@ setdisklabel(olp, nlp, openmask, clp)
return (EBUSY);
opp = &olp->d_partitions[i];
npp = &nlp->d_partitions[i];
- if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
+ if (npp->p_offset != opp->p_offset ||
+ npp->p_size < opp->p_size)
return (EBUSY);
- /*
- * Copy internally-set partition information
- * if new label doesn't include it. XXX
- */
- if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
- npp->p_fstype = opp->p_fstype;
- npp->p_fsize = opp->p_fsize;
- npp->p_frag = opp->p_frag;
- npp->p_cpg = opp->p_cpg;
- }
}
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
+
+ /* We did not modify the new label, so the checksum is OK. */
*olp = *nlp;
return (0);
}
@@ -338,7 +330,8 @@ disklabel_sun_to_bsd(cp, lp)
return("SunOS disk label, bad checksum");
/* Format conversion. */
- lp->d_magic = 0; /* denote as pseudo */
+ lp->d_magic = DISKMAGIC;
+ lp->d_magic2 = DISKMAGIC;
memcpy(lp->d_packname, sl->sl_text, sizeof(lp->d_packname));
lp->d_secsize = 512;
@@ -365,10 +358,29 @@ disklabel_sun_to_bsd(cp, lp)
npp = &lp->d_partitions[i];
npp->p_offset = spp->sdkp_cyloffset * secpercyl;
npp->p_size = spp->sdkp_nsectors;
- if (npp->p_size)
+ if (npp->p_size == 0)
+ npp->p_fstype = FS_UNUSED;
+ else {
+ /* Partition has non-zero size. Set type, etc. */
npp->p_fstype = sun_fstypes[i];
+ /*
+ * The sun label does not store the FFS fields,
+ * so just set them with default values here.
+ * XXX: This keeps newfs from trying to rewrite
+ * XXX: the disk label in the most common case.
+ * XXX: (Should remove that code from newfs...)
+ */
+ if (npp->p_fstype == FS_BSDFFS) {
+ npp->p_fsize = 1024;
+ npp->p_frag = 8;
+ npp->p_cpg = 16;
+ }
+ }
}
+ lp->d_checksum = 0;
+ lp->d_checksum = dkcksum(lp);
+
return(NULL);
}
@@ -389,6 +401,9 @@ disklabel_bsd_to_sun(lp, cp)
int i, secpercyl;
u_short cksum, *sp1, *sp2;
+ if (lp->d_secsize != 512)
+ return (EINVAL);
+
sl = (struct sun_disklabel *)cp;
/* Format conversion. */