summaryrefslogtreecommitdiffstats
path: root/sbin/disklabel/editor.c
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2009-05-13 01:31:58 +0000
committerkrw <krw@openbsd.org>2009-05-13 01:31:58 +0000
commit6ab0bb66ea3340da5deebd6f15931db6f09bb9eb (patch)
treebc8501beb1d68dfee6ca62e95213e321cc2a9031 /sbin/disklabel/editor.c
parentinitialize d_npartitions to MAXPARTITIONS always; ok krw (diff)
downloadwireguard-openbsd-6ab0bb66ea3340da5deebd6f15931db6f09bb9eb.tar.xz
wireguard-openbsd-6ab0bb66ea3340da5deebd6f15931db6f09bb9eb.zip
Set D_VENDOR when spoofing a label on archs that use D_VENDOR when
reading the native disklabel. This ensures cylinder alignment. Fix disklabel to do cylinder alignment arithmetic correctly in -A mode. Worked by accident before, since the code was protected by D_VENDOR, which wasn't being set. ok deraadt@
Diffstat (limited to 'sbin/disklabel/editor.c')
-rw-r--r--sbin/disklabel/editor.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index c6383404481..6039a04d8aa 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.207 2009/05/12 00:54:48 krw Exp $ */
+/* $OpenBSD: editor.c,v 1.208 2009/05/13 01:31:58 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.207 2009/05/12 00:54:48 krw Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.208 2009/05/13 01:31:58 krw Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -610,9 +610,9 @@ cylinderalign:
#ifdef SUN_CYLCHECK
if (lp->d_flags & D_VENDOR) {
/* Align chunk to cylinder boundaries. */
- chunksize -= cylsecs - chunkstart % cylsecs;
chunksize -= chunksize % cylsecs;
- chunkstart += cylsecs - chunkstart % cylsecs;
+ chunkstart = ((chunkstart + cylsecs - 1) / cylsecs) *
+ cylsecs;
}
#endif
/* See if partition can fit into chunk. */