From 189579f88f357de3a7a75fb6b528d607555266cd Mon Sep 17 00:00:00 2001 From: mm Date: Thu, 1 Mar 2012 08:22:59 +0000 Subject: [PATCH 077/175] MFC r232064: Import illumos changeset 13608 [1]: add support for "-t " 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) git-svn-id: http://svn.freebsd.org/base/stable/9@232328 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f (cherry picked from commit 072d547808a500ca1a80de36a87ab631b7d6606a) Signed-off-by: Xin Li --- cddl/contrib/opensolaris/cmd/zfs/zfs.8 | 16 ++++++++--- cddl/contrib/opensolaris/cmd/zfs/zfs_main.c | 39 ++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 index d1793ad..58e986f 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -1,5 +1,5 @@ '\" te -.\" Copyright (c) 2011, Martin Matuska . +.\" Copyright (c) 2012, Martin Matuska . .\" 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 .\" .\" $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 diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c index 30434cc..410246a 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c @@ -227,7 +227,8 @@ get_usage(zfs_help_t idx) "[%][,...]\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) -- 1.7.9.4