Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Mar 2012 08:22:59 +0000 (UTC)
From:      Martin Matuska <mm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r232328 - stable/9/cddl/contrib/opensolaris/cmd/zfs
Message-ID:  <201203010822.q218MxMt068129@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Thu Mar  1 08:22:59 2012
New Revision: 232328
URL: http://svn.freebsd.org/changeset/base/232328

Log:
  MFC r232064:
  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)

Modified:
  stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
Directory Properties:
  stable/9/cddl/contrib/opensolaris/   (props changed)

Modified: stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==============================================================================
--- stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Thu Mar  1 03:53:07 2012	(r232327)
+++ stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Thu Mar  1 08:22:59 2012	(r232328)
@@ -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 displ
 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

Modified: stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==============================================================================
--- stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Thu Mar  1 03:53:07 2012	(r232327)
+++ stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Thu Mar  1 08:22:59 2012	(r232328)
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203010822.q218MxMt068129>