diff --git a/man/man8/zfs-program.8 b/man/man8/zfs-program.8 index 617f0aa2cec9..7c58af0d25c2 100644 --- a/man/man8/zfs-program.8 +++ b/man/man8/zfs-program.8 @@ -474,6 +474,13 @@ snapshot (string) .Bd -ragged -compact -offset "xxxx" Must be a valid snapshot. .Ed +.It Em zfs.list.properties(dataset) +An alias for zfs.list.user_properties (see relevant entry). +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Must be a valid filesystem, snapshot, or volume. +.Ed .It Em zfs.list.user_properties(dataset) Iterate through all user properties for the given dataset. For each step of the iteration, output the property name, its value, and its source. diff --git a/module/zfs/zcp_iter.c b/module/zfs/zcp_iter.c index eef0de45d4e4..7600e662dfbb 100644 --- a/module/zfs/zcp_iter.c +++ b/module/zfs/zcp_iter.c @@ -375,6 +375,28 @@ static zcp_list_info_t zcp_user_props_list_info = { } }; +/* + * 'properties' was the initial name for 'user_properties' seen + * above. 'user_properties' is a better name as it distinguishes + * these properties from 'system_properties' which are different. + * In order to avoid breaking compatibility between different + * versions of ZFS, we declare 'properties' as an alias for + * 'user_properties'. + */ +static zcp_list_info_t zcp_props_list_info = { + .name = "properties", + .func = zcp_user_props_list, + .gc = zcp_user_props_list_gc, + .pargs = { + { .za_name = "filesystem | snapshot | volume", + .za_lua_type = LUA_TSTRING}, + {NULL, 0} + }, + .kwargs = { + {NULL, 0} + } +}; + static int zcp_user_props_list(lua_State *state) { @@ -693,6 +715,7 @@ zcp_load_list_lib(lua_State *state) &zcp_children_list_info, &zcp_snapshots_list_info, &zcp_user_props_list_info, + &zcp_props_list_info, &zcp_clones_list_info, &zcp_system_props_list_info, &zcp_bookmarks_list_info, diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/cleanup.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/cleanup.ksh index 281f639a4276..59f69ca8b488 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/cleanup.ksh @@ -17,3 +17,4 @@ . $STF_SUITE/include/libtest.shlib default_cleanup +destroy_pool testpool2 diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/setup.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/setup.ksh index 2516b6b8ad9e..5837bf1a14c7 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/setup.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/setup.ksh @@ -18,4 +18,8 @@ DISK=${DISKS%% *} -default_setup ${DISK} +TESTPOOLDISK=${DISKS%% *} +TESTPOOL2DISK=${DISKS##* } + +default_setup ${TESTPOOLDISK} +create_pool testpool2 ${TESTPOOL2DISK} diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_bookmarks.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_bookmarks.ksh index 4dd57240e8de..7456177f725b 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_bookmarks.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_bookmarks.ksh @@ -101,7 +101,7 @@ EOF # Can't look in a different pool than the one specified on command line log_mustnot_program $TESTPOOL - <<-EOF - zfs.list.bookmarks("rpool") + zfs.list.bookmarks("testpool2") return 0 EOF diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_holds.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_holds.ksh index 7905cb084bf1..2a471bdecbfc 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_holds.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_holds.ksh @@ -102,7 +102,7 @@ EOF # Can't look in a different pool than the one specified on command line log_mustnot_program $TESTPOOL - <<-EOF - zfs.list.holds("rpool") + zfs.list.holds("testpool2") return 0 EOF diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh index 08cca9b021af..34fdbd56d924 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh @@ -20,6 +20,9 @@ # DESCRIPTION: # Listing zfs user properties should work correctly. # +# Note, that this file tests both zfs.list.user_properties +# and it's alias zfs.list.properties. +# verify_runnable "global" @@ -45,6 +48,14 @@ log_must_program $TESTPOOL - <<-EOF assert(n == 0) return 0 EOF +log_must_program $TESTPOOL - <<-EOF + n = 0 + for p in zfs.list.properties("$TESTPOOL/$TESTFS") do + n = n + 1 + end + assert(n == 0) + return 0 +EOF # Add a single user property log_must zfs set $TESTPROP="$TESTVAL" $TESTPOOL/$TESTFS @@ -59,6 +70,16 @@ log_must_program $TESTPOOL - <<-EOF assert(n == 1) return 0 EOF +log_must_program $TESTPOOL - <<-EOF + n = 0 + for p,v in zfs.list.properties("$TESTPOOL/$TESTFS") do + assert(p == "$TESTPROP") + assert(v == "$TESTVAL") + n = n + 1 + end + assert(n == 1) + return 0 +EOF log_must zfs set $TESTPROP1="$TESTVAL1" $TESTPOOL/$TESTFS log_must zfs set $TESTPROP2="$TESTVAL2" $TESTPOOL/$TESTFS @@ -94,5 +115,33 @@ log_must_program $TESTPOOL - <<-EOF a["$TESTPROP4"]) return 0 EOF +log_must_program $TESTPOOL - <<-EOF + a = {} + a["$TESTPROP"] = false + a["$TESTPROP1"] = false + a["$TESTPROP2"] = false + a["$TESTPROP3"] = false + a["$TESTPROP4"] = false + m = {} + m["$TESTPROP"] = "$TESTVAL" + m["$TESTPROP1"] = "$TESTVAL1" + m["$TESTPROP2"] = "$TESTVAL2" + m["$TESTPROP3"] = "$TESTVAL3" + m["$TESTPROP4"] = "$TESTVAL4" + n = 0 + for p,v in zfs.list.properties("$TESTPOOL/$TESTFS") do + assert(not a[p]) + a[p] = true + assert(v == m[p]) + n = n + 1 + end + assert(n == 5) + assert(a["$TESTPROP"] and + a["$TESTPROP1"] and + a["$TESTPROP2"] and + a["$TESTPROP3"] and + a["$TESTPROP4"]) + return 0 +EOF log_pass "Listing zfs user properies should work correctly."