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 startsec to specify the partition to chang...



details:   https://anonhg.NetBSD.org/src/rev/08679e7caae3
branches:  trunk
changeset: 449832:08679e7caae3
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Mar 25 20:15:49 2019 +0000

description:
Allow -b startsec to specify the partition to change for the set subcommand
as well.
Add another option, -N, as a quick way to remove all attributes.

diffstat:

 sbin/gpt/gpt.8 |  16 ++++++++++++----
 sbin/gpt/set.c |  34 ++++++++++++++++++++++++++++------
 2 files changed, 40 insertions(+), 10 deletions(-)

diffs (122 lines):

diff -r 3e071adea18e -r 08679e7caae3 sbin/gpt/gpt.8
--- a/sbin/gpt/gpt.8    Mon Mar 25 19:24:29 2019 +0000
+++ b/sbin/gpt/gpt.8    Mon Mar 25 20:15:49 2019 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.65 2019/03/24 13:45:35 martin Exp $
+.\" $NetBSD: gpt.8,v 1.66 2019/03/25 20:15:49 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 24, 2019
+.Dd March 25, 2019
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -555,7 +555,8 @@
 will automatically adjust.
 However, the new disk must use the same sector size as the old disk.
 .\" ==== set ====
-.It Nm Ic set Fl a Ar attribute Fl i Ar index
+.It Nm Ic set Oo Fl a Ar attribute Oc Oo Fl N Oc Oo Fl i Ar index Oc \
+Oo Fl b Ar startsec Oc
 .It Nm Ic set Fl l
 The
 .Ic set
@@ -567,9 +568,16 @@
 .Fl a
 option specifies which attributes to set and may be specified more than once,
 or the attributes can be comma-separated.
+If the
+.Fl N
+option and no
+.Fl a
+option are specified, all attributes are removed.
 The
 .Fl i
-option specifies which entry to update.
+or the
+.Fl b
+option specify which entry to update.
 The possible attributes are
 .Do biosboot Dc ,
 .Do bootme Dc ,
diff -r 3e071adea18e -r 08679e7caae3 sbin/gpt/set.c
--- a/sbin/gpt/set.c    Mon Mar 25 19:24:29 2019 +0000
+++ b/sbin/gpt/set.c    Mon Mar 25 20:15:49 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: set.c,v 1.14 2018/03/19 09:06:20 mlelstv Exp $");
+__RCSID("$NetBSD: set.c,v 1.15 2019/03/25 20:15:49 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -52,7 +52,8 @@
 static int cmd_set(gpt_t, int, char *[]);
 
 static const char *sethelp[] = {
-       "-a attribute -i index",
+       "-a attribute [-i index] [-b startsec]",
+       "-N [-i index] [-b startsec]",
        "-l",
 };
 
@@ -70,14 +71,20 @@
 {
        int ch;
        unsigned int entry = 0;
-       uint64_t attributes = 0;
+       uint64_t attributes = 0, clear = 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:lN")) != -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();
@@ -85,13 +92,28 @@
                case 'l':
                        gpt_attr_help("\t");
                        return 0;
+               case 'N':
+                       clear = ~clear;
+                       break;
                default:
                        return usage();
                }
        }
 
-       if (gpt == NULL || argc != optind)
+       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 || (attributes != 0 && clear != 0))
                return usage();
 
-       return gpt_attr_update(gpt, entry, attributes, 0);
+       return gpt_attr_update(gpt, entry, attributes, clear);
 }



Home | Main Index | Thread Index | Old Index