Skip to content

Commit 57fc597

Browse files
author
Umer Saleem
authored
JSON: fix user properties output for zfs list
This commit fixes JSON output for zfs list when user properties are requested with -o flag. This case needed to be handled specifically since zfs_prop_to_name does not return property name for user properties, instead it is stored in pl->pl_user_prop. Reviewed-by: Ameer Hamza <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Umer Saleem <[email protected]> Closes #16732
1 parent 4a7a0a0 commit 57fc597

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmd/zfs/zfs_main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3761,8 +3761,13 @@ collect_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
37613761
if (cb->cb_json) {
37623762
if (pl->pl_prop == ZFS_PROP_NAME)
37633763
continue;
3764+
const char *prop_name;
3765+
if (pl->pl_prop != ZPROP_USERPROP)
3766+
prop_name = zfs_prop_to_name(pl->pl_prop);
3767+
else
3768+
prop_name = pl->pl_user_prop;
37643769
if (zprop_nvlist_one_property(
3765-
zfs_prop_to_name(pl->pl_prop), propstr,
3770+
prop_name, propstr,
37663771
sourcetype, source, NULL, props,
37673772
cb->cb_json_as_int) != 0)
37683773
nomem();

0 commit comments

Comments
 (0)