diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-05-15 15:20:18 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-05-15 15:20:18 +0000 |
commit | f0f68d85e9094ba5a27503e40e7c018629e5349a (patch) | |
tree | 42ce1d04ed29066b9653f21d215fa6008edf803c /sbin | |
parent | afaffa814f431d3c7690d884cfb7f06bb47b9d1e (diff) |
Shuffle USER_print_disk() code into a more rational, clearer
structure.
No intentional functional change.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fdisk/user.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c index 1f721a89335..1972211a2a3 100644 --- a/sbin/fdisk/user.c +++ b/sbin/fdisk/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.54 2021/05/14 15:31:01 krw Exp $ */ +/* $OpenBSD: user.c,v 1.55 2021/05/15 15:20:17 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -155,27 +155,35 @@ USER_print_disk(int verbosity) MBR_parse(&dos_mbr, offset, firstoff, &mbr); if (offset == 0) { efi = MBR_protective_mbr(&mbr); - if (verbosity == VERBOSE || efi != -1) { + if (efi == -1) { + /* No valid 0xEE partition means no GPT. */ if (verbosity == VERBOSE) { - printf("Primary GPT:\n"); - GPT_read(PRIMARYGPT); + printf("Primary GPT:\nNot Found\n"); + printf("\nSecondary GPT:\nNot Found\n"); } + } else if (verbosity == TERSE) { + /* Should already have read one of Primary/Secondary GPT. */ + if (letoh64(gh.gh_sig) == GPTSIGNATURE) { + GPT_print("s", verbosity); + return; + } + } else { + /*. Read & print both primary and secondary GPT. */ + printf("Primary GPT:\n"); + GPT_read(PRIMARYGPT); if (letoh64(gh.gh_sig) == GPTSIGNATURE) GPT_print("s", verbosity); else printf("\tNot Found\n"); - if (verbosity == VERBOSE) { - printf("\n"); - printf("Secondary GPT:\n"); - GPT_read(SECONDARYGPT); - if (letoh64(gh.gh_sig) == GPTSIGNATURE) - GPT_print("s", verbosity); - else - printf("\tNot Found\n"); - printf("\nMBR:\n"); - } else - break; - } + printf("\nSecondary GPT:\n"); + GPT_read(SECONDARYGPT); + if (letoh64(gh.gh_sig) == GPTSIGNATURE) + GPT_print("s", verbosity); + else + printf("\tNot Found\n"); + } + if (verbosity == VERBOSE) + printf("\nMBR:\n"); } MBR_print(&mbr, NULL); |