From 4707d017f4f7cc1ed11d18ba69b5ea33b21ebc25 Mon Sep 17 00:00:00 2001 From: krw Date: Tue, 7 Dec 2021 14:58:32 +0000 Subject: [PATCH] Don't truncate the default OpenBSD partition at the end of the last full cylinder. Let it extend to the end of the disk. --- sbin/fdisk/mbr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index ac911074f5c..d25b0897bb7 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.112 2021/12/01 22:37:30 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.113 2021/12/07 14:58:32 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -44,8 +44,6 @@ MBR_init(struct mbr *mbr) struct dos_partition dp; struct prt bootprt, obsdprt; daddr_t daddr; - uint64_t disksz; - const uint32_t spc = disk.dk_heads * disk.dk_sectors; memset(&gmbr, 0, sizeof(gmbr)); memset(&gh, 0, sizeof(gh)); @@ -61,7 +59,6 @@ MBR_init(struct mbr *mbr) memset(&obsdprt, 0, sizeof(obsdprt)); memset(&bootprt, 0, sizeof(bootprt)); - disksz = disk.dk_cylinders * spc; /* Use only complete cylinders. */ if (disk.dk_bootprt.prt_ns > 0) { bootprt = disk.dk_bootprt; @@ -83,10 +80,10 @@ MBR_init(struct mbr *mbr) daddr *= 2; obsdprt.prt_bs = DL_BLKTOSEC(&dl, daddr); - if (obsdprt.prt_bs >= disksz) { + if (obsdprt.prt_bs >= disk.dk_size) { memset(&obsdprt, 0, sizeof(obsdprt)); } else { - obsdprt.prt_ns = disksz - obsdprt.prt_bs; + obsdprt.prt_ns = disk.dk_size - obsdprt.prt_bs; obsdprt.prt_id = DOSPTYP_OPENBSD; if (bootprt.prt_flag != DOSACTIVE) obsdprt.prt_flag = DOSACTIVE; -- 2.20.1