Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Allow -b to specify a partition for "gpt unset" as ...



details:   https://anonhg.NetBSD.org/src/rev/3070ebb7c916
branches:  trunk
changeset: 449855:3070ebb7c916
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Mar 26 14:55:02 2019 +0000

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

diffstat:

 sbin/gpt/gpt.8   |   9 ++++++---
 sbin/gpt/unset.c |  23 +++++++++++++++++++++--
 2 files changed, 27 insertions(+), 5 deletions(-)

diffs (99 lines):

diff -r f9a86c8b7d06 -r 3070ebb7c916 sbin/gpt/gpt.8
--- a/sbin/gpt/gpt.8    Tue Mar 26 13:32:26 2019 +0000
+++ b/sbin/gpt/gpt.8    Tue Mar 26 14:55:02 2019 +0000
@@ -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 @@
 .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 @@
 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 ,
diff -r f9a86c8b7d06 -r 3070ebb7c916 sbin/gpt/unset.c
--- a/sbin/gpt/unset.c  Tue Mar 26 13:32:26 2019 +0000
+++ b/sbin/gpt/unset.c  Tue Mar 26 14:55:02 2019 +0000
@@ -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 const char *unsethelp[] = {
        "-a attribute -i index",
+       "-a attribute -b startsec",
        "-l",
 };
 
@@ -71,13 +72,19 @@
        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 @@
                }
        }
 
+       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();
 



Home | Main Index | Thread Index | Old Index