4 * This file and its contents are supplied under the terms of the
5 * Common Development and Distribution License ("CDDL"), version 1.0.
6 * You may only use this file in accordance with the terms of version
9 * A full copy of the text of the CDDL should have accompanied this
10 * source. A copy of the CDDL is also available via the Internet at
11 * http://www.illumos.org/license/CDDL.
17 * Copyright (c) 2016 by Delphix. All rights reserved.
18 * Copyrigh 2020 Joyent, Inc.
21 #include <sys/lua/lua.h>
22 #include <sys/lua/lualib.h>
23 #include <sys/lua/lauxlib.h>
25 #include <sys/dsl_prop.h>
26 #include <sys/dsl_dir.h>
27 #include <sys/dsl_synctask.h>
28 #include <sys/dsl_dataset.h>
30 #include <sys/zcp_set.h>
31 #include <sys/zcp_iter.h>
32 #include <sys/zcp_global.h>
38 zcp_set_user_prop(lua_State
*state
, dsl_pool_t
*dp
, const char *dsname
,
39 const char *prop_name
, const char *prop_val
, dmu_tx_t
*tx
)
41 dsl_dataset_t
*ds
= zcp_dataset_hold(state
, dp
, dsname
, FTAG
);
43 return; /* not reached; zcp_dataset_hold() longjmp'd */
45 nvlist_t
*nvl
= fnvlist_alloc();
46 fnvlist_add_string(nvl
, prop_name
, prop_val
);
48 dsl_props_set_sync_impl(ds
, ZPROP_SRC_LOCAL
, nvl
, tx
);
51 dsl_dataset_rele(ds
, FTAG
);
55 zcp_set_prop_check(void *arg
, dmu_tx_t
*tx
)
57 zcp_set_prop_arg_t
*args
= arg
;
58 const char *prop_name
= args
->prop
;
59 dsl_props_set_arg_t dpsa
= {
60 .dpsa_dsname
= args
->dsname
,
61 .dpsa_source
= ZPROP_SRC_LOCAL
,
67 * Only user properties are currently supported. When non-user
68 * properties are supported, we will want to use
69 * zfs_valid_proplist() to verify the properties.
71 if (!zfs_prop_user(prop_name
)) {
75 nvl
= fnvlist_alloc();
76 fnvlist_add_string(nvl
, args
->prop
, args
->val
);
77 dpsa
.dpsa_props
= nvl
;
79 ret
= dsl_props_set_check(&dpsa
, tx
);
86 zcp_set_prop_sync(void *arg
, dmu_tx_t
*tx
)
88 zcp_set_prop_arg_t
*args
= arg
;
89 zcp_run_info_t
*ri
= zcp_run_info(args
->state
);
90 dsl_pool_t
*dp
= ri
->zri_pool
;
92 const char *dsname
= args
->dsname
;
93 const char *prop_name
= args
->prop
;
94 const char *prop_val
= args
->val
;
96 if (zfs_prop_user(prop_name
)) {
97 zcp_set_user_prop(args
->state
, dp
, dsname
, prop_name
,