summaryrefslogtreecommitdiff
path: root/sbin/fdisk/mbr.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2010-06-30 22:53:42 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2010-06-30 22:53:42 +0000
commit0d02b8e4c98c741e7a0efca280db1e59259e2bca (patch)
treef3f7bdd11195bc6ff80257f381f9cfc0f4b7c12c /sbin/fdisk/mbr.c
parent8c106c54d8ea352c3a5cde7ab58fdb7eb7231a4a (diff)
Make 'fdisk -i' start the OpenBSD partition on a power of 2 512-byte
block boundary. In most modern (i.e. 'faked' geometry) situations this will start it at (0-based) block[64] rather than block[63] as now. This should help performance on disks which really have 4K sectors but report 512-byte sectors. Power of 2 idea from deraadt@. ok toby@ deraadt@
Diffstat (limited to 'sbin/fdisk/mbr.c')
-rw-r--r--sbin/fdisk/mbr.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c
index 5fa12606c8e..df93b3aace2 100644
--- a/sbin/fdisk/mbr.c
+++ b/sbin/fdisk/mbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbr.c,v 1.24 2009/02/08 18:03:18 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.25 2010/06/30 22:53:41 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -48,6 +48,9 @@
void
MBR_init(disk_t *disk, mbr_t *mbr)
{
+ daddr64_t i;
+ int adj;
+
/* Fix up given mbr for this disk */
mbr->part[0].flag = 0;
mbr->part[1].flag = 0;
@@ -87,6 +90,16 @@ MBR_init(disk_t *disk, mbr_t *mbr)
/* Fix up start/length fields */
PRT_fix_BN(disk, &mbr->part[3], 3);
#endif
+
+ /* Start OpenBSD MBR partition on a power of 2 block number. */
+ i = 1;
+ while (i < DL_SECTOBLK(&dl, mbr->part[3].bs))
+ i *= 2;
+ i = DL_BLKTOSEC(&dl, i);
+ adj = i - mbr->part[3].bs;
+ mbr->part[3].bs += adj;
+ mbr->part[3].ns -= adj;
+ PRT_fix_CHS(disk, &mbr->part[3]);
}
void