summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2013-09-03 17:48:26 +0000
committerkrw <krw@openbsd.org>2013-09-03 17:48:26 +0000
commite16000446d7bb9f8fb41ff3c46a5e87301b71925 (patch)
tree838f866cea6c00d290ca4ea757f43e75eaa76632
parentRewrite the ARMv7 cache discovery, as some assumptions in the previous one (diff)
downloadwireguard-openbsd-e16000446d7bb9f8fb41ff3c46a5e87301b71925.tar.xz
wireguard-openbsd-e16000446d7bb9f8fb41ff3c46a5e87301b71925.zip
When a partition is changing to UNUSED, we try to save kernel-set
values for the p_fragblock and p_cpg fields. But we were saving the info for open partitions only. Instead, look at all partitions. And stop discarding the new partition type. In addition to general betterness, this lets you change the RAW_PART partition (a.k.a. 'c') to UNUSED. This problem was pointed out by Federico Giannici via misc@. ok otto@
-rw-r--r--sys/kern/subr_disk.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index c132d2aeba9..f936e378eda 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.151 2013/08/08 23:25:06 syl Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.152 2013/09/03 17:48:26 krw Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -645,22 +645,17 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_int openmask)
/* 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);
+ for (i = 0; i < MAXPARTITIONS; i++) {
opp = &olp->d_partitions[i];
npp = &nlp->d_partitions[i];
- if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) ||
- DL_GETPSIZE(npp) < DL_GETPSIZE(opp))
+ if ((openmask & (1 << i)) && (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;
}