summaryrefslogtreecommitdiff
path: root/sbin/fdisk/fdisk.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2021-06-28 19:50:31 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2021-06-28 19:50:31 +0000
commitf47eac402e8ba02bf3e05644ac9349614da02f47 (patch)
tree805d9e5837a20c29cf45b1980f52f872c9ecdbeb /sbin/fdisk/fdisk.c
parent306c7adbb5c486e3af59c7cd8c418881ad8c1d35 (diff)
Add another epicycle to -A processing that ensures ONLY the
partition table is changed. Not the GPT header. Not the MBR. And only write back as much partition table information as the header claims to have room for. At a minimum should make -A safer when operating on the Apple M1 GPT. A major overhaul of this code is urgently needed before someone sneezes too hard in its vicinity. Feedback kettenis@ & ok deraadt@
Diffstat (limited to 'sbin/fdisk/fdisk.c')
-rw-r--r--sbin/fdisk/fdisk.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index b1f3870a964..59a43da8daf 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdisk.c,v 1.113 2021/06/25 19:24:53 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.114 2021/06/28 19:50:30 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -222,14 +222,14 @@ main(int argc, char *argv[])
if (letoh64(gh.gh_sig) != GPTSIGNATURE)
errx(1, "-A requires a valid GPT");
else {
- MBR_init_GPT(&initial_mbr);
- GPT_init();
+ initial_mbr = mbr; /* Keep current MBR. */
+ GPT_init(GPONLY, b_sectors);
query = "Do you wish to write new GPT?";
}
} else if (i_flag) {
if (g_flag) {
MBR_init_GPT(&initial_mbr);
- GPT_init();
+ GPT_init(GHANDGP, b_sectors);
query = "Do you wish to write new GPT?";
} else {
memset(&gh, 0, sizeof(gh));