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.
20 #include <sys/lua/lua.h>
21 #include <sys/lua/lualib.h>
22 #include <sys/lua/lauxlib.h>
26 #include <sys/dsl_prop.h>
27 #include <sys/dsl_synctask.h>
28 #include <sys/dsl_dataset.h>
29 #include <sys/dsl_dir.h>
30 #include <sys/dmu_objset.h>
31 #include <sys/mntent.h>
32 #include <sys/sunddi.h>
35 #include <sys/zcp_iter.h>
36 #include <sys/zcp_global.h>
37 #include <sys/zfs_ioctl.h>
38 #include <sys/zfs_znode.h>
42 #include <sys/zfs_vfsops.h>
46 get_objset_type(dsl_dataset_t
*ds
, zfs_type_t
*type
)
50 error
= dmu_objset_from_ds(ds
, &os
);
53 if (ds
->ds_is_snapshot
) {
54 *type
= ZFS_TYPE_SNAPSHOT
;
56 switch (os
->os_phys
->os_type
) {
58 *type
= ZFS_TYPE_FILESYSTEM
;
61 *type
= ZFS_TYPE_VOLUME
;
71 * Returns the string name of ds's type in str (a buffer which should be
72 * at least 12 bytes long).
75 get_objset_type_name(dsl_dataset_t
*ds
, char *str
)
79 error
= get_objset_type(ds
, &type
);
83 case ZFS_TYPE_SNAPSHOT
:
84 (void) strcpy(str
, "snapshot");
86 case ZFS_TYPE_FILESYSTEM
:
87 (void) strcpy(str
, "filesystem");
90 (void) strcpy(str
, "volume");
99 * Determines the source of a property given its setpoint and
100 * property type. It pushes the source to the lua stack.
103 get_prop_src(lua_State
*state
, const char *setpoint
, zfs_prop_t prop
)
105 if (zfs_prop_readonly(prop
) || (prop
== ZFS_PROP_VERSION
)) {
109 if (strcmp("", setpoint
) == 0) {
114 (void) lua_pushstring(state
, src
);
119 * Given an error encountered while getting properties, either longjmp's for
120 * a fatal error or pushes nothing to the stack for a non fatal one.
123 zcp_handle_error(lua_State
*state
, const char *dataset_name
,
124 const char *property_name
, int error
)
126 ASSERT3S(error
, !=, 0);
127 if (error
== ENOENT
) {
129 } else if (error
== EINVAL
) {
130 return (luaL_error(state
,
131 "property '%s' is not a valid property on dataset '%s'",
132 property_name
, dataset_name
));
133 } else if (error
== EIO
) {
134 return (luaL_error(state
,
135 "I/O error while retrieving property '%s' on dataset '%s'",
136 property_name
, dataset_name
));
138 return (luaL_error(state
, "unexpected error %d while "
139 "retrieving property '%s' on dataset '%s'",
140 error
, property_name
, dataset_name
));
145 * Look up a user defined property in the zap object. If it exists, push it
146 * and the setpoint onto the stack, otherwise don't push anything.
149 zcp_get_user_prop(lua_State
*state
, dsl_pool_t
*dp
, const char *dataset_name
,
150 const char *property_name
)
154 char setpoint
[ZFS_MAX_DATASET_NAME_LEN
];
156 * zcp_dataset_hold will either successfully return the requested
157 * dataset or throw a lua error and longjmp out of the zfs.get_prop call
160 dsl_dataset_t
*ds
= zcp_dataset_hold(state
, dp
, dataset_name
, FTAG
);
162 return (1); /* not reached; zcp_dataset_hold() longjmp'd */
164 buf
= kmem_alloc(ZAP_MAXVALUELEN
, KM_SLEEP
);
165 error
= dsl_prop_get_ds(ds
, property_name
, 1, ZAP_MAXVALUELEN
,
167 dsl_dataset_rele(ds
, FTAG
);
170 kmem_free(buf
, ZAP_MAXVALUELEN
);
171 return (zcp_handle_error(state
, dataset_name
, property_name
,
174 (void) lua_pushstring(state
, buf
);
175 (void) lua_pushstring(state
, setpoint
);
176 kmem_free(buf
, ZAP_MAXVALUELEN
);
181 * Check if the property we're looking for is stored in the ds_dir. If so,
182 * return it in the 'val' argument. Return 0 on success and ENOENT and if
183 * the property is not present.
186 get_dsl_dir_prop(dsl_dataset_t
*ds
, zfs_prop_t zfs_prop
,
189 dsl_dir_t
*dd
= ds
->ds_dir
;
190 mutex_enter(&dd
->dd_lock
);
192 case ZFS_PROP_USEDSNAP
:
193 *val
= dsl_dir_get_usedsnap(dd
);
195 case ZFS_PROP_USEDCHILD
:
196 *val
= dsl_dir_get_usedchild(dd
);
198 case ZFS_PROP_USEDDS
:
199 *val
= dsl_dir_get_usedds(dd
);
201 case ZFS_PROP_USEDREFRESERV
:
202 *val
= dsl_dir_get_usedrefreserv(dd
);
204 case ZFS_PROP_LOGICALUSED
:
205 *val
= dsl_dir_get_logicalused(dd
);
208 mutex_exit(&dd
->dd_lock
);
211 mutex_exit(&dd
->dd_lock
);
216 * Takes a dataset, a property, a value and that value's setpoint as
217 * found in the ZAP. Checks if the property has been changed in the vfs.
218 * If so, val and setpoint will be overwritten with updated content.
219 * Otherwise, they are left unchanged.
222 get_temporary_prop(dsl_dataset_t
*ds
, zfs_prop_t zfs_prop
, uint64_t *val
,
225 #if !defined(_KERNEL)
234 error
= dmu_objset_from_ds(ds
, &os
);
238 if (dmu_objset_type(os
) != DMU_OST_ZFS
)
241 mutex_enter(&os
->os_user_ptr_lock
);
242 zfvp
= dmu_objset_get_user(os
);
243 mutex_exit(&os
->os_user_ptr_lock
);
251 if (vfsp
->vfs_do_atime
)
252 tmp
= vfsp
->vfs_atime
;
254 case ZFS_PROP_RELATIME
:
255 if (vfsp
->vfs_do_relatime
)
256 tmp
= vfsp
->vfs_relatime
;
258 case ZFS_PROP_DEVICES
:
259 if (vfsp
->vfs_do_devices
)
260 tmp
= vfsp
->vfs_devices
;
263 if (vfsp
->vfs_do_exec
)
264 tmp
= vfsp
->vfs_exec
;
266 case ZFS_PROP_SETUID
:
267 if (vfsp
->vfs_do_setuid
)
268 tmp
= vfsp
->vfs_setuid
;
270 case ZFS_PROP_READONLY
:
271 if (vfsp
->vfs_do_readonly
)
272 tmp
= vfsp
->vfs_readonly
;
275 if (vfsp
->vfs_do_xattr
)
276 tmp
= vfsp
->vfs_xattr
;
278 case ZFS_PROP_NBMAND
:
279 if (vfsp
->vfs_do_nbmand
)
280 tmp
= vfsp
->vfs_nbmand
;
287 (void) strcpy(setpoint
, "temporary");
295 * Check if the property we're looking for is stored at the dsl_dataset or
296 * dsl_dir level. If so, push the property value and source onto the lua stack
297 * and return 0. If it is not present or a failure occurs in lookup, return a
298 * non-zero error value.
301 get_special_prop(lua_State
*state
, dsl_dataset_t
*ds
, const char *dsname
,
307 char *strval
= kmem_alloc(ZAP_MAXVALUELEN
, KM_SLEEP
);
308 char setpoint
[ZFS_MAX_DATASET_NAME_LEN
] =
309 "Internal error - setpoint not determined";
311 zprop_type_t prop_type
= zfs_prop_get_type(zfs_prop
);
312 (void) get_objset_type(ds
, &ds_type
);
315 case ZFS_PROP_REFRATIO
:
316 numval
= dsl_get_refratio(ds
);
319 numval
= dsl_get_used(ds
);
321 case ZFS_PROP_CLONES
: {
322 nvlist_t
*clones
= fnvlist_alloc();
323 error
= get_clones_stat_impl(ds
, clones
);
325 /* push list to lua stack */
326 VERIFY0(zcp_nvlist_to_lua(state
, clones
, NULL
, 0ULL));
328 (void) lua_pushnil(state
);
331 kmem_free(strval
, ZAP_MAXVALUELEN
);
334 case ZFS_PROP_COMPRESSRATIO
:
335 numval
= dsl_get_compressratio(ds
);
337 case ZFS_PROP_CREATION
:
338 numval
= dsl_get_creation(ds
);
340 case ZFS_PROP_REFERENCED
:
341 numval
= dsl_get_referenced(ds
);
343 case ZFS_PROP_AVAILABLE
:
344 numval
= dsl_get_available(ds
);
346 case ZFS_PROP_LOGICALREFERENCED
:
347 numval
= dsl_get_logicalreferenced(ds
);
349 case ZFS_PROP_CREATETXG
:
350 numval
= dsl_get_creationtxg(ds
);
353 numval
= dsl_get_guid(ds
);
355 case ZFS_PROP_UNIQUE
:
356 numval
= dsl_get_unique(ds
);
358 case ZFS_PROP_OBJSETID
:
359 numval
= dsl_get_objsetid(ds
);
361 case ZFS_PROP_ORIGIN
:
362 dsl_dir_get_origin(ds
->ds_dir
, strval
);
364 case ZFS_PROP_USERACCOUNTING
:
365 error
= dmu_objset_from_ds(ds
, &os
);
367 numval
= dmu_objset_userspace_present(os
);
369 case ZFS_PROP_WRITTEN
:
370 error
= dsl_get_written(ds
, &numval
);
373 error
= get_objset_type_name(ds
, strval
);
375 case ZFS_PROP_PREV_SNAP
:
376 error
= dsl_get_prev_snap(ds
, strval
);
379 dsl_dataset_name(ds
, strval
);
381 case ZFS_PROP_MOUNTPOINT
:
382 error
= dsl_get_mountpoint(ds
, dsname
, strval
, setpoint
);
384 case ZFS_PROP_VERSION
:
385 /* should be a snapshot or filesystem */
386 ASSERT(ds_type
!= ZFS_TYPE_VOLUME
);
387 error
= dmu_objset_from_ds(ds
, &os
);
388 /* look in the master node for the version */
390 error
= zap_lookup(os
, MASTER_NODE_OBJ
, ZPL_VERSION_STR
,
391 sizeof (numval
), 1, &numval
);
394 case ZFS_PROP_DEFER_DESTROY
:
395 numval
= dsl_get_defer_destroy(ds
);
397 case ZFS_PROP_USERREFS
:
398 numval
= dsl_get_userrefs(ds
);
400 case ZFS_PROP_FILESYSTEM_COUNT
:
401 error
= dsl_dir_get_filesystem_count(ds
->ds_dir
, &numval
);
402 (void) strcpy(setpoint
, "");
404 case ZFS_PROP_SNAPSHOT_COUNT
:
405 error
= dsl_dir_get_snapshot_count(ds
->ds_dir
, &numval
);
406 (void) strcpy(setpoint
, "");
408 case ZFS_PROP_NUMCLONES
:
409 numval
= dsl_get_numclones(ds
);
411 case ZFS_PROP_INCONSISTENT
:
412 numval
= dsl_get_inconsistent(ds
);
414 case ZFS_PROP_RECEIVE_RESUME_TOKEN
: {
415 char *token
= get_receive_resume_stats_impl(ds
);
417 VERIFY3U(strlcpy(strval
, token
, ZAP_MAXVALUELEN
),
419 if (strcmp(strval
, "") == 0) {
420 char *childval
= get_child_receive_stats(ds
);
422 VERIFY3U(strlcpy(strval
, childval
, ZAP_MAXVALUELEN
),
424 if (strcmp(strval
, "") == 0)
432 case ZFS_PROP_VOLSIZE
:
433 ASSERT(ds_type
== ZFS_TYPE_VOLUME
||
434 ds_type
== ZFS_TYPE_SNAPSHOT
);
435 error
= dmu_objset_from_ds(ds
, &os
);
437 error
= zap_lookup(os
, ZVOL_ZAP_OBJ
, "size",
438 sizeof (numval
), 1, &numval
);
441 (void) strcpy(setpoint
, dsname
);
444 case ZFS_PROP_VOLBLOCKSIZE
: {
445 ASSERT(ds_type
== ZFS_TYPE_VOLUME
);
446 dmu_object_info_t doi
;
447 error
= dmu_objset_from_ds(ds
, &os
);
449 error
= dmu_object_info(os
, ZVOL_OBJ
, &doi
);
451 numval
= doi
.doi_data_block_size
;
456 case ZFS_PROP_KEYSTATUS
:
457 case ZFS_PROP_KEYFORMAT
: {
458 /* provide defaults in case no crypto obj exists */
460 if (zfs_prop
== ZFS_PROP_KEYSTATUS
)
461 numval
= ZFS_KEYSTATUS_NONE
;
463 numval
= ZFS_KEYFORMAT_NONE
;
465 nvlist_t
*nvl
, *propval
;
466 nvl
= fnvlist_alloc();
467 dsl_dataset_crypt_stats(ds
, nvl
);
468 if (nvlist_lookup_nvlist(nvl
, zfs_prop_to_name(zfs_prop
),
472 (void) nvlist_lookup_uint64(propval
, ZPROP_VALUE
,
474 if (nvlist_lookup_string(propval
, ZPROP_SOURCE
,
476 strlcpy(setpoint
, source
, sizeof (setpoint
));
483 /* Did not match these props, check in the dsl_dir */
484 error
= get_dsl_dir_prop(ds
, zfs_prop
, &numval
);
487 kmem_free(strval
, ZAP_MAXVALUELEN
);
492 case PROP_TYPE_NUMBER
: {
493 (void) lua_pushnumber(state
, numval
);
496 case PROP_TYPE_STRING
: {
497 (void) lua_pushstring(state
, strval
);
500 case PROP_TYPE_INDEX
: {
502 error
= zfs_prop_index_to_string(zfs_prop
, numval
, &propval
);
504 kmem_free(strval
, ZAP_MAXVALUELEN
);
507 (void) lua_pushstring(state
, propval
);
511 kmem_free(strval
, ZAP_MAXVALUELEN
);
513 /* Push the source to the stack */
514 get_prop_src(state
, setpoint
, zfs_prop
);
519 * Look up a property and its source in the zap object. If the value is
520 * present and successfully retrieved, push the value and source on the
521 * lua stack and return 0. On failure, return a non-zero error value.
524 get_zap_prop(lua_State
*state
, dsl_dataset_t
*ds
, zfs_prop_t zfs_prop
)
527 char setpoint
[ZFS_MAX_DATASET_NAME_LEN
];
528 char *strval
= kmem_alloc(ZAP_MAXVALUELEN
, KM_SLEEP
);
530 const char *prop_name
= zfs_prop_to_name(zfs_prop
);
531 zprop_type_t prop_type
= zfs_prop_get_type(zfs_prop
);
533 if (prop_type
== PROP_TYPE_STRING
) {
534 /* Push value to lua stack */
535 error
= dsl_prop_get_ds(ds
, prop_name
, 1,
536 ZAP_MAXVALUELEN
, strval
, setpoint
);
538 (void) lua_pushstring(state
, strval
);
540 error
= dsl_prop_get_ds(ds
, prop_name
, sizeof (numval
),
541 1, &numval
, setpoint
);
543 /* Fill in temorary value for prop, if applicable */
544 (void) get_temporary_prop(ds
, zfs_prop
, &numval
, setpoint
);
546 /* Push value to lua stack */
547 if (prop_type
== PROP_TYPE_INDEX
) {
549 error
= zfs_prop_index_to_string(zfs_prop
, numval
,
552 (void) lua_pushstring(state
, propval
);
555 (void) lua_pushnumber(state
, numval
);
558 kmem_free(strval
, ZAP_MAXVALUELEN
);
560 get_prop_src(state
, setpoint
, zfs_prop
);
565 * Determine whether property is valid for a given dataset
568 prop_valid_for_ds(dsl_dataset_t
*ds
, zfs_prop_t zfs_prop
)
573 /* properties not supported */
574 if ((zfs_prop
== ZFS_PROP_ISCSIOPTIONS
) ||
575 (zfs_prop
== ZFS_PROP_MOUNTED
))
578 /* if we want the origin prop, ds must be a clone */
579 if ((zfs_prop
== ZFS_PROP_ORIGIN
) && (!dsl_dir_is_clone(ds
->ds_dir
)))
582 error
= get_objset_type(ds
, &zfs_type
);
585 return (zfs_prop_valid_for_type(zfs_prop
, zfs_type
, B_FALSE
));
589 * Look up a given dataset property. On success return 2, the number of
590 * values pushed to the lua stack (property value and source). On a fatal
591 * error, longjmp. On a non fatal error push nothing.
594 zcp_get_system_prop(lua_State
*state
, dsl_pool_t
*dp
, const char *dataset_name
,
599 * zcp_dataset_hold will either successfully return the requested
600 * dataset or throw a lua error and longjmp out of the zfs.get_prop call
603 dsl_dataset_t
*ds
= zcp_dataset_hold(state
, dp
, dataset_name
, FTAG
);
605 return (1); /* not reached; zcp_dataset_hold() longjmp'd */
607 /* Check that the property is valid for the given dataset */
608 const char *prop_name
= zfs_prop_to_name(zfs_prop
);
609 if (!prop_valid_for_ds(ds
, zfs_prop
)) {
610 dsl_dataset_rele(ds
, FTAG
);
614 /* Check if the property can be accessed directly */
615 error
= get_special_prop(state
, ds
, dataset_name
, zfs_prop
);
617 dsl_dataset_rele(ds
, FTAG
);
618 /* The value and source have been pushed by get_special_prop */
621 if (error
!= ENOENT
) {
622 dsl_dataset_rele(ds
, FTAG
);
623 return (zcp_handle_error(state
, dataset_name
,
627 /* If we were unable to find it, look in the zap object */
628 error
= get_zap_prop(state
, ds
, zfs_prop
);
629 dsl_dataset_rele(ds
, FTAG
);
631 return (zcp_handle_error(state
, dataset_name
,
634 /* The value and source have been pushed by get_zap_prop */
639 static zfs_userquota_prop_t
640 get_userquota_prop(const char *prop_name
)
642 zfs_userquota_prop_t type
;
643 /* Figure out the property type ({user|group}{quota|used}) */
644 for (type
= 0; type
< ZFS_NUM_USERQUOTA_PROPS
; type
++) {
645 if (strncmp(prop_name
, zfs_userquota_prop_prefixes
[type
],
646 strlen(zfs_userquota_prop_prefixes
[type
])) == 0)
653 * Given the name of a zfs_userquota_prop, this function determines the
654 * prop type as well as the numeric group/user ids based on the string
655 * following the '@' in the property name. On success, returns 0. On failure,
656 * returns a non-zero error.
657 * 'domain' must be free'd by caller using strfree()
660 parse_userquota_prop(const char *prop_name
, zfs_userquota_prop_t
*type
,
661 char **domain
, uint64_t *rid
)
663 char *cp
, *end
, *domain_val
;
665 *type
= get_userquota_prop(prop_name
);
666 if (*type
>= ZFS_NUM_USERQUOTA_PROPS
)
670 cp
= strchr(prop_name
, '@') + 1;
671 if (strncmp(cp
, "S-1-", 4) == 0) {
673 * It's a numeric SID (eg "S-1-234-567-89") and we want to
674 * seperate the domain id and the rid
676 int domain_len
= strrchr(cp
, '-') - cp
;
677 domain_val
= kmem_alloc(domain_len
+ 1, KM_SLEEP
);
678 (void) strncpy(domain_val
, cp
, domain_len
);
679 domain_val
[domain_len
] = '\0';
680 cp
+= domain_len
+ 1;
682 (void) ddi_strtoll(cp
, &end
, 10, (longlong_t
*)rid
);
688 /* It's only a user/group ID (eg "12345"), just get the rid */
690 (void) ddi_strtoll(cp
, &end
, 10, (longlong_t
*)rid
);
694 *domain
= domain_val
;
699 * Look up {user|group}{quota|used} property for given dataset. On success
700 * push the value (quota or used amount) and the setpoint. On failure, push
704 zcp_get_userquota_prop(lua_State
*state
, dsl_pool_t
*dp
,
705 const char *dataset_name
, const char *prop_name
)
710 zfs_userquota_prop_t type
;
712 uint64_t rid
, value
= 0;
715 dsl_dataset_t
*ds
= zcp_dataset_hold(state
, dp
, dataset_name
, FTAG
);
717 return (1); /* not reached; zcp_dataset_hold() longjmp'd */
719 error
= parse_userquota_prop(prop_name
, &type
, &domain
, &rid
);
721 error
= dmu_objset_from_ds(ds
, &os
);
723 zfsvfs
= kmem_zalloc(sizeof (zfsvfs_t
), KM_SLEEP
);
724 error
= zfsvfs_create_impl(&zfvp
, zfsvfs
, os
);
726 error
= zfs_userspace_one(zfvp
, type
, domain
,
734 dsl_dataset_rele(ds
, FTAG
);
736 if ((value
== 0) && ((type
== ZFS_PROP_USERQUOTA
) ||
737 (type
== ZFS_PROP_GROUPQUOTA
)))
740 return (zcp_handle_error(state
, dataset_name
,
744 (void) lua_pushnumber(state
, value
);
745 (void) lua_pushstring(state
, dataset_name
);
751 * Determines the name of the snapshot referenced in the written property
752 * name. Returns snapshot name in snap_name, a buffer that must be at least
753 * as large as ZFS_MAX_DATASET_NAME_LEN
756 parse_written_prop(const char *dataset_name
, const char *prop_name
,
759 ASSERT(zfs_prop_written(prop_name
));
760 const char *name
= prop_name
+ ZFS_WRITTEN_PROP_PREFIX_LEN
;
761 if (strchr(name
, '@') == NULL
) {
762 (void) sprintf(snap_name
, "%s@%s", dataset_name
, name
);
764 (void) strcpy(snap_name
, name
);
769 * Look up written@ property for given dataset. On success
770 * push the value and the setpoint. If error is fatal, we will
771 * longjmp, otherwise push nothing.
774 zcp_get_written_prop(lua_State
*state
, dsl_pool_t
*dp
,
775 const char *dataset_name
, const char *prop_name
)
777 char snap_name
[ZFS_MAX_DATASET_NAME_LEN
];
778 uint64_t used
, comp
, uncomp
;
782 parse_written_prop(dataset_name
, prop_name
, snap_name
);
783 dsl_dataset_t
*new = zcp_dataset_hold(state
, dp
, dataset_name
, FTAG
);
785 return (1); /* not reached; zcp_dataset_hold() longjmp'd */
787 error
= dsl_dataset_hold(dp
, snap_name
, FTAG
, &old
);
789 dsl_dataset_rele(new, FTAG
);
790 return (zcp_dataset_hold_error(state
, dp
, snap_name
,
793 error
= dsl_dataset_space_written(old
, new,
794 &used
, &comp
, &uncomp
);
796 dsl_dataset_rele(old
, FTAG
);
797 dsl_dataset_rele(new, FTAG
);
800 return (zcp_handle_error(state
, dataset_name
,
803 (void) lua_pushnumber(state
, used
);
804 (void) lua_pushstring(state
, dataset_name
);
808 static int zcp_get_prop(lua_State
*state
);
809 static zcp_lib_info_t zcp_get_prop_info
= {
811 .func
= zcp_get_prop
,
813 { .za_name
= "dataset", .za_lua_type
= LUA_TSTRING
},
814 { .za_name
= "property", .za_lua_type
= LUA_TSTRING
},
823 zcp_get_prop(lua_State
*state
)
825 const char *dataset_name
;
826 const char *property_name
;
827 dsl_pool_t
*dp
= zcp_run_info(state
)->zri_pool
;
828 zcp_lib_info_t
*libinfo
= &zcp_get_prop_info
;
830 zcp_parse_args(state
, libinfo
->name
, libinfo
->pargs
, libinfo
->kwargs
);
832 dataset_name
= lua_tostring(state
, 1);
833 property_name
= lua_tostring(state
, 2);
835 /* User defined property */
836 if (zfs_prop_user(property_name
)) {
837 return (zcp_get_user_prop(state
, dp
,
838 dataset_name
, property_name
));
840 /* userspace property */
841 if (zfs_prop_userquota(property_name
)) {
843 return (zcp_get_userquota_prop(state
, dp
,
844 dataset_name
, property_name
));
846 return (luaL_error(state
,
847 "user quota properties only supported in kernel mode",
851 /* written@ property */
852 if (zfs_prop_written(property_name
)) {
853 return (zcp_get_written_prop(state
, dp
,
854 dataset_name
, property_name
));
857 zfs_prop_t zfs_prop
= zfs_name_to_prop(property_name
);
858 /* Valid system property */
859 if (zfs_prop
!= ZPROP_INVAL
) {
860 return (zcp_get_system_prop(state
, dp
, dataset_name
,
864 /* Invalid property name */
865 return (luaL_error(state
,
866 "'%s' is not a valid property", property_name
));
870 zcp_load_get_lib(lua_State
*state
)
872 lua_pushcclosure(state
, zcp_get_prop_info
.func
, 0);
873 lua_setfield(state
, -2, zcp_get_prop_info
.name
);