Module Name: src
Committed By: martin
Date: Sun Mar 24 13:45:35 UTC 2019
Modified Files:
src/sbin/gpt: gpt.8 show.c
Log Message:
Make the "show" subcommand accept -b startsec to identify a partition
(very usefull for scripts and other robotic callers).
To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.42 -r1.43 src/sbin/gpt/show.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.64 src/sbin/gpt/gpt.8:1.65
--- src/sbin/gpt/gpt.8:1.64 Sun Mar 24 13:31:00 2019
+++ src/sbin/gpt/gpt.8 Sun Mar 24 13:45:35 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.64 2019/03/24 13:31:00 martin Exp $
+.\" $NetBSD: gpt.8,v 1.65 2019/03/24 13:45:35 martin Exp $
.\"
.\" Copyright (c) 2002 Marcel Moolenaar
.\" All rights reserved.
@@ -466,7 +466,7 @@ See above for a description of these opt
Partitions are removed by clearing the partition type.
No other information is changed.
.\" ==== resize ====
-.It Nm Ic resize [ Fl i Ar index | Fl b Ar startsec ] Oo Fl a Ar alignment Oc \
+.It Nm Ic resize Oo Fl i Ar index Oc Oo Fl b Ar startsec Oc Oo Fl a Ar alignment Oc \
Oo Fl s Ar size Oc
The
.Ic resize
@@ -592,7 +592,7 @@ They may be used by
.Nx
in the future.
.\" ==== show ====
-.It Nm Ic show Oo Fl aglu Oc Oo Fl i Ar index Oc
+.It Nm Ic show Oo Fl aglu Oc Oo Fl i Ar index Oc Oo Fl b Ar startsec Oc
The
.Ic show
command displays the current partitioning on the listed devices and gives
@@ -611,6 +611,8 @@ option the GPT partition type is display
user friendly form.
With the
.Fl i
+or the
+.Fl b
option, all the details of a particular GPT partition will be displayed.
The format of this display is subject to change.
With the
Index: src/sbin/gpt/show.c
diff -u src/sbin/gpt/show.c:1.42 src/sbin/gpt/show.c:1.43
--- src/sbin/gpt/show.c:1.42 Sun Mar 3 03:20:42 2019
+++ src/sbin/gpt/show.c Sun Mar 24 13:45:35 2019
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: show.c,v 1.42 2019/03/03 03:20:42 jnemeth Exp $");
+__RCSID("$NetBSD: show.c,v 1.43 2019/03/24 13:45:35 martin Exp $");
#endif
#include <sys/bootblock.h>
@@ -317,8 +317,10 @@ cmd_show(gpt_t gpt, int argc, char *argv
int ch;
int xshow = 0;
unsigned int entry = 0;
+ off_t start = 0;
+ map_t m;
- while ((ch = getopt(argc, argv, "gi:lua")) != -1) {
+ while ((ch = getopt(argc, argv, "gi:b:lua")) != -1) {
switch(ch) {
case 'a':
xshow |= SHOW_ALL;
@@ -330,6 +332,10 @@ cmd_show(gpt_t gpt, int argc, char *argv
if (gpt_uint_get(gpt, &entry) == -1)
return usage();
break;
+ case 'b':
+ if (gpt_human_get(gpt, &start) == -1)
+ return usage();
+ break;
case 'l':
xshow |= SHOW_LABEL;
break;
@@ -350,5 +356,17 @@ cmd_show(gpt_t gpt, int argc, char *argv
if (xshow & SHOW_ALL)
return show_all(gpt);
+ 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;
+ }
+ }
+
return entry > 0 ? show_one(gpt, entry) : show(gpt, xshow);
}