summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2012-04-25 04:21:46 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2012-04-25 04:21:46 +0000
commit2c9ade7b3750024b6b1be43a7ee63437a77fd697 (patch)
tree6fd9d3a90c5308066eedde2e17cb50f326170265 /sbin
parent777da97698e271a6d50d6e1bf950e7f169f16270 (diff)
Before writing it to disk, warn the user if their new MBR contains
more than one OpenBSD partition. ok deraadt
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/cmd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index d7cf3498cd9..91fd9113ac8 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.46 2011/11/11 18:21:06 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.47 2012/04/25 04:21:45 matthew Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -328,7 +328,16 @@ int
Xwrite(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset)
{
char mbr_buf[DEV_BSIZE];
- int fd;
+ int fd, i, n;
+
+ for (i = 0, n = 0; i < NDOSPART; i++)
+ if (mbr->part[i].id == 0xA6)
+ n++;
+ if (n >= 2) {
+ warnx("MBR contains more than one OpenBSD partition!");
+ if (!ask_yn("Write MBR anyway?"))
+ return (CMD_CONT);
+ }
fd = DISK_open(disk->name, O_RDWR);
MBR_make(mbr, mbr_buf);