From d8f1450d24e6c12014854b10b9983fef36ad9046 Mon Sep 17 00:00:00 2001 From: krw Date: Thu, 25 Nov 2021 15:40:26 +0000 Subject: [PATCH] Honour /usr/mdec/mbr or -f partition 0 information even outside of _powerpc__ and __mips__, preventing the possible creation of MBRs with overlapping partitions 0 and 3. Don't set bootprt DOSACTIVE flag if no partition 0 information was provided via /usr/mdec/mbr or -f. Lets octeon fdisk(8) set DOSACTIVE on the OpenBSD partition in the default MBR like every other fdisk(8) does. --- sbin/fdisk/mbr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index 251bf8d6158..67b2eda71df 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.110 2021/11/20 21:35:52 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.111 2021/11/25 15:40:26 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -66,17 +66,15 @@ MBR_init(struct mbr *mbr) memcpy(&dp, &default_dmbr.dmbr_parts[0], sizeof(dp)); PRT_parse(&dp, 0, 0, &bootprt); - /* Reserve first track, or first cyl, if possible. */ - if (disk.dk_heads > 1 || disk.dk_cylinders > 1) + if (bootprt.prt_ns > 0) + obsdprt.prt_bs = bootprt.prt_bs + bootprt.prt_ns; + else if (disk.dk_heads > 1 || disk.dk_cylinders > 1) obsdprt.prt_bs = disk.dk_sectors; else obsdprt.prt_bs = 1; #if defined(__powerpc__) || defined(__mips__) /* Now fix up for the MS-DOS boot partition on PowerPC/MIPS. */ - bootprt.prt_flag = DOSACTIVE; /* Boot from dos part */ - if (bootprt.prt_ns > 0) - obsdprt.prt_bs = bootprt.prt_bs + bootprt.prt_ns; if (obsdprt.prt_bs % spc != 0) obsdprt.prt_bs += spc - (obsdprt.prt_bs % spc); #else -- 2.20.1