summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/disk.c5
-rw-r--r--sbin/fdisk/disk.h4
-rw-r--r--sbin/fdisk/mbr.c15
3 files changed, 20 insertions, 4 deletions
diff --git a/sbin/fdisk/disk.c b/sbin/fdisk/disk.c
index 8fe7ce2596a..a77ba5ae6dc 100644
--- a/sbin/fdisk/disk.c
+++ b/sbin/fdisk/disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.c,v 1.30 2010/05/18 04:41:14 dlg Exp $ */
+/* $OpenBSD: disk.c,v 1.31 2010/06/30 22:53:41 krw Exp $ */
/*
* Copyright (c) 1997, 2001 Tobias Weingartner
@@ -40,6 +40,8 @@
#include "disk.h"
#include "misc.h"
+struct disklabel dl;
+
DISK_metrics *DISK_getlabelmetrics(char *name);
int
@@ -67,7 +69,6 @@ DISK_metrics *
DISK_getlabelmetrics(char *name)
{
DISK_metrics *lm = NULL;
- struct disklabel dl;
int fd;
/* Get label metrics */
diff --git a/sbin/fdisk/disk.h b/sbin/fdisk/disk.h
index 1be075d49a9..0ffd479c6b0 100644
--- a/sbin/fdisk/disk.h
+++ b/sbin/fdisk/disk.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.h,v 1.10 2009/02/08 18:03:18 krw Exp $ */
+/* $OpenBSD: disk.h,v 1.11 2010/06/30 22:53:41 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -47,4 +47,6 @@ int DISK_open(char *, int);
int DISK_getmetrics(disk_t *, DISK_metrics *);
int DISK_printmetrics(disk_t *, char *);
+extern struct disklabel dl;
+
#endif /* _DISK_H */
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