summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2012-04-04 13:14:45 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2012-04-04 13:14:45 +0000
commit6314cd2d3aa0755f8e027c616b4560af9dbe23e7 (patch)
tree1b4dd61283fba1dd90925276f0047ea7f8d1c4c1 /sbin
parentb12409c45ef216d6b2af5de01c365b59c155a40d (diff)
Don't 'reserve' a head/track if there is only only 1 head and 1
cylinder. If there is only one head but multiple cylinders reserve one cylinder. Prevents nonsense MBR being created on scsi attached floppies, which have a 'geometry' of 1/1/2888. No change to less pathological cases.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/mbr.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c
index b8f05bdded4..b02e53aae28 100644
--- a/sbin/fdisk/mbr.c
+++ b/sbin/fdisk/mbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbr.c,v 1.27 2011/06/20 19:10:41 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.28 2012/04/04 13:14:44 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -59,10 +59,16 @@ MBR_init(disk_t *disk, mbr_t *mbr)
mbr->part[3].flag = DOSACTIVE;
mbr->signature = DOSMBR_SIGNATURE;
- /* Use whole disk, save for first head, on first cyl. */
+ /* Use whole disk. Reserve first track, or first cyl, if possible. */
mbr->part[3].id = DOSPTYP_OPENBSD;
- mbr->part[3].scyl = 0;
- mbr->part[3].shead = 1;
+ if (disk->real->heads > 1)
+ mbr->part[3].shead = 1;
+ else
+ mbr->part[3].shead = 0;
+ if (disk->real->heads < 2 && disk->real->cylinders > 1)
+ mbr->part[3].scyl = 1;
+ else
+ mbr->part[3].scyl = 0;
mbr->part[3].ssect = 1;
/* Go right to the end */