diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-07-18 21:40:14 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-07-18 21:40:14 +0000 |
commit | 6abd62aee76a1637185997383e88914b9ea1b1fe (patch) | |
tree | a0a83ce51f8cbccb520cb15b6612ffc4a8e0525c /sbin/fdisk/part.c | |
parent | c93d850d138320329d2c0c2a489b5bb667437b0a (diff) |
Don't save the prt_scyl/prt_ecyl values, change them, use them
and then restore them. Just change/use the saved values and skip
the restoring.
Allows PRT_make() to add 'const' to its struct mbr parameter, and
thus allows MBR_make() to add 'const' to its struct mbr
parameter.
No intentional functional change.
Diffstat (limited to 'sbin/fdisk/part.c')
-rw-r--r-- | sbin/fdisk/part.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index 14e8ba92f6d..c062cc003c6 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.99 2021/07/16 22:50:43 krw Exp $ */ +/* $OpenBSD: part.c,v 1.100 2021/07/18 21:40:13 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -275,20 +275,15 @@ check_chs(const struct prt *prt) } void -PRT_make(struct prt *prt, const uint64_t lba_self, const uint64_t lba_firstembr, +PRT_make(const struct prt *prt, const uint64_t lba_self, const uint64_t lba_firstembr, struct dos_partition *dp) { uint64_t off, t; - uint32_t ecsave, scsave; + uint32_t ecyl, scyl; - /* Save (and restore below) cylinder info we may fiddle with. */ - scsave = prt->prt_scyl; - ecsave = prt->prt_ecyl; + scyl = (prt->prt_scyl > 1023) ? 1023 : prt->prt_scyl; + ecyl = (prt->prt_ecyl > 1023) ? 1023 : prt->prt_ecyl; - if ((prt->prt_scyl > 1023) || (prt->prt_ecyl > 1023)) { - prt->prt_scyl = (prt->prt_scyl > 1023)? 1023: prt->prt_scyl; - prt->prt_ecyl = (prt->prt_ecyl > 1023)? 1023: prt->prt_ecyl; - } if ((prt->prt_id == DOSPTYP_EXTEND) || (prt->prt_id == DOSPTYP_EXTENDL)) off = lba_firstembr; else @@ -296,13 +291,11 @@ PRT_make(struct prt *prt, const uint64_t lba_self, const uint64_t lba_firstembr, if (check_chs(prt) == 0) { dp->dp_shd = prt->prt_shead & 0xFF; - dp->dp_ssect = (prt->prt_ssect & 0x3F) | - ((prt->prt_scyl & 0x300) >> 2); - dp->dp_scyl = prt->prt_scyl & 0xFF; + dp->dp_ssect = (prt->prt_ssect & 0x3F) | ((scyl & 0x300) >> 2); + dp->dp_scyl = scyl & 0xFF; dp->dp_ehd = prt->prt_ehead & 0xFF; - dp->dp_esect = (prt->prt_esect & 0x3F) | - ((prt->prt_ecyl & 0x300) >> 2); - dp->dp_ecyl = prt->prt_ecyl & 0xFF; + dp->dp_esect = (prt->prt_esect & 0x3F) | ((ecyl & 0x300) >> 2); + dp->dp_ecyl = ecyl & 0xFF; } else { memset(dp, 0xFF, sizeof(*dp)); } @@ -318,9 +311,6 @@ PRT_make(struct prt *prt, const uint64_t lba_self, const uint64_t lba_firstembr, else t = htole64(prt->prt_ns); memcpy(&dp->dp_size, &t, sizeof(uint32_t)); - - prt->prt_scyl = scsave; - prt->prt_ecyl = ecsave; } void |