summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/alpha/alpha/disksubr.c62
-rw-r--r--sys/arch/amd64/amd64/disksubr.c55
-rw-r--r--sys/arch/arm/arm/disksubr.c55
-rw-r--r--sys/arch/aviion/aviion/disksubr.c55
-rw-r--r--sys/arch/hp300/hp300/disksubr.c41
-rw-r--r--sys/arch/hppa/hppa/disksubr.c62
-rw-r--r--sys/arch/hppa64/hppa64/disksubr.c62
-rw-r--r--sys/arch/i386/i386/disksubr.c55
-rw-r--r--sys/arch/landisk/landisk/disksubr.c55
-rw-r--r--sys/arch/luna88k/luna88k/disksubr.c45
-rw-r--r--sys/arch/mac68k/mac68k/disksubr.c53
-rw-r--r--sys/arch/macppc/macppc/disksubr.c55
-rw-r--r--sys/arch/mips64/mips64/disksubr.c62
-rw-r--r--sys/arch/mvme68k/mvme68k/disksubr.c54
-rw-r--r--sys/arch/mvme88k/mvme88k/disksubr.c54
-rw-r--r--sys/arch/mvmeppc/mvmeppc/disksubr.c55
-rw-r--r--sys/arch/sparc/sparc/disksubr.c43
-rw-r--r--sys/arch/sparc64/sparc64/disksubr.c43
-rw-r--r--sys/arch/vax/vax/disksubr.c53
-rw-r--r--sys/kern/subr_disk.c56
20 files changed, 74 insertions, 1001 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c
index aa34550de7c..13e1bf7124b 100644
--- a/sys/arch/alpha/alpha/disksubr.c
+++ b/sys/arch/alpha/alpha/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.78 2007/06/09 02:03:45 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.79 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -386,66 +386,6 @@ notfat:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
- (nlp->d_secsize % DEV_BSIZE) != 0)
- return (EINVAL);
-
- /*
- * XXX Nice thought, but it doesn't work, if the intention was to
- * force a reread at the next *readdisklabel call. That does not
- * happen. There's still some use for it though as you can pseudo-
- * partition the disk.
- *
- * Special case to allow disklabel to be invalidated.
- */
- if (nlp->d_magic == 0xffffffff) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c
index 087530280ff..a7fe2f31e56 100644
--- a/sys/arch/amd64/amd64/disksubr.c
+++ b/sys/arch/amd64/amd64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.42 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.43 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -321,59 +321,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c
index 06047aec7dd..74a16f48ebe 100644
--- a/sys/arch/arm/arm/disksubr.c
+++ b/sys/arch/arm/arm/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.37 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.38 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -293,59 +293,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c
index 2f865a8684b..c468316b364 100644
--- a/sys/arch/aviion/aviion/disksubr.c
+++ b/sys/arch/aviion/aviion/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.28 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.29 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -293,59 +293,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c
index 3c5d10ed6d0..7f08b6e4252 100644
--- a/sys/arch/hp300/hp300/disksubr.c
+++ b/sys/arch/hp300/hp300/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.34 2007/06/08 05:34:27 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.35 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */
/*
@@ -127,45 +127,6 @@ done:
}
/*
- * Check new disk label for sensibility before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
- while ((i = ffs(openmask)) != 0) {
- i--;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
-
-/*
* Write disk label back to device after modification.
*/
int
diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c
index f4263f33cfa..3073277ff42 100644
--- a/sys/arch/hppa/hppa/disksubr.c
+++ b/sys/arch/hppa/hppa/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.59 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.60 2007/06/09 04:08:39 deraadt Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -542,66 +542,6 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *),
LABELOFFSET, lp, spoofonly);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
- (nlp->d_secsize % DEV_BSIZE) != 0)
- return (EINVAL);
-
- /*
- * XXX Nice thought, but it doesn't work, if the intention was to
- * force a reread at the next *readdisklabel call. That does not
- * happen. There's still some use for it though as you can pseudo-
- * partition the disk.
- *
- * Special case to allow disklabel to be invalidated.
- */
- if (nlp->d_magic == 0xffffffff) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c
index d9b8ca24803..cb36e7fb80b 100644
--- a/sys/arch/hppa64/hppa64/disksubr.c
+++ b/sys/arch/hppa64/hppa64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.42 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.43 2007/06/09 04:08:39 deraadt Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -542,66 +542,6 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *),
LABELOFFSET, lp, spoofonly);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
- (nlp->d_secsize % DEV_BSIZE) != 0)
- return (EINVAL);
-
- /*
- * XXX Nice thought, but it doesn't work, if the intention was to
- * force a reread at the next *readdisklabel call. That does not
- * happen. There's still some use for it though as you can pseudo-
- * partition the disk.
- *
- * Special case to allow disklabel to be invalidated.
- */
- if (nlp->d_magic == 0xffffffff) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c
index 6aea778b4b9..5b39b485aec 100644
--- a/sys/arch/i386/i386/disksubr.c
+++ b/sys/arch/i386/i386/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.82 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.83 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -321,59 +321,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c
index 2a58f130ecc..6706dd12e00 100644
--- a/sys/arch/landisk/landisk/disksubr.c
+++ b/sys/arch/landisk/landisk/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.25 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.26 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -293,59 +293,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c
index 144781be7c8..ee14e7cea9d 100644
--- a/sys/arch/luna88k/luna88k/disksubr.c
+++ b/sys/arch/luna88k/luna88k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.22 2007/06/08 12:45:05 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.23 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */
/*
@@ -210,49 +210,6 @@ done:
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *clp)
-{
- struct partition *opp, *npp;
- int i;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC ||
- nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- return (EBUSY);
- }
-
- /* We did not modify the new label, so the checksum is OK. */
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c
index 64383e3e82d..567f8456fe0 100644
--- a/sys/arch/mac68k/mac68k/disksubr.c
+++ b/sys/arch/mac68k/mac68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.42 2007/06/08 05:34:28 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.43 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */
/*
@@ -429,57 +429,6 @@ done:
}
/*
- * Check new disk label for sensibility before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- while ((i = ffs(openmask)) != 0) {
- i--;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
-
-/*
* Write disk label back to device after modification.
*
* To avoid spreading havoc into the MacOS partition structures, we will
diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c
index 2afc4b61f3b..9532a75e1c2 100644
--- a/sys/arch/macppc/macppc/disksubr.c
+++ b/sys/arch/macppc/macppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.47 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.48 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -384,59 +384,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c
index 53b8039a8ec..fb8330d4b36 100644
--- a/sys/arch/mips64/mips64/disksubr.c
+++ b/sys/arch/mips64/mips64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.49 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.50 2007/06/09 04:08:39 deraadt Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -500,66 +500,6 @@ static struct {int m; int b;} maptab[] = {
}
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
- (nlp->d_secsize % DEV_BSIZE) != 0)
- return (EINVAL);
-
- /*
- * XXX Nice thought, but it doesn't work, if the intention was to
- * force a reread at the next *readdisklabel call. That does not
- * happen. There's still some use for it though as you can pseudo-
- * partition the disk.
- *
- * Special case to allow disklabel to be invalidated.
- */
- if (nlp->d_magic == 0xffffffff) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c
index fa2175fc62c..58274fea06c 100644
--- a/sys/arch/mvme68k/mvme68k/disksubr.c
+++ b/sys/arch/mvme68k/mvme68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.50 2007/06/09 00:39:25 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.51 2007/06/09 04:08:39 deraadt Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1995 Dale Rahn.
@@ -130,58 +130,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *clp)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- while ((i = ffs(openmask)) != 0) {
- i--;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
-
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
* Write disk label back to device after modification.
diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c
index 34cf8b2bb92..4ed75b1349f 100644
--- a/sys/arch/mvme88k/mvme88k/disksubr.c
+++ b/sys/arch/mvme88k/mvme88k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.46 2007/06/09 00:39:25 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.47 2007/06/09 04:08:39 deraadt Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1995 Dale Rahn.
@@ -130,58 +130,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *clp)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- while ((i = ffs(openmask)) != 0) {
- i--;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
-
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
* Write disk label back to device after modification.
diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c
index ad572f06979..02082d25c2c 100644
--- a/sys/arch/mvmeppc/mvmeppc/disksubr.c
+++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.43 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.44 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -296,59 +296,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c
index 46ad9066639..ab763eb2862 100644
--- a/sys/arch/sparc/sparc/disksubr.c
+++ b/sys/arch/sparc/sparc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.55 2007/06/08 04:59:06 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.56 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */
/*
@@ -182,47 +182,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *clp)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- while ((i = ffs(openmask)) != 0) {
- i--;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- return (EBUSY);
- }
-
- *olp = *nlp;
- return (0);
-}
/*
* Write disk label back to device after modification.
diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c
index 76c31ba6779..91c5c0be0c6 100644
--- a/sys/arch/sparc64/sparc64/disksubr.c
+++ b/sys/arch/sparc64/sparc64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.35 2007/06/09 02:03:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.36 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */
/*
@@ -181,47 +181,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *clp)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- while ((i = ffs(openmask)) != 0) {
- i--;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- return (EBUSY);
- }
-
- *olp = *nlp;
- return (0);
-}
/*
* Write disk label back to device after modification.
diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c
index 3f1c554baf1..6db98f3c998 100644
--- a/sys/arch/vax/vax/disksubr.c
+++ b/sys/arch/vax/vax/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.45 2007/06/08 05:34:28 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.46 2007/06/09 04:08:39 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */
/*
@@ -186,57 +186,6 @@ done:
return (msg);
}
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_int openmask, struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- 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) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- while ((i = ffs(openmask)) != 0) {
- i--;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
- 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_fragblock = opp->p_fragblock;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
/*
* Write disk label back to device after modification.
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index ce110c854f7..ca40dcd8e7d 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.53 2007/06/09 03:56:48 deraadt Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.54 2007/06/09 04:08:37 deraadt Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -237,6 +237,60 @@ disklabeltokernlabel(struct disklabel *lp)
}
/*
+ * Check new disk label for sensibility
+ * before setting it.
+ */
+int
+setdisklabel(struct disklabel *olp, struct disklabel *nlp,
+ u_int openmask, struct cpu_disklabel *osdep)
+{
+ int i;
+ struct partition *opp, *npp;
+
+ /* sanity clause */
+ 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) {
+ *olp = *nlp;
+ return (0);
+ }
+
+ if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
+ dkcksum(nlp) != 0)
+ return (EINVAL);
+
+ /* XXX missing check if other dos partitions will be overwritten */
+
+ while (openmask != 0) {
+ i = ffs(openmask) - 1;
+ openmask &= ~(1 << i);
+ if (nlp->d_npartitions <= i)
+ return (EBUSY);
+ opp = &olp->d_partitions[i];
+ npp = &nlp->d_partitions[i];
+ if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
+ DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
+ 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_fragblock = opp->p_fragblock;
+ npp->p_cpg = opp->p_cpg;
+ }
+ }
+ nlp->d_checksum = 0;
+ nlp->d_checksum = dkcksum(nlp);
+ *olp = *nlp;
+ return (0);
+}
+
+/*
* Disk error is the preface to plaintive error messages
* about failing disk transfers. It prints messages of the form