GPT_read() to match MBR_read().
No intentional functional change.
-/* $OpenBSD: cmd.c,v 1.101 2021/05/07 22:15:13 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.102 2021/05/10 17:16:01 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
if (dogpt) {
MBR_init_GPT(mbr);
GPT_init();
- GPT_print("s", 0);
+ GPT_print("s", TERSE);
} else {
memset(&gh, 0, sizeof(gh));
MBR_init(mbr);
gg = &gp[pn];
/* Print out current table entry */
- GPT_print_parthdr(0);
- GPT_print_part(pn, "s", 0);
+ GPT_print_parthdr(TERSE);
+ GPT_print_part(pn, "s", TERSE);
/* Ask for partition type or GUID. */
uuid_dec_le(&gg->gp_type, &guid);
{
if (MBR_protective_mbr(mbr) == 0 && letoh64(gh.gh_sig) == GPTSIGNATURE)
- GPT_print(args, 1);
+ GPT_print(args, VERBOSE);
else
MBR_print(mbr, args);
-/* $OpenBSD: fdisk.c,v 1.105 2021/05/07 22:15:13 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.106 2021/05/10 17:16:01 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
ssize_t len;
int ch, fd, error;
int e_flag = 0, g_flag = 0, i_flag = 0, u_flag = 0;
- int verbosity = 0;
+ int verbosity = TERSE;
int c_arg = 0, h_arg = 0, s_arg = 0;
uint32_t l_arg = 0;
char *query;
y_flag = 1;
break;
case 'v':
- verbosity++;
+ verbosity = VERBOSE;
break;
default:
usage();
/* Get the GPT if present. Either primary or secondary is ok. */
if (MBR_protective_mbr(&mbr) == 0)
- GPT_get_gpt(0);
+ GPT_read(ANYGPT);
if (!(i_flag || u_flag || e_flag)) {
if (pledge("stdio", NULL) == -1)
-/* $OpenBSD: gpt.c,v 1.13 2021/05/07 22:15:13 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.14 2021/05/10 17:16:01 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
}
void
-GPT_get_gpt(int which)
+GPT_read(int which)
{
- int privalid, altvalid;
+ int valid;
- /*
- * primary header && primary partition table ||
- * alt header && alt partition table
- */
- privalid = GPT_get_header(GPTSECTOR);
- if (privalid == 0)
- privalid = GPT_get_partition_table(gh.gh_part_lba);
- if (which == 1 || (which == 0 && privalid == 0))
+ valid = GPT_get_header(GPTSECTOR);
+ if (valid == 0)
+ valid = GPT_get_partition_table(gh.gh_part_lba);
+ if (which == PRIMARYGPT || (which == ANYGPT && valid == 0))
return;
/* No valid GPT found. Zap any artifacts. */
memset(&gh, 0, sizeof(gh));
memset(&gp, 0, sizeof(gp));
- altvalid = GPT_get_header(DL_GETDSIZE(&dl) - 1);
- if (altvalid == 0)
- altvalid = GPT_get_partition_table(gh.gh_part_lba);
- if (which == 2 || altvalid == 0)
+ valid = GPT_get_header(DL_GETDSIZE(&dl) - 1);
+ if (valid == 0)
+ valid = GPT_get_partition_table(gh.gh_part_lba);
+ if (which == SECONDARYGPT || valid == 0)
return;
/* No valid GPT found. Zap any artifacts. */
printf("%d-byte ", secsize);
printf("%s]\n", unit_types[u].lname);
- if (verbosity) {
+ if (verbosity == VERBOSE) {
printf("GUID: ");
uuid_dec_le(&gh.gh_guid, &guid);
uuid_to_string(&guid, &guidstr, &status);
{
printf(" #: type "
" [ start: size ]\n");
- if (verbosity)
+ if (verbosity == VERBOSE)
printf(" guid name\n");
printf("--------------------------------------------------------"
"----------------\n");
PRT_uuid_to_typename(&guid), letoh64(partn->gp_lba_start),
size, unit_types[u].abbr);
- if (verbosity) {
+ if (verbosity == VERBOSE) {
uuid_dec_le(&partn->gp_guid, &guid);
uuid_to_string(&guid, &guidstr, &status);
if (status != uuid_s_ok)
-/* $OpenBSD: gpt.h,v 1.8 2021/05/06 22:26:14 krw Exp $ */
+/* $OpenBSD: gpt.h,v 1.9 2021/05/10 17:16:01 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-void GPT_get_gpt(int);
+void GPT_read(int);
int GPT_get_header(off_t);
int GPT_get_partition_table(off_t);
int GPT_get_lba_start(unsigned int);
extern struct gpt_header gh;
extern struct gpt_partition gp[NGPTPARTITIONS];
+
+#define ANYGPT 0
+#define PRIMARYGPT 1
+#define SECONDARYGPT 2
+
+#define TERSE 0
+#define VERBOSE 1
-/* $OpenBSD: user.c,v 1.52 2019/04/29 18:54:12 krw Exp $ */
+/* $OpenBSD: user.c,v 1.53 2021/05/10 17:16:01 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
memset(&gh, 0, sizeof(gh));
memset(&gp, 0, sizeof(gp));
if (MBR_protective_mbr(&mbr) == 0)
- GPT_get_gpt(0);
+ GPT_read(ANYGPT);
}
printf("Enter 'help' for information\n");
break;
MBR_parse(&dos_mbr, offset, firstoff, &mbr);
if (offset == 0) {
- if (verbosity || MBR_protective_mbr(&mbr) == 0) {
- if (verbosity) {
+ if (verbosity == VERBOSE || MBR_protective_mbr(&mbr) ==
+ 0) {
+ if (verbosity == VERBOSE) {
printf("Primary GPT:\n");
- GPT_get_gpt(1); /* Get Primary */
+ GPT_read(PRIMARYGPT);
}
if (letoh64(gh.gh_sig) == GPTSIGNATURE)
GPT_print("s", verbosity);
else
printf("\tNot Found\n");
- if (verbosity) {
+ if (verbosity == VERBOSE) {
printf("\n");
printf("Secondary GPT:\n");
- GPT_get_gpt(2); /* Get Secondary */
+ GPT_read(SECONDARYGPT);
if (letoh64(gh.gh_sig) == GPTSIGNATURE)
GPT_print("s", verbosity);
else