-/* $OpenBSD: cmd.c,v 1.155 2022/04/18 17:32:16 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.156 2022/04/20 00:47:32 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
gedit(const int pn)
{
struct uuid oldtype;
- struct gpt_partition *gg;
char *name;
uint16_t *utf;
int i;
- gg = &gp[pn];
- oldtype = gg->gp_type;
+ oldtype = gp[pn].gp_type;
if (gsetpid(pn))
return -1;
- if (uuid_is_nil(&gg->gp_type, NULL)) {
+ if (uuid_is_nil(&gp[pn].gp_type, NULL)) {
if (uuid_is_nil(&oldtype, NULL) == 0) {
- memset(gg, 0, sizeof(struct gpt_partition));
+ memset(&gp[pn], 0, sizeof(gp[pn]));
printf("Partition %d is disabled.\n", pn);
}
return 0;
return -1;
}
- name = ask_string("Partition name", utf16le_to_string(gg->gp_name));
+ name = ask_string("Partition name", utf16le_to_string(gp[pn].gp_name));
if (strlen(name) >= GPTPARTNAMESIZE) {
printf("partition name must be < %d characters\n",
GPTPARTNAMESIZE);
*/
utf = string_to_utf16le(name);
for (i = 0; i < GPTPARTNAMESIZE; i++) {
- gg->gp_name[i] = utf[i];
+ gp[pn].gp_name[i] = utf[i];
if (utf[i] == 0)
break;
}
{
struct gpt_partition oldgg;
struct prt oldprt;
- struct gpt_partition *gg;
int pn;
pn = parsepn(args);
oldgg = gp[pn];
if (gedit(pn))
gp[pn] = oldgg;
- else if (memcmp(&gp[pn], &oldgg, sizeof(oldgg)))
+ else if (memcmp(&gp[pn], &oldgg, sizeof(gp[pn])))
return CMD_DIRTY;
} else {
oldprt = mbr->mbr_prt[pn];
gsetpid(const int pn)
{
struct uuid gp_type, gp_guid;
- struct gpt_partition *gg;
uint32_t status;
- gg = &gp[pn];
-
GPT_print_parthdr(TERSE);
GPT_print_part(pn, "s", TERSE);
- uuid_dec_le(&gg->gp_type, &gp_type);
+ uuid_dec_le(&gp[pn].gp_type, &gp_type);
if (PRT_protected_guid(&gp_type)) {
printf("can't edit partition type %s\n",
PRT_uuid_to_typename(&gp_type));
return -1;
}
- uuid_dec_le(&gg->gp_guid, &gp_guid);
+ uuid_dec_le(&gp[pn].gp_guid, &gp_guid);
if (uuid_is_nil(&gp_guid, NULL)) {
uuid_create(&gp_guid, &status);
if (status != uuid_s_ok) {
}
}
- uuid_enc_le(&gg->gp_type, &gp_type);
- uuid_enc_le(&gg->gp_guid, &gp_guid);
+ uuid_enc_le(&gp[pn].gp_type, &gp_type);
+ uuid_enc_le(&gp[pn].gp_guid, &gp_guid);
return 0;
}
oldgg = gp[pn];
if (gsetpid(pn))
gp[pn] = oldgg;
- else if (memcmp(&gp[pn], &oldgg, sizeof(oldgg)))
+ else if (memcmp(&gp[pn], &oldgg, sizeof(gp[pn])))
return CMD_DIRTY;
} else {
oldprt = mbr->mbr_prt[pn];
-/* $OpenBSD: gpt.c,v 1.69 2022/04/19 17:53:15 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.70 2022/04/20 00:47:32 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
{
const struct unit_type *ut;
struct uuid guid;
- struct gpt_partition *partn = &gp[pn];
char *guidstr = NULL;
double size;
uint64_t sectors;
uint32_t status;
- uuid_dec_le(&partn->gp_type, &guid);
- sectors = letoh64(partn->gp_lba_end) - letoh64(partn->gp_lba_start) + 1;
+ uuid_dec_le(&gp[pn].gp_type, &guid);
+ sectors = letoh64(gp[pn].gp_lba_end) - letoh64(gp[pn].gp_lba_start) + 1;
size = units_size(units, sectors, &ut);
printf("%c%3u: %-36s [%12lld: %12.0f%s]\n",
- (letoh64(partn->gp_attrs) & GPTDOSACTIVE)?'*':' ', pn,
- PRT_uuid_to_typename(&guid), letoh64(partn->gp_lba_start),
+ (letoh64(gp[pn].gp_attrs) & GPTDOSACTIVE) ? '*' : ' ', pn,
+ PRT_uuid_to_typename(&guid), letoh64(gp[pn].gp_lba_start),
size, ut->ut_abbr);
if (verbosity == VERBOSE) {
- uuid_dec_le(&partn->gp_guid, &guid);
+ uuid_dec_le(&gp[pn].gp_guid, &guid);
uuid_to_string(&guid, &guidstr, &status);
if (status != uuid_s_ok)
printf(" <invalid partition guid> ");
else
printf(" %-36s ", guidstr);
- printf("%-36s\n", utf16le_to_string(partn->gp_name));
+ printf("%-36s\n", utf16le_to_string(gp[pn].gp_name));
free(guidstr);
}
}