Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3863,6 +3863,7 @@ zfs_do_list(int argc, char **argv)
zfs_sort_column_t *sortcol = NULL;
int flags = ZFS_ITER_PROP_LISTSNAPS | ZFS_ITER_ARGS_CAN_BE_PATHS;
nvlist_t *data = NULL;
char full_fields[1024];

struct option long_options[] = {
{"json", no_argument, NULL, 'j'},
Expand All @@ -3875,7 +3876,23 @@ zfs_do_list(int argc, char **argv)
NULL)) != -1) {
switch (c) {
case 'o':
fields = optarg;
if (optarg[0] == '+') {
/* +2 for the , and the null terminator */
if (strlen(fields) + strlen(optarg + 1) + 2 <=
1024) {
(void) snprintf(full_fields,
sizeof (full_fields), "%s,%s",
fields, optarg + 1);
} else {
(void) fprintf(stderr, gettext(
"argument too long for '-o'"
" option.\n"));
usage(B_FALSE);
}
fields = full_fields;
} else {
fields = optarg;
}
break;
case 'p':
cb.cb_literal = B_TRUE;
Expand Down
19 changes: 18 additions & 1 deletion cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7400,6 +7400,7 @@ zpool_do_list(int argc, char **argv)
boolean_t first = B_TRUE;
nvlist_t *data = NULL;
current_prop_type = ZFS_TYPE_POOL;
char full_props[1024];

struct option long_options[] = {
{"json", no_argument, NULL, 'j'},
Expand All @@ -7423,7 +7424,23 @@ zpool_do_list(int argc, char **argv)
cb.cb_name_flags |= VDEV_NAME_FOLLOW_LINKS;
break;
case 'o':
props = optarg;
if (optarg[0] == '+') {
/* +2 for the , and the null terminator */
if (strlen(props) + strlen(optarg + 1) + 2 <=
1024) {
(void) snprintf(full_props,
sizeof (full_props), "%s,%s",
props, optarg + 1);
} else {
(void) fprintf(stderr, gettext(
"argument too long for '-o'"
" option.\n"));
usage(B_FALSE);
}
props = full_props;
} else {
props = optarg;
}
break;
case 'P':
cb.cb_name_flags |= VDEV_NAME_PATH;
Expand Down
7 changes: 7 additions & 0 deletions man/man8/zfs-list.8
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ This is a shortcut for specifying
.Sy usedds , Ns Sy usedrefreserv , Ns Sy usedchild
.Fl t Sy filesystem , Ns Sy volume .
.El
.Pp
The default list of properties can be extended by using
.Sy +property
instead of
.Sy property .
For example,
.Sy zfs list -o +guid .
.It Fl p
Display numbers in parsable
.Pq exact
Expand Down
7 changes: 7 additions & 0 deletions man/man8/zpool-list.8
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ manual page for a list of valid properties.
The default list is
.Sy name , size , allocated , free , checkpoint, expandsize , fragmentation ,
.Sy capacity , dedupratio , health , altroot .
.Pp
The default list of properties can be extended by using
.Sy +property
instead of
.Sy property .
For example,
.Sy zpool list -o +guid .
.It Fl L
Display real paths for vdevs resolving all symbolic links.
This can be used to look up the current block device name regardless of the
Expand Down
Loading