From 5821cd96071ad1757f3b79ad982593cd2bcce321 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Fri, 8 Nov 2024 00:31:14 +0500 Subject: [PATCH] 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 Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Umer Saleem Closes #16732 --- cmd/zfs/zfs_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index f5d2a744df2..55d49390aa0 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -3761,8 +3761,13 @@ collect_dataset(zfs_handle_t *zhp, list_cbdata_t *cb) if (cb->cb_json) { if (pl->pl_prop == ZFS_PROP_NAME) continue; + const char *prop_name; + if (pl->pl_prop != ZPROP_USERPROP) + prop_name = zfs_prop_to_name(pl->pl_prop); + else + prop_name = pl->pl_user_prop; if (zprop_nvlist_one_property( - zfs_prop_to_name(pl->pl_prop), propstr, + prop_name, propstr, sourcetype, source, NULL, props, cb->cb_json_as_int) != 0) nomem();