diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 01d93ed92c5a..1b837f0fdfaf 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -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'}, @@ -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; diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index bec3f94d9602..832a5758dd16 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -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'}, @@ -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; diff --git a/man/man8/zfs-list.8 b/man/man8/zfs-list.8 index 42eff94f9762..62aa8a3ec88d 100644 --- a/man/man8/zfs-list.8 +++ b/man/man8/zfs-list.8 @@ -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 diff --git a/man/man8/zpool-list.8 b/man/man8/zpool-list.8 index 106399941f98..fe44f57456e5 100644 --- a/man/man8/zpool-list.8 +++ b/man/man8/zpool-list.8 @@ -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