Project

General

Profile

Feature #1936 » zfs-get-types.patch

Andrew Stormont, 2011-12-28 09:58 AM

View differences:

usr/src/cmd/zfs/zfs_main.c Tue Nov 29 11:46:16 2011 +1100 → usr/src/cmd/zfs/zfs_main.c Wed Dec 21 21:43:13 2011 +0000
216 216
		    "<filesystem|volume>@<snap>[%<snap>][,...]\n"));
217 217
	case HELP_GET:
218 218
		return (gettext("\tget [-rHp] [-d max] "
219
		    "[-o \"all\" | field[,...]] [-s source[,...]]\n"
219
		    "[-o \"all\" | field[,...]] [-t type[,...]] [-s source[,...]]\n"
220 220
		    "\t    <\"all\" | property[,...]> "
221 221
		    "[filesystem|volume|snapshot] ...\n"));
222 222
	case HELP_INHERIT:
......
1457 1457
{
1458 1458
	zprop_get_cbdata_t cb = { 0 };
1459 1459
	int i, c, flags = ZFS_ITER_ARGS_CAN_BE_PATHS;
1460
	int types = ZFS_TYPE_DATASET;
1460 1461
	char *value, *fields;
1461 1462
	int ret;
1462 1463
	int limit = 0;
......
1473 1474
	cb.cb_type = ZFS_TYPE_DATASET;
1474 1475

  
1475 1476
	/* check options */
1476
	while ((c = getopt(argc, argv, ":d:o:s:rHp")) != -1) {
1477
	while ((c = getopt(argc, argv, ":d:o:s:rt:Hp")) != -1) {
1477 1478
		switch (c) {
1478 1479
		case 'p':
1479 1480
			cb.cb_literal = B_TRUE;
......
1591 1592
			}
1592 1593
			break;
1593 1594

  
1595
		case 't':
1596
			types = 0;
1597
			flags &= ~ZFS_ITER_PROP_LISTSNAPS;
1598
			while (*optarg != '\0') {
1599
				static char *type_subopts[] = { "filesystem",
1600
				    "volume", "snapshot", "all", NULL };
1601

  
1602
				switch (getsubopt(&optarg, type_subopts,
1603
				    &value)) {
1604
				case 0:
1605
					types |= ZFS_TYPE_FILESYSTEM;
1606
					break;
1607
				case 1:
1608
					types |= ZFS_TYPE_VOLUME;
1609
					break;
1610
				case 2:
1611
					types |= ZFS_TYPE_SNAPSHOT;
1612
					break;
1613
				case 3:
1614
					types = ZFS_TYPE_DATASET;
1615
					break;
1616

  
1617
				default:
1618
					(void) fprintf(stderr,
1619
					    gettext("invalid type '%s'\n"),
1620
					    value);
1621
					usage(B_FALSE);
1622
				}
1623
			}
1624
			break;
1625

  
1594 1626
		case '?':
1595 1627
			(void) fprintf(stderr, gettext("invalid option '%c'\n"),
1596 1628
			    optopt);
......
1634 1666
	cb.cb_first = B_TRUE;
1635 1667

  
1636 1668
	/* run for each object */
1637
	ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET, NULL,
1669
	ret = zfs_for_each(argc, argv, flags, types, NULL,
1638 1670
	    &cb.cb_proplist, limit, get_callback, &cb);
1639 1671

  
1640 1672
	if (cb.cb_proplist == &fake_name)
usr/src/man/man1m/zfs.1m Tue Nov 29 11:46:16 2011 +1100 → usr/src/man/man1m/zfs.1m Wed Dec 21 21:43:30 2011 +0000
85 85

  
86 86
.LP
87 87
.nf
88
\fBzfs\fR \fBget\fR [\fB-r\fR|\fB-d\fR \fIdepth\fR][\fB-Hp\fR][\fB-o\fR \fIfield\fR[,...]] [\fB-s\fR \fIsource\fR[,...]]
88
\fBzfs\fR \fBget\fR [\fB-r\fR|\fB-d\fR \fIdepth\fR][\fB-Hp\fR][\fB-o\fR \fIfield\fR[,...]] [\fB-t\fR \fItype\fR[,...]] [\fB-s\fR \fIsource\fR[,...]]
89 89
     "\fIall\fR" | \fIproperty\fR[,...] \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR ...
90 90
.fi
91 91

  
    (1-1/1)