diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-01-21 17:29:25 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-01-21 17:29:25 +0000 |
commit | a61a8677e51c81392fc5d6393cbe1d4d7aadd7e1 (patch) | |
tree | 5f0ead68c045dccc839dc1d258322063170a5ba9 /sbin | |
parent | 99b48866b7de080a2f647126a0a582f7138fd1e5 (diff) |
Split PRT_print() into PRT_print_parthdr() and PRT_print_part()
to align with GPT functions. Simplifies logic and eliminates the
magic invocations to print the header.
No functional change.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fdisk/cmd.c | 6 | ||||
-rw-r--r-- | sbin/fdisk/mbr.c | 6 | ||||
-rw-r--r-- | sbin/fdisk/part.c | 40 | ||||
-rw-r--r-- | sbin/fdisk/part.h | 5 |
4 files changed, 30 insertions, 27 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index 82a5290c84f..0216a7f6dea 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.147 2021/10/21 13:16:49 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.148 2022/01/21 17:29:24 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -316,8 +316,8 @@ setpid(const int pn, struct mbr *mbr) pp = &mbr->mbr_prt[pn]; - PRT_print(0, NULL, "s"); - PRT_print(pn, pp, "s"); + PRT_print_parthdr(); + PRT_print_part(pn, pp, "s"); pp->prt_id = ask_pid(pp->prt_id); diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index ad11fa130c4..90d2def9ea1 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.114 2021/12/11 20:09:28 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.115 2022/01/21 17:29:24 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -148,10 +148,10 @@ MBR_print(const struct mbr *mbr, const char *units) printf("Offset: %lld\t", (long long)mbr->mbr_lba_self); printf("Signature: 0x%X\n", (int)mbr->mbr_signature); - PRT_print(0, NULL, units); + PRT_print_parthdr(); for (i = 0; i < NDOSPART; i++) - PRT_print(i, &mbr->mbr_prt[i], units); + PRT_print_part(i, &mbr->mbr_prt[i], units); } int diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index f7525baa104..4a7dfa6418a 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.111 2022/01/18 19:37:27 krw Exp $ */ +/* $OpenBSD: part.c,v 1.112 2022/01/21 17:29:24 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -351,28 +351,30 @@ PRT_make(const struct prt *prt, const uint64_t lba_self, const uint64_t lba_firs } void -PRT_print(const int num, const struct prt *prt, const char *units) +PRT_print_parthdr(void) +{ + printf(" Starting Ending " + " LBA Info:\n"); + printf(" #: id C H S - C H S " + "[ start: size ]\n"); + printf("---------------------------------------" + "----------------------------------------\n"); +} + +void +PRT_print_part(const int num, const struct prt *prt, const char *units) { const struct unit_type *ut; double size; - if (prt == NULL) { - printf(" Starting Ending " - " LBA Info:\n"); - printf(" #: id C H S - C H S " - "[ start: size ]\n"); - printf("---------------------------------------" - "----------------------------------------\n"); - } else { - size = units_size(units, prt->prt_ns, &ut); - printf("%c%1d: %.2X %6u %3u %3u - %6u %3u %3u " - "[%12llu:%12.0f%s] %s\n", - (prt->prt_flag == DOSACTIVE)?'*':' ', - num, prt->prt_id, - prt->prt_scyl, prt->prt_shead, prt->prt_ssect, - prt->prt_ecyl, prt->prt_ehead, prt->prt_esect, - prt->prt_bs, size, ut->ut_abbr, ascii_id(prt->prt_id)); - } + size = units_size(units, prt->prt_ns, &ut); + printf("%c%1d: %.2X %6u %3u %3u - %6u %3u %3u " + "[%12llu:%12.0f%s] %s\n", + (prt->prt_flag == DOSACTIVE)?'*':' ', + num, prt->prt_id, + prt->prt_scyl, prt->prt_shead, prt->prt_ssect, + prt->prt_ecyl, prt->prt_ehead, prt->prt_esect, + prt->prt_bs, size, ut->ut_abbr, ascii_id(prt->prt_id)); } void diff --git a/sbin/fdisk/part.h b/sbin/fdisk/part.h index cfbc48d2e27..97e88d476bd 100644 --- a/sbin/fdisk/part.h +++ b/sbin/fdisk/part.h @@ -1,4 +1,4 @@ -/* $OpenBSD: part.h,v 1.31 2021/10/25 13:51:25 krw Exp $ */ +/* $OpenBSD: part.h,v 1.32 2022/01/21 17:29:24 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -31,7 +31,8 @@ void PRT_parse(const struct dos_partition *, const uint64_t, const uint64_t, struct prt *); void PRT_make(const struct prt *,const uint64_t, const uint64_t, struct dos_partition *); -void PRT_print(const int, const struct prt *, const char *); +void PRT_print_part(const int, const struct prt *, const char *); +void PRT_print_parthdr(void); char *PRT_uuid_to_typename(const struct uuid *); int PRT_uuid_to_type(const struct uuid *); struct uuid *PRT_type_to_uuid(const int); |