summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2015-11-18 02:12:51 +0000
committerkrw <krw@openbsd.org>2015-11-18 02:12:51 +0000
commit165305932a3d82530894b18c396babf6300a1bb7 (patch)
tree75bf541d327c171a711f8745f43efca62e5dac13
parentRead MBR immediately, and only read the GPT if the MBR is a (diff)
downloadwireguard-openbsd-165305932a3d82530894b18c396babf6300a1bb7.tar.xz
wireguard-openbsd-165305932a3d82530894b18c396babf6300a1bb7.zip
USER_edit() (a.k.a. -e) edits the on-disk information. So zap GPT
and re-read it from disk if appropriate. i.e. when the re-read MBR is a protective MBR.
-rw-r--r--sbin/fdisk/user.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c
index b02b712d86a..ab40e1a238e 100644
--- a/sbin/fdisk/user.c
+++ b/sbin/fdisk/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.46 2015/11/13 02:27:17 krw Exp $ */
+/* $OpenBSD: user.c,v 1.47 2015/11/18 02:12:51 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -74,6 +74,13 @@ USER_edit(off_t offset, off_t reloff)
/* Parse the sucker */
MBR_parse(&dos_mbr, offset, reloff, &mbr);
+ if (editlevel == 1) {
+ memset(&gh, 0, sizeof(gh));
+ memset(&gp, 0, sizeof(gp));
+ if (MBR_protective_mbr(&mbr) == 0)
+ GPT_get_gpt();
+ }
+
printf("Enter 'help' for information\n");
/* Edit cycle */