unit_types, 'pt_' for part_type, 'pg_' for protected_guid.
No functional change.
-/* $OpenBSD: cmd.c,v 1.124 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.125 2021/07/12 18:31:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
char *mbrstr;
int i;
- for (i = 0; cmd_table[i].cmd != NULL; i++) {
- strlcpy(help, cmd_table[i].help, sizeof(help));
+ for (i = 0; cmd_table[i].cmd_name != NULL; i++) {
+ strlcpy(help, cmd_table[i].cmd_help, sizeof(help));
if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
- if (cmd_table[i].gpt == 0)
+ if (cmd_table[i].cmd_gpt == 0)
continue;
mbrstr = strstr(help, "MBR");
if (mbrstr)
memcpy(mbrstr, "GPT", 3);
}
- printf("\t%s\t\t%s\n", cmd_table[i].cmd, help);
+ printf("\t%s\t\t%s\n", cmd_table[i].cmd_name, help);
}
return CMD_CONT;
-/* $OpenBSD: cmd.h,v 1.21 2021/07/11 13:23:18 krw Exp $ */
+/* $OpenBSD: cmd.h,v 1.22 2021/07/12 18:31:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#define CMD_DIRTY 0x0004
struct cmd {
- char *cmd;
- int gpt;
- int (*fcn)(char *, struct mbr *);
- char *help;
+ char *cmd_name;
+ int cmd_gpt;
+ int (*cmd_fcn)(char *, struct mbr *);
+ char *cmd_help;
};
extern struct cmd cmd_table[];
-/* $OpenBSD: disk.c,v 1.60 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: disk.c,v 1.61 2021/07/12 18:31:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
if (ioctl(disk.dk_fd, DIOCGPDINFO, &dl) == -1) {
warn("DIOCGPDINFO");
} else {
- unit_types[SECTORS].conversion = dl.d_secsize;
+ unit_types[SECTORS].ut_conversion = dl.d_secsize;
if (disk.dk_size == 0) {
/* -l or -c/-h/-s not used. Use disklabel info. */
disk.dk_cylinders = dl.d_ncylinders;
}
if (disk.dk_size == 0 || disk.dk_cylinders == 0 || disk.dk_heads == 0 ||
- disk.dk_sectors == 0 || unit_types[SECTORS].conversion == 0)
+ disk.dk_sectors == 0 || unit_types[SECTORS].ut_conversion == 0)
errx(1, "Can't get disk geometry, please use [-chs] or [-l]"
"to specify.");
}
int
DISK_printgeometry(char *units)
{
- const int secsize = unit_types[SECTORS].conversion;
+ const int secsize = unit_types[SECTORS].ut_conversion;
double size;
int i;
i = unit_lookup(units);
- size = ((double)disk.dk_size * secsize) / unit_types[i].conversion;
+ size = ((double)disk.dk_size * secsize) / unit_types[i].ut_conversion;
printf("Disk: %s\t", disk.dk_name);
if (disk.dk_size) {
printf("geometry: %d/%d/%d [%.0f ", disk.dk_cylinders,
disk.dk_heads, disk.dk_sectors, size);
if (i == SECTORS && secsize != sizeof(struct dos_mbr))
printf("%d-byte ", secsize);
- printf("%s]\n", unit_types[i].lname);
+ printf("%s]\n", unit_types[i].ut_lname);
} else
printf("geometry: <none>\n");
-/* $OpenBSD: gpt.c,v 1.38 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.39 2021/07/12 18:31:53 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
void
GPT_print(char *units, int verbosity)
{
- const int secsize = unit_types[SECTORS].conversion;
+ const int secsize = unit_types[SECTORS].ut_conversion;
struct uuid guid;
char *guidstr = NULL;
double size;
int i, u, status;
u = unit_lookup(units);
- size = ((double)DL_GETDSIZE(&dl) * secsize) / unit_types[u].conversion;
+ size = ((double)DL_GETDSIZE(&dl) * secsize) / unit_types[u].ut_conversion;
printf("Disk: %s Usable LBA: %llu to %llu [%.0f ",
disk.dk_name, letoh64(gh.gh_lba_start), letoh64(gh.gh_lba_end), size);
if (u == SECTORS && secsize != DEV_BSIZE)
printf("%d-byte ", secsize);
- printf("%s]\n", unit_types[u].lname);
+ printf("%s]\n", unit_types[u].ut_lname);
if (verbosity == VERBOSE) {
printf("GUID: ");
struct uuid guid;
struct gpt_partition *partn = &gp[n];
char *guidstr = NULL;
- const int secsize = unit_types[SECTORS].conversion;
+ const int secsize = unit_types[SECTORS].ut_conversion;
double size;
int u, status;
uuid_dec_le(&partn->gp_type, &guid);
u = unit_lookup(units);
size = letoh64(partn->gp_lba_end) - letoh64(partn->gp_lba_start) + 1;
- size = (size * secsize) / unit_types[u].conversion;
+ size = (size * secsize) / unit_types[u].ut_conversion;
printf("%c%3d: %-36s [%12lld: %12.0f%s]\n",
(letoh64(partn->gp_attrs) & GPTDOSACTIVE)?'*':' ', n,
PRT_uuid_to_typename(&guid), letoh64(partn->gp_lba_start),
- size, unit_types[u].abbr);
+ size, unit_types[u].ut_abbr);
if (verbosity == VERBOSE) {
uuid_dec_le(&partn->gp_guid, &guid);
{
struct gpt_header oldgh;
struct uuid guid;
- const int secsize = unit_types[SECTORS].conversion;
+ const int secsize = unit_types[SECTORS].ut_conversion;
int needed;
uint32_t status;
char *secbuf;
ssize_t len;
off_t off;
- const int secsize = unit_types[SECTORS].conversion;
+ const int secsize = unit_types[SECTORS].ut_conversion;
uint64_t altgh, altgp, prigh, prigp, gpbytes;
/*
-/* $OpenBSD: misc.c,v 1.73 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: misc.c,v 1.74 2021/07/12 18:31:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
if (units == NULL)
return SECTORS;
- while (unit_types[i].abbr != NULL) {
- if (strncasecmp(unit_types[i].abbr, units, 1) == 0)
+ while (unit_types[i].ut_abbr != NULL) {
+ if (strncasecmp(unit_types[i].ut_abbr, units, 1) == 0)
break;
i++;
}
/* default */
- if (unit_types[i].abbr == NULL)
+ if (unit_types[i].ut_abbr == NULL)
return SECTORS;
return i;
getuint64(char *prompt, uint64_t oval, uint64_t minval, uint64_t maxval)
{
char buf[BUFSIZ], *endptr, *p, operator = '\0';
- const int secsize = unit_types[SECTORS].conversion;
+ const int secsize = unit_types[SECTORS].ut_conversion;
size_t n;
int64_t mult = 1;
double d, d2;
-/* $OpenBSD: part.c,v 1.92 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: part.c,v 1.93 2021/07/12 18:31:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
const char *ascii_id(int);
static const struct part_type {
- int type;
- char sname[14];
- char guid[UUID_STR_LEN + 1];
+ int pt_type;
+ char pt_sname[14];
+ char pt_guid[UUID_STR_LEN + 1];
} part_types[] = {
{ 0x00, "unused ", "00000000-0000-0000-0000-000000000000" },
{ 0x01, "FAT12 ", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7" },
};
static const struct protected_guid {
- char guid[UUID_STR_LEN + 1];
+ char pg_guid[UUID_STR_LEN + 1];
} protected_guid[] = {
{ "7c3457ef-0000-11aa-aa11-00306543ecac" }, /* APFS */
{ "69646961-6700-11aa-aa11-00306543ecac" }, /* APFS ISC */
rslt = 0;
for(i = 0; i < nitems(protected_guid); i++) {
- if (strncmp(str, protected_guid[i].guid, UUID_STR_LEN) == 0) {
+ if (strncmp(str, protected_guid[i].pg_guid, UUID_STR_LEN) == 0) {
rslt = 1;
break;
}
printf("Choose from the following Partition id values:\n");
for (i = 0; i < idrows; i++) {
printf("%02X %s %02X %s %02X %s",
- part_types[i].type, part_types[i].sname,
- part_types[i+idrows].type, part_types[i+idrows].sname,
- part_types[i+idrows*2].type, part_types[i+idrows*2].sname);
+ part_types[i].pt_type, part_types[i].pt_sname,
+ part_types[i+idrows].pt_type, part_types[i+idrows].pt_sname,
+ part_types[i+idrows*2].pt_type, part_types[i+idrows*2].pt_sname);
if ((i+idrows*3) < (sizeof(part_types)/sizeof(struct part_type))) {
printf(" %02X %s\n",
- part_types[i+idrows*3].type,
- part_types[i+idrows*3].sname);
+ part_types[i+idrows*3].pt_type,
+ part_types[i+idrows*3].pt_sname);
} else
printf( "\n" );
}
int i;
for (i = 0; i < sizeof(part_types)/sizeof(struct part_type); i++) {
- if (part_types[i].type == id)
- return part_types[i].sname;
+ if (part_types[i].pt_type == id)
+ return part_types[i].pt_sname;
}
return unknown;
void
PRT_print(int num, struct prt *prt, char *units)
{
- const int secsize = unit_types[SECTORS].conversion;
+ const int secsize = unit_types[SECTORS].ut_conversion;
double size;
int i;
printf("---------------------------------------"
"----------------------------------------\n");
} else {
- size = ((double)prt->prt_ns * secsize) / unit_types[i].conversion;
+ size = ((double)prt->prt_ns * secsize) / unit_types[i].ut_conversion;
printf("%c%1d: %.2X %6u %3u %3u - %6u %3u %3u "
"[%12llu:%12.0f%s] %s\n",
(prt->prt_flag == DOSACTIVE)?'*':' ',
prt->prt_scyl, prt->prt_shead, prt->prt_ssect,
prt->prt_ecyl, prt->prt_ehead, prt->prt_esect,
prt->prt_bs, size,
- unit_types[i].abbr,
+ unit_types[i].ut_abbr,
ascii_id(prt->prt_id));
}
}
entries = sizeof(part_types) / sizeof(struct part_type);
for (i = 0; i < entries; i++) {
- if (memcmp(part_types[i].guid, uuidstr,
- sizeof(part_types[i].guid)) == 0)
+ if (memcmp(part_types[i].pt_guid, uuidstr,
+ sizeof(part_types[i].pt_guid)) == 0)
break;
}
if (i < entries)
- strlcpy(partition_type, part_types[i].sname,
+ strlcpy(partition_type, part_types[i].pt_sname,
sizeof(partition_type));
else
strlcpy(partition_type, uuidstr, sizeof(partition_type));
entries = sizeof(part_types) / sizeof(struct part_type);
for (i = 0; i < entries; i++) {
- if (memcmp(part_types[i].guid, uuidstr,
- sizeof(part_types[i].guid)) == 0) {
- type = part_types[i].type;
+ if (memcmp(part_types[i].pt_guid, uuidstr,
+ sizeof(part_types[i].pt_guid)) == 0) {
+ type = part_types[i].pt_type;
break;
}
}
entries = sizeof(part_types) / sizeof(struct part_type);
for (i = 0; i < entries; i++) {
- if (part_types[i].type == type)
+ if (part_types[i].pt_type == type)
break;
}
if (i < entries)
- uuid_from_string(part_types[i].guid, &guid, &status);
+ uuid_from_string(part_types[i].pt_guid, &guid, &status);
if (i == entries || status != uuid_s_ok)
- uuid_from_string(part_types[0].guid, &guid, &status);
+ uuid_from_string(part_types[0].pt_guid, &guid, &status);
return &guid;
}
-/* $OpenBSD: user.c,v 1.60 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: user.c,v 1.61 2021/07/12 18:31:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
if (cmd[0] == '\0')
continue;
- for (i = 0; cmd_table[i].cmd != NULL; i++)
- if (strstr(cmd_table[i].cmd, cmd) == cmd_table[i].cmd)
+ for (i = 0; cmd_table[i].cmd_name != NULL; i++)
+ if (strstr(cmd_table[i].cmd_name, cmd) == cmd_table[i].cmd_name)
break;
/* Quick hack to put in '?' == 'help' */
i = 0;
/* Check for valid command */
- if ((cmd_table[i].cmd == NULL) || (letoh64(gh.gh_sig) ==
- GPTSIGNATURE && cmd_table[i].gpt == 0)) {
+ if ((cmd_table[i].cmd_name == NULL) || (letoh64(gh.gh_sig) ==
+ GPTSIGNATURE && cmd_table[i].cmd_gpt == 0)) {
printf("Invalid command '%s'. Try 'help'.\n", cmd);
continue;
}
/* Call function */
- st = cmd_table[i].fcn(args, &mbr);
+ st = cmd_table[i].cmd_fcn(args, &mbr);
/* Update status */
if (st == CMD_EXIT)