Module Name: src Committed By: martin Date: Tue Mar 26 14:55:02 UTC 2019
Modified Files: src/sbin/gpt: gpt.8 unset.c Log Message: Allow -b to specify a partition for "gpt unset" as well. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sbin/gpt/gpt.8 cvs rdiff -u -r1.14 -r1.15 src/sbin/gpt/unset.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/gpt/gpt.8 diff -u src/sbin/gpt/gpt.8:1.66 src/sbin/gpt/gpt.8:1.67 --- src/sbin/gpt/gpt.8:1.66 Mon Mar 25 20:15:49 2019 +++ src/sbin/gpt/gpt.8 Tue Mar 26 14:55:02 2019 @@ -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 , Index: src/sbin/gpt/unset.c diff -u src/sbin/gpt/unset.c:1.14 src/sbin/gpt/unset.c:1.15 --- src/sbin/gpt/unset.c:1.14 Mon Mar 19 09:06:20 2018 +++ src/sbin/gpt/unset.c Tue Mar 26 14:55:02 2019 @@ -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 *arg 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 *arg } } + 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();