From 9ae693400485454b554ef6d3febec21fb051f32f Mon Sep 17 00:00:00 2001 From: krw Date: Sun, 2 May 2021 20:07:14 +0000 Subject: [PATCH] Try harder to ensure there are no GPT revenants after choosing MBR partitioning. --- sbin/fdisk/cmd.c | 7 ++++--- sbin/fdisk/fdisk.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index b283116a965..12fb757f559 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.99 2021/01/30 18:16:36 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.100 2021/05/02 20:07:14 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -67,6 +67,7 @@ Xreinit(char *args, struct mbr *mbr) GPT_init(); GPT_print("s", 0); } else { + memset(&gh, 0, sizeof(gh)); MBR_init(mbr); MBR_print(mbr, "s"); } @@ -430,8 +431,8 @@ Xwrite(char *args, struct mbr *mbr) warn("error writing GPT"); return (CMD_CONT); } - } else if (reinited) { - /* Make sure GPT doesn't get in the way. */ + } else { + /* Ensure any on-disk GPT headers are zeroed. */ MBR_zapgpt(&dos_mbr, DL_GETDSIZE(&dl) - 1); } diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index 2d85a7c2a1e..c453a63228e 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.103 2018/04/26 15:55:14 guenther Exp $ */ +/* $OpenBSD: fdisk.c,v 1.104 2021/05/02 20:07:14 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -214,6 +214,7 @@ main(int argc, char *argv[]) GPT_init(); query = "Do you wish to write new GPT?"; } else { + memset(&gh, 0, sizeof(gh)); MBR_init(&initial_mbr); query = "Do you wish to write new MBR and " "partition table?"; -- 2.20.1