Import illumos changeset 13608 [1]:

add support for "-t <datatype>" argument to zfs get

References:
https://www.illumos.org/issues/1936

Update zfs(8) manpage in respect of [1].
Fix typo in zfs(8) manpage.

Obtained from:	illumos (issue #1936)
MFC after:	1 week
This commit is contained in:
Martin Matuska 2012-02-23 19:13:19 +00:00
parent 257e5645da
commit dd7f80a359
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=232064
2 changed files with 49 additions and 6 deletions

View File

@ -1,5 +1,5 @@
'\" te
.\" Copyright (c) 2011, Martin Matuska <mm@FreeBSD.org>.
.\" Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>.
.\" All Rights Reserved.
.\"
.\" The contents of this file are subject to the terms of the
@ -18,8 +18,8 @@
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\" Copyright (c) 2010, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 2011 Nexenta Systems, Inc. All rights reserved.
.\" Copyright (c) 2011 by Delphix. All rights reserved.
.\" Copyright (c) 2012 Nexenta Systems, Inc. All Rights Reserved.
.\" Copyright (c) 2011, Pawel Jakub Dawidek <pjd@FreeBSD.org>
.\"
.\" $FreeBSD$
@ -113,6 +113,7 @@
.Op Fl r Ns | Ns Fl d Ar depth
.Op Fl Hp
.Op Fl o Ar all | field Ns Op , Ns Ar ...
.Op Fl t Ar type Ns Op , Ns Ar ...
.Op Fl s Ar source Ns Op , Ns Ar ...
.Ar all | property Ns Op , Ns Ar ...
.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
@ -1753,7 +1754,7 @@ A comma-separated list of types to display, where
is one of
.Sy filesystem , snapshot , volume , No or Sy all .
For example, specifying
.Fl o Cm snapshot
.Fl t Cm snapshot
displays only snapshots.
.It Fl s Ar property
A property for sorting the output by column in ascending order based on the
@ -1811,6 +1812,7 @@ section.
.Op Fl r Ns | Ns Fl d Ar depth
.Op Fl Hp
.Op Fl o Ar all | field Ns Op , Ns Ar ...
.Op Fl t Ar type Ns Op , Ns Ar ...
.Op Fl s Ar source Ns Op , Ns Ar ...
.Ar all | property Ns Op , Ns Ar ...
.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
@ -1871,6 +1873,14 @@ Default values are
The keyword
.Cm all
specifies all columns.
.It Fl t Ar type Ns Op , Ns Ar ...
A comma-separated list of types to display, where
.Ar type
is one of
.Sy filesystem , snapshot , volume , No or Sy all .
For example, specifying
.Fl t Cm snapshot
displays only snapshots.
.It Fl s Ar source Ns Op , Ns Ar ...
A comma-separated list of sources to display. Those properties coming from a
source other than those in this list are ignored. Each source must be one of

View File

@ -227,7 +227,8 @@ get_usage(zfs_help_t idx)
"<snapshot>[%<snapname>][,...]\n"));
case HELP_GET:
return (gettext("\tget [-rHp] [-d max] "
"[-o \"all\" | field[,...]] [-s source[,...]]\n"
"[-o \"all\" | field[,...]] [-t type[,...]] "
"[-s source[,...]]\n"
"\t <\"all\" | property[,...]> "
"[filesystem|volume|snapshot] ...\n"));
case HELP_INHERIT:
@ -1473,6 +1474,7 @@ zfs_do_get(int argc, char **argv)
{
zprop_get_cbdata_t cb = { 0 };
int i, c, flags = ZFS_ITER_ARGS_CAN_BE_PATHS;
int types = ZFS_TYPE_DATASET;
char *value, *fields;
int ret = 0;
int limit = 0;
@ -1489,7 +1491,7 @@ zfs_do_get(int argc, char **argv)
cb.cb_type = ZFS_TYPE_DATASET;
/* check options */
while ((c = getopt(argc, argv, ":d:o:s:rHp")) != -1) {
while ((c = getopt(argc, argv, ":d:o:s:rt:Hp")) != -1) {
switch (c) {
case 'p':
cb.cb_literal = B_TRUE;
@ -1607,6 +1609,37 @@ zfs_do_get(int argc, char **argv)
}
break;
case 't':
types = 0;
flags &= ~ZFS_ITER_PROP_LISTSNAPS;
while (*optarg != '\0') {
static char *type_subopts[] = { "filesystem",
"volume", "snapshot", "all", NULL };
switch (getsubopt(&optarg, type_subopts,
&value)) {
case 0:
types |= ZFS_TYPE_FILESYSTEM;
break;
case 1:
types |= ZFS_TYPE_VOLUME;
break;
case 2:
types |= ZFS_TYPE_SNAPSHOT;
break;
case 3:
types = ZFS_TYPE_DATASET;
break;
default:
(void) fprintf(stderr,
gettext("invalid type '%s'\n"),
value);
usage(B_FALSE);
}
}
break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
@ -1650,7 +1683,7 @@ zfs_do_get(int argc, char **argv)
cb.cb_first = B_TRUE;
/* run for each object */
ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET, NULL,
ret = zfs_for_each(argc, argv, flags, types, NULL,
&cb.cb_proplist, limit, get_callback, &cb);
if (cb.cb_proplist == &fake_name)