From: krw Date: Wed, 1 Dec 2021 22:37:30 +0000 (+0000) Subject: Remove the MBR_init() "#ifdef defined(__macppc__) || X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=354eded82a987a0032db0f12e45cbfbadee14669;p=openbsd Remove the MBR_init() "#ifdef defined(__macppc__) || defined(__mips__)" chunk that rounded the start of the default OpenBSD partition to a cylinder boundary. The value has been immediately re-rounded to a power of 2 block since r1.25 in 2009. Eliminates wasted space when no /usr/mdec/mbr partition 0 information is available. '-b' becomes available to architectures other than amd64 and i386, taking precedence over /usr/mdec/mbr partition 0 information. The latter being present only in macppc and loongson /usr/mdec/mbr files. --- diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index 67b2eda71df..ac911074f5c 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.111 2021/11/25 15:40:26 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.112 2021/12/01 22:37:30 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -63,8 +63,12 @@ MBR_init(struct mbr *mbr) memset(&bootprt, 0, sizeof(bootprt)); disksz = disk.dk_cylinders * spc; /* Use only complete cylinders. */ - memcpy(&dp, &default_dmbr.dmbr_parts[0], sizeof(dp)); - PRT_parse(&dp, 0, 0, &bootprt); + if (disk.dk_bootprt.prt_ns > 0) { + bootprt = disk.dk_bootprt; + } else { + memcpy(&dp, &default_dmbr.dmbr_parts[0], sizeof(dp)); + PRT_parse(&dp, 0, 0, &bootprt); + } if (bootprt.prt_ns > 0) obsdprt.prt_bs = bootprt.prt_bs + bootprt.prt_ns; @@ -73,17 +77,6 @@ MBR_init(struct mbr *mbr) else obsdprt.prt_bs = 1; -#if defined(__powerpc__) || defined(__mips__) - /* Now fix up for the MS-DOS boot partition on PowerPC/MIPS. */ - if (obsdprt.prt_bs % spc != 0) - obsdprt.prt_bs += spc - (obsdprt.prt_bs % spc); -#else - if (disk.dk_bootprt.prt_ns > 0) { - bootprt = disk.dk_bootprt; - obsdprt.prt_bs = bootprt.prt_bs + bootprt.prt_ns; - } -#endif - /* Start OpenBSD MBR partition on a power of 2 block number. */ daddr = 1; while (daddr < DL_SECTOBLK(&dl, obsdprt.prt_bs))