Allow -b to specify a partition for "gpt unset" as well.

This commit is contained in:
martin 2019-03-26 14:55:02 +00:00
parent da46072561
commit d48fad1d9d
2 changed files with 27 additions and 5 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: gpt.8,v 1.66 2019/03/25 20:15:49 martin Exp $
.\" $NetBSD: gpt.8,v 1.67 2019/03/26 14:55:02 martin Exp $
.\"
.\" Copyright (c) 2002 Marcel Moolenaar
.\" All rights reserved.
@ -26,7 +26,7 @@
.\"
.\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
.\"
.Dd March 25, 2019
.Dd March 26, 2019
.Dt GPT 8
.Os
.Sh NAME
@ -653,7 +653,7 @@ The
.Fl l
flag lists available types.
.\" ==== unset ====
.It Nm Ic unset Fl a Ar attribute Fl i Ar index
.It Nm Ic unset Fl a Ar attribute Oo Fl i Ar index Oc Oo Fl b Ar startsec Oc
.It Nm Ic unset Fl l
The
.Ic unset
@ -664,8 +664,11 @@ flag lists all available attributes.
The
.Fl a
option specifies which attributes to unset and may be specified more than once.
Alternatively a comma separated list of attributes can be used.
The
.Fl i
or the
.Fl b
option specifies which entry to update.
The possible attributes are
.Do biosboot Dc ,

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif
#ifdef __RCSID
__RCSID("$NetBSD: unset.c,v 1.14 2018/03/19 09:06:20 mlelstv Exp $");
__RCSID("$NetBSD: unset.c,v 1.15 2019/03/26 14:55:02 martin Exp $");
#endif
#include <sys/types.h>
@ -53,6 +53,7 @@ static int cmd_unset(gpt_t, int, char *[]);
static const char *unsethelp[] = {
"-a attribute -i index",
"-a attribute -b startsec",
"-l",
};
@ -71,13 +72,19 @@ cmd_unset(gpt_t gpt, int argc, char *argv[])
int ch;
unsigned int entry = 0;
uint64_t attributes = 0;
off_t start = 0;
map_t m;
while ((ch = getopt(argc, argv, "a:i:l")) != -1) {
while ((ch = getopt(argc, argv, "a:b:i:l")) != -1) {
switch(ch) {
case 'a':
if (gpt == NULL || gpt_attr_get(gpt, &attributes) == -1)
return usage();
break;
case 'b':
if (gpt == NULL || gpt_human_get(gpt, &start) == -1)
return usage();
break;
case 'i':
if (gpt == NULL || gpt_uint_get(gpt, &entry) == -1)
return usage();
@ -90,6 +97,18 @@ cmd_unset(gpt_t gpt, int argc, char *argv[])
}
}
if (start > 0) {
for (m = map_first(gpt); m != NULL; m = m->map_next) {
if (m->map_type != MAP_TYPE_GPT_PART ||
m->map_index < 1)
continue;
if (start != m->map_start)
continue;
entry = m->map_index;
break;
}
}
if (gpt == NULL || argc != optind)
return usage();