xref: /titanic_52/usr/src/common/zfs/zfs_prop.c (revision 45818ee124adeaaf947698996b4f4c722afc6d1f)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5906d120cSlling  * Common Development and Distribution License (the "License").
6906d120cSlling  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
2227dd1e87SMark Shellenbaum  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23edf345e6SMatthew Ahrens  * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
24a6f561b4SSašo Kiselkov  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25810e43b2SBill Pijewski  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
26fa9e4066Sahrens  */
27fa9e4066Sahrens 
2855da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */
2955da60b9SMark J Musante 
30fa9e4066Sahrens #include <sys/zio.h>
31fa9e4066Sahrens #include <sys/spa.h>
32de8267e0Stimh #include <sys/u8_textprep.h>
33fa9e4066Sahrens #include <sys/zfs_acl.h>
34fa9e4066Sahrens #include <sys/zfs_ioctl.h>
35e7437265Sahrens #include <sys/zfs_znode.h>
36fa9e4066Sahrens 
37fa9e4066Sahrens #include "zfs_prop.h"
38ecd6cf80Smarks #include "zfs_deleg.h"
39fa9e4066Sahrens 
40fa9e4066Sahrens #if defined(_KERNEL)
41fa9e4066Sahrens #include <sys/systm.h>
42fa9e4066Sahrens #else
43fa9e4066Sahrens #include <stdlib.h>
44fa9e4066Sahrens #include <string.h>
45fa9e4066Sahrens #include <ctype.h>
46fa9e4066Sahrens #endif
47fa9e4066Sahrens 
48990b4856Slling static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
49fa9e4066Sahrens 
5014843421SMatthew Ahrens /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
5114843421SMatthew Ahrens const char *zfs_userquota_prop_prefixes[] = {
5214843421SMatthew Ahrens 	"userused@",
5314843421SMatthew Ahrens 	"userquota@",
5414843421SMatthew Ahrens 	"groupused@",
5514843421SMatthew Ahrens 	"groupquota@"
5614843421SMatthew Ahrens };
5714843421SMatthew Ahrens 
58990b4856Slling zprop_desc_t *
59990b4856Slling zfs_prop_get_table(void)
6091ebeef5Sahrens {
61990b4856Slling 	return (zfs_prop_table);
6291ebeef5Sahrens }
6391ebeef5Sahrens 
6491ebeef5Sahrens void
6591ebeef5Sahrens zfs_prop_init(void)
6691ebeef5Sahrens {
67990b4856Slling 	static zprop_index_t checksum_table[] = {
6891ebeef5Sahrens 		{ "on",		ZIO_CHECKSUM_ON },
6991ebeef5Sahrens 		{ "off",	ZIO_CHECKSUM_OFF },
7091ebeef5Sahrens 		{ "fletcher2",	ZIO_CHECKSUM_FLETCHER_2 },
7191ebeef5Sahrens 		{ "fletcher4",	ZIO_CHECKSUM_FLETCHER_4 },
7291ebeef5Sahrens 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
73810e43b2SBill Pijewski 		{ "noparity",	ZIO_CHECKSUM_NOPARITY },
74*45818ee1SMatthew Ahrens 		{ "sha512",	ZIO_CHECKSUM_SHA512 },
75*45818ee1SMatthew Ahrens 		{ "skein",	ZIO_CHECKSUM_SKEIN },
76*45818ee1SMatthew Ahrens 		{ "edonr",	ZIO_CHECKSUM_EDONR },
7791ebeef5Sahrens 		{ NULL }
78fa9e4066Sahrens 	};
79fa9e4066Sahrens 
80b24ab676SJeff Bonwick 	static zprop_index_t dedup_table[] = {
81b24ab676SJeff Bonwick 		{ "on",		ZIO_CHECKSUM_ON },
82b24ab676SJeff Bonwick 		{ "off",	ZIO_CHECKSUM_OFF },
83b24ab676SJeff Bonwick 		{ "verify",	ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
84b24ab676SJeff Bonwick 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
85b24ab676SJeff Bonwick 		{ "sha256,verify",
86b24ab676SJeff Bonwick 				ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
87*45818ee1SMatthew Ahrens 		{ "sha512",	ZIO_CHECKSUM_SHA512 },
88*45818ee1SMatthew Ahrens 		{ "sha512,verify",
89*45818ee1SMatthew Ahrens 				ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY },
90*45818ee1SMatthew Ahrens 		{ "skein",	ZIO_CHECKSUM_SKEIN },
91*45818ee1SMatthew Ahrens 		{ "skein,verify",
92*45818ee1SMatthew Ahrens 				ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY },
93*45818ee1SMatthew Ahrens 		{ "edonr,verify",
94*45818ee1SMatthew Ahrens 				ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY },
95b24ab676SJeff Bonwick 		{ NULL }
96b24ab676SJeff Bonwick 	};
97b24ab676SJeff Bonwick 
98990b4856Slling 	static zprop_index_t compress_table[] = {
9991ebeef5Sahrens 		{ "on",		ZIO_COMPRESS_ON },
10091ebeef5Sahrens 		{ "off",	ZIO_COMPRESS_OFF },
10191ebeef5Sahrens 		{ "lzjb",	ZIO_COMPRESS_LZJB },
10291ebeef5Sahrens 		{ "gzip",	ZIO_COMPRESS_GZIP_6 },	/* gzip default */
10391ebeef5Sahrens 		{ "gzip-1",	ZIO_COMPRESS_GZIP_1 },
10491ebeef5Sahrens 		{ "gzip-2",	ZIO_COMPRESS_GZIP_2 },
10591ebeef5Sahrens 		{ "gzip-3",	ZIO_COMPRESS_GZIP_3 },
10691ebeef5Sahrens 		{ "gzip-4",	ZIO_COMPRESS_GZIP_4 },
10791ebeef5Sahrens 		{ "gzip-5",	ZIO_COMPRESS_GZIP_5 },
10891ebeef5Sahrens 		{ "gzip-6",	ZIO_COMPRESS_GZIP_6 },
10991ebeef5Sahrens 		{ "gzip-7",	ZIO_COMPRESS_GZIP_7 },
11091ebeef5Sahrens 		{ "gzip-8",	ZIO_COMPRESS_GZIP_8 },
11191ebeef5Sahrens 		{ "gzip-9",	ZIO_COMPRESS_GZIP_9 },
112b24ab676SJeff Bonwick 		{ "zle",	ZIO_COMPRESS_ZLE },
113a6f561b4SSašo Kiselkov 		{ "lz4",	ZIO_COMPRESS_LZ4 },
11491ebeef5Sahrens 		{ NULL }
11591ebeef5Sahrens 	};
11691ebeef5Sahrens 
117990b4856Slling 	static zprop_index_t snapdir_table[] = {
11891ebeef5Sahrens 		{ "hidden",	ZFS_SNAPDIR_HIDDEN },
11991ebeef5Sahrens 		{ "visible",	ZFS_SNAPDIR_VISIBLE },
12091ebeef5Sahrens 		{ NULL }
12191ebeef5Sahrens 	};
12291ebeef5Sahrens 
123a3c49ce1SAlbert Lee 	static zprop_index_t acl_mode_table[] = {
124a3c49ce1SAlbert Lee 		{ "discard",	ZFS_ACL_DISCARD },
125a3c49ce1SAlbert Lee 		{ "groupmask",	ZFS_ACL_GROUPMASK },
126a3c49ce1SAlbert Lee 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
12771dbfc28SPaul B. Henson 		{ "restricted", ZFS_ACL_RESTRICTED },
128a3c49ce1SAlbert Lee 		{ NULL }
129a3c49ce1SAlbert Lee 	};
130a3c49ce1SAlbert Lee 
131990b4856Slling 	static zprop_index_t acl_inherit_table[] = {
13291ebeef5Sahrens 		{ "discard",	ZFS_ACL_DISCARD },
13391ebeef5Sahrens 		{ "noallow",	ZFS_ACL_NOALLOW },
134b3d141f8Smarks 		{ "restricted",	ZFS_ACL_RESTRICTED },
13591ebeef5Sahrens 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
136b3d141f8Smarks 		{ "secure",	ZFS_ACL_RESTRICTED }, /* bkwrd compatability */
137d0f3f37eSMark Shellenbaum 		{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
13891ebeef5Sahrens 		{ NULL }
13991ebeef5Sahrens 	};
14091ebeef5Sahrens 
141da6c28aaSamw 	static zprop_index_t case_table[] = {
142da6c28aaSamw 		{ "sensitive",		ZFS_CASE_SENSITIVE },
143da6c28aaSamw 		{ "insensitive",	ZFS_CASE_INSENSITIVE },
144da6c28aaSamw 		{ "mixed",		ZFS_CASE_MIXED },
145da6c28aaSamw 		{ NULL }
146da6c28aaSamw 	};
147da6c28aaSamw 
148990b4856Slling 	static zprop_index_t copies_table[] = {
14991ebeef5Sahrens 		{ "1",		1 },
15091ebeef5Sahrens 		{ "2",		2 },
15191ebeef5Sahrens 		{ "3",		3 },
15291ebeef5Sahrens 		{ NULL }
15391ebeef5Sahrens 	};
15491ebeef5Sahrens 
155de8267e0Stimh 	/*
156de8267e0Stimh 	 * Use the unique flags we have to send to u8_strcmp() and/or
157de8267e0Stimh 	 * u8_textprep() to represent the various normalization property
158de8267e0Stimh 	 * values.
159de8267e0Stimh 	 */
160da6c28aaSamw 	static zprop_index_t normalize_table[] = {
161de8267e0Stimh 		{ "none",	0 },
162de8267e0Stimh 		{ "formD",	U8_TEXTPREP_NFD },
163de8267e0Stimh 		{ "formKC",	U8_TEXTPREP_NFKC },
164de8267e0Stimh 		{ "formC",	U8_TEXTPREP_NFC },
165de8267e0Stimh 		{ "formKD",	U8_TEXTPREP_NFKD },
166da6c28aaSamw 		{ NULL }
167da6c28aaSamw 	};
168da6c28aaSamw 
169990b4856Slling 	static zprop_index_t version_table[] = {
17091ebeef5Sahrens 		{ "1",		1 },
17191ebeef5Sahrens 		{ "2",		2 },
172da6c28aaSamw 		{ "3",		3 },
17314843421SMatthew Ahrens 		{ "4",		4 },
1740a586ceaSMark Shellenbaum 		{ "5",		5 },
17591ebeef5Sahrens 		{ "current",	ZPL_VERSION },
17691ebeef5Sahrens 		{ NULL }
17791ebeef5Sahrens 	};
17891ebeef5Sahrens 
179990b4856Slling 	static zprop_index_t boolean_table[] = {
180e45ce728Sahrens 		{ "off",	0 },
181e45ce728Sahrens 		{ "on",		1 },
182e45ce728Sahrens 		{ NULL }
183e45ce728Sahrens 	};
184e45ce728Sahrens 
185e09fa4daSNeil Perrin 	static zprop_index_t logbias_table[] = {
186e09fa4daSNeil Perrin 		{ "latency",	ZFS_LOGBIAS_LATENCY },
187e09fa4daSNeil Perrin 		{ "throughput",	ZFS_LOGBIAS_THROUGHPUT },
188e09fa4daSNeil Perrin 		{ NULL }
189e09fa4daSNeil Perrin 	};
190e09fa4daSNeil Perrin 
191a227b7f4Shs24103 	static zprop_index_t canmount_table[] = {
192a227b7f4Shs24103 		{ "off",	ZFS_CANMOUNT_OFF },
193a227b7f4Shs24103 		{ "on",		ZFS_CANMOUNT_ON },
194a227b7f4Shs24103 		{ "noauto",	ZFS_CANMOUNT_NOAUTO },
195a227b7f4Shs24103 		{ NULL }
196a227b7f4Shs24103 	};
197a227b7f4Shs24103 
1983baa08fcSek110237 	static zprop_index_t cache_table[] = {
1993baa08fcSek110237 		{ "none",	ZFS_CACHE_NONE },
2003baa08fcSek110237 		{ "metadata",	ZFS_CACHE_METADATA },
2013baa08fcSek110237 		{ "all",	ZFS_CACHE_ALL },
2023baa08fcSek110237 		{ NULL }
2033baa08fcSek110237 	};
2043baa08fcSek110237 
20555da60b9SMark J Musante 	static zprop_index_t sync_table[] = {
20655da60b9SMark J Musante 		{ "standard",	ZFS_SYNC_STANDARD },
20755da60b9SMark J Musante 		{ "always",	ZFS_SYNC_ALWAYS },
20855da60b9SMark J Musante 		{ "disabled",	ZFS_SYNC_DISABLED },
20955da60b9SMark J Musante 		{ NULL }
21055da60b9SMark J Musante 	};
21155da60b9SMark J Musante 
212edf345e6SMatthew Ahrens 	static zprop_index_t redundant_metadata_table[] = {
213edf345e6SMatthew Ahrens 		{ "all",	ZFS_REDUNDANT_METADATA_ALL },
214edf345e6SMatthew Ahrens 		{ "most",	ZFS_REDUNDANT_METADATA_MOST },
215edf345e6SMatthew Ahrens 		{ NULL }
216edf345e6SMatthew Ahrens 	};
217edf345e6SMatthew Ahrens 
21891ebeef5Sahrens 	/* inherit index properties */
219edf345e6SMatthew Ahrens 	zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
220edf345e6SMatthew Ahrens 	    ZFS_REDUNDANT_METADATA_ALL,
221edf345e6SMatthew Ahrens 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
222edf345e6SMatthew Ahrens 	    "all | most", "REDUND_MD",
223edf345e6SMatthew Ahrens 	    redundant_metadata_table);
22455da60b9SMark J Musante 	zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
22555da60b9SMark J Musante 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
22655da60b9SMark J Musante 	    "standard | always | disabled", "SYNC",
22755da60b9SMark J Musante 	    sync_table);
22883d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
22983d7f9feSTom Erickson 	    ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
23083d7f9feSTom Erickson 	    ZFS_TYPE_VOLUME,
231*45818ee1SMatthew Ahrens 	    "on | off | fletcher2 | fletcher4 | sha256 | sha512 | "
232*45818ee1SMatthew Ahrens 	    "skein | edonr", "CHECKSUM", checksum_table);
23383d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
234b24ab676SJeff Bonwick 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
235*45818ee1SMatthew Ahrens 	    "on | off | verify | sha256[,verify], sha512[,verify], "
236*45818ee1SMatthew Ahrens 	    "skein[,verify], edonr,verify", "DEDUP", dedup_table);
23783d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
238e45ce728Sahrens 	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
239e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
240a6f561b4SSašo Kiselkov 	    "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4",
241a6f561b4SSašo Kiselkov 	    "COMPRESS", compress_table);
24283d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
243e45ce728Sahrens 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
244e45ce728Sahrens 	    "hidden | visible", "SNAPDIR", snapdir_table);
245a3c49ce1SAlbert Lee 	zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
246a3c49ce1SAlbert Lee 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
24771dbfc28SPaul B. Henson 	    "discard | groupmask | passthrough | restricted", "ACLMODE",
24871dbfc28SPaul B. Henson 	    acl_mode_table);
24983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
25083d7f9feSTom Erickson 	    ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
251d0f3f37eSMark Shellenbaum 	    "discard | noallow | restricted | passthrough | passthrough-x",
252b3d141f8Smarks 	    "ACLINHERIT", acl_inherit_table);
25383d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
25483d7f9feSTom Erickson 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
25591ebeef5Sahrens 	    "1 | 2 | 3", "COPIES", copies_table);
25683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
2573baa08fcSek110237 	    ZFS_CACHE_ALL, PROP_INHERIT,
2583baa08fcSek110237 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
2593baa08fcSek110237 	    "all | none | metadata", "PRIMARYCACHE", cache_table);
26083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
2613baa08fcSek110237 	    ZFS_CACHE_ALL, PROP_INHERIT,
2623baa08fcSek110237 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
2633baa08fcSek110237 	    "all | none | metadata", "SECONDARYCACHE", cache_table);
26483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
265e09fa4daSNeil Perrin 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
266e09fa4daSNeil Perrin 	    "latency | throughput", "LOGBIAS", logbias_table);
267e45ce728Sahrens 
268e45ce728Sahrens 	/* inherit index (boolean) properties */
26983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
270e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
27183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
272e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
273e45ce728Sahrens 	    boolean_table);
27483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
275e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
276e45ce728Sahrens 	    boolean_table);
27783d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
278e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
279e45ce728Sahrens 	    boolean_table);
28083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
281e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
282e45ce728Sahrens 	    boolean_table);
28383d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
284e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
28583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
286e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
287e45ce728Sahrens 	    boolean_table);
28883d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
289da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
290da6c28aaSamw 	    boolean_table);
29183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
292da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
293da6c28aaSamw 	    boolean_table);
294e45ce728Sahrens 
295e45ce728Sahrens 	/* default index properties */
29683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
29791ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
29819b94df9SMatthew Ahrens 	    "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table);
29983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
300a227b7f4Shs24103 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
301a227b7f4Shs24103 	    "CANMOUNT", canmount_table);
302e45ce728Sahrens 
303e45ce728Sahrens 	/* readonly index (boolean) properties */
30483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
305990b4856Slling 	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
30683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
307842727c2SChris Kirby 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
308842727c2SChris Kirby 	    boolean_table);
309e45ce728Sahrens 
310da6c28aaSamw 	/* set once index properties */
31183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
312da6c28aaSamw 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
313da6c28aaSamw 	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
314da6c28aaSamw 	    normalize_table);
31583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
31683d7f9feSTom Erickson 	    ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
31783d7f9feSTom Erickson 	    ZFS_TYPE_SNAPSHOT,
318da6c28aaSamw 	    "sensitive | insensitive | mixed", "CASE", case_table);
319da6c28aaSamw 
320da6c28aaSamw 	/* set once index (boolean) properties */
32183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
322da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
323da6c28aaSamw 	    "on | off", "UTF8ONLY", boolean_table);
324da6c28aaSamw 
32591ebeef5Sahrens 	/* string properties */
32683d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
32791ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
32819b94df9SMatthew Ahrens 	zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
32919b94df9SMatthew Ahrens 	    ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES");
33083d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
33183d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
33283d7f9feSTom Erickson 	    "MOUNTPOINT");
33383d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
33483d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options",
33583d7f9feSTom Erickson 	    "SHARENFS");
33683d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
33778f17100SMatthew Ahrens 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
33878f17100SMatthew Ahrens 	    "filesystem | volume | snapshot | bookmark", "TYPE");
33983d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
34083d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
34183d7f9feSTom Erickson 	    "on | off | sharemgr(1M) options", "SHARESMB");
34283d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
34383d7f9feSTom Erickson 	    ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
34483d7f9feSTom Erickson 	    "<sensitivity label>", "MLSLABEL");
34591ebeef5Sahrens 
34691ebeef5Sahrens 	/* readonly number properties */
34783d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
348990b4856Slling 	    ZFS_TYPE_DATASET, "<size>", "USED");
34983d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
350990b4856Slling 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
35183d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
35283d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER");
35383d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
354990b4856Slling 	    PROP_READONLY, ZFS_TYPE_DATASET,
35591ebeef5Sahrens 	    "<1.00x or higher if compressed>", "RATIO");
356187d6ac0SMatt Ahrens 	zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
357187d6ac0SMatt Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET,
358187d6ac0SMatt Ahrens 	    "<1.00x or higher if compressed>", "REFRATIO");
35983d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
360c1449561SEric Taylor 	    ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
361da6c28aaSamw 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK");
36283d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
36383d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
36483d7f9feSTom Erickson 	    "USEDSNAP");
36583d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
36683d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
36783d7f9feSTom Erickson 	    "USEDDS");
36883d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
36983d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
37083d7f9feSTom Erickson 	    "USEDCHILD");
37183d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
37274e7dc98SMatthew Ahrens 	    PROP_READONLY,
37374e7dc98SMatthew Ahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
37483d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
375842727c2SChris Kirby 	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
37619b94df9SMatthew Ahrens 	zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
37719b94df9SMatthew Ahrens 	    ZFS_TYPE_DATASET, "<size>", "WRITTEN");
37877372cb0SMatthew Ahrens 	zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
37977372cb0SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LUSED");
38077372cb0SMatthew Ahrens 	zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
38177372cb0SMatthew Ahrens 	    0, PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LREFER");
38291ebeef5Sahrens 
38391ebeef5Sahrens 	/* default number properties */
38483d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
38591ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
38683d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
38783d7f9feSTom Erickson 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
38883d7f9feSTom Erickson 	    "<size> | none", "RESERV");
38983d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
39091ebeef5Sahrens 	    ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
39183d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
392a9799022Sck153898 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
39383d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
394a9799022Sck153898 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
395a9799022Sck153898 	    "<size> | none", "REFRESERV");
396a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
397a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
398a2afb611SJerry Jelinek 	    "<count> | none", "FSLIMIT");
399a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
400a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
401a2afb611SJerry Jelinek 	    "<count> | none", "SSLIMIT");
402a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
403a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
404a2afb611SJerry Jelinek 	    "<count>", "FSCOUNT");
405a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
406a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
407a2afb611SJerry Jelinek 	    "<count>", "SSCOUNT");
40891ebeef5Sahrens 
40991ebeef5Sahrens 	/* inherit number properties */
41083d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
411b5152584SMatthew Ahrens 	    SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,
412b5152584SMatthew Ahrens 	    ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE");
41391ebeef5Sahrens 
41491ebeef5Sahrens 	/* hidden properties */
41583d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
41678f17100SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "CREATETXG");
41783d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
418b24ab676SJeff Bonwick 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
41983d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
42078f17100SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME");
42183d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
42283d7f9feSTom Erickson 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
42383d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
424478ed9adSEric Taylor 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
425478ed9adSEric Taylor 	    "STMF_SBD_LU");
42683d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER,
42778f17100SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "GUID");
42883d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
429b24ab676SJeff Bonwick 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
430b24ab676SJeff Bonwick 	    "USERACCOUNTING");
43183d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
432b24ab676SJeff Bonwick 	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
43383d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
4341d713200SEric Schrock 	    PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
435ca48f36fSKeith M Wesolowski 	zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
436ca48f36fSKeith M Wesolowski 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT");
437b461c746SMatthew Ahrens 	zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
438b461c746SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP");
43991ebeef5Sahrens 
44091ebeef5Sahrens 	/* oddball properties */
44183d7f9feSTom Erickson 	zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
44278f17100SMatthew Ahrens 	    NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
44391ebeef5Sahrens 	    "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
44491ebeef5Sahrens }
44591ebeef5Sahrens 
446b1b8ab34Slling boolean_t
447990b4856Slling zfs_prop_delegatable(zfs_prop_t prop)
448b1b8ab34Slling {
449990b4856Slling 	zprop_desc_t *pd = &zfs_prop_table[prop];
4504201a95eSRic Aleshire 
4514201a95eSRic Aleshire 	/* The mlslabel property is never delegatable. */
4524201a95eSRic Aleshire 	if (prop == ZFS_PROP_MLSLABEL)
4534201a95eSRic Aleshire 		return (B_FALSE);
4544201a95eSRic Aleshire 
455990b4856Slling 	return (pd->pd_attr != PROP_READONLY);
456b1b8ab34Slling }
457b1b8ab34Slling 
458b1b8ab34Slling /*
459b1b8ab34Slling  * Given a zfs dataset property name, returns the corresponding property ID.
460fa9e4066Sahrens  */
461fa9e4066Sahrens zfs_prop_t
462fa9e4066Sahrens zfs_name_to_prop(const char *propname)
463fa9e4066Sahrens {
464990b4856Slling 	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
465b1b8ab34Slling }
466fa9e4066Sahrens 
467fa9e4066Sahrens /*
468e9dbad6fSeschrock  * For user property names, we allow all lowercase alphanumeric characters, plus
469e9dbad6fSeschrock  * a few useful punctuation characters.
470e9dbad6fSeschrock  */
471e9dbad6fSeschrock static int
472e9dbad6fSeschrock valid_char(char c)
473e9dbad6fSeschrock {
474e9dbad6fSeschrock 	return ((c >= 'a' && c <= 'z') ||
475e9dbad6fSeschrock 	    (c >= '0' && c <= '9') ||
476e9dbad6fSeschrock 	    c == '-' || c == '_' || c == '.' || c == ':');
477e9dbad6fSeschrock }
478e9dbad6fSeschrock 
479e9dbad6fSeschrock /*
480e9dbad6fSeschrock  * Returns true if this is a valid user-defined property (one with a ':').
481e9dbad6fSeschrock  */
482e9dbad6fSeschrock boolean_t
483e9dbad6fSeschrock zfs_prop_user(const char *name)
484e9dbad6fSeschrock {
485e9dbad6fSeschrock 	int i;
486e9dbad6fSeschrock 	char c;
487e9dbad6fSeschrock 	boolean_t foundsep = B_FALSE;
488e9dbad6fSeschrock 
489e9dbad6fSeschrock 	for (i = 0; i < strlen(name); i++) {
490e9dbad6fSeschrock 		c = name[i];
491e9dbad6fSeschrock 		if (!valid_char(c))
492e9dbad6fSeschrock 			return (B_FALSE);
493e9dbad6fSeschrock 		if (c == ':')
494e9dbad6fSeschrock 			foundsep = B_TRUE;
495e9dbad6fSeschrock 	}
496e9dbad6fSeschrock 
497e9dbad6fSeschrock 	if (!foundsep)
498e9dbad6fSeschrock 		return (B_FALSE);
499e9dbad6fSeschrock 
500e9dbad6fSeschrock 	return (B_TRUE);
501e9dbad6fSeschrock }
502e9dbad6fSeschrock 
503e9dbad6fSeschrock /*
50414843421SMatthew Ahrens  * Returns true if this is a valid userspace-type property (one with a '@').
50514843421SMatthew Ahrens  * Note that after the @, any character is valid (eg, another @, for SID
50614843421SMatthew Ahrens  * user@domain).
50714843421SMatthew Ahrens  */
50814843421SMatthew Ahrens boolean_t
50914843421SMatthew Ahrens zfs_prop_userquota(const char *name)
51014843421SMatthew Ahrens {
51114843421SMatthew Ahrens 	zfs_userquota_prop_t prop;
51214843421SMatthew Ahrens 
51314843421SMatthew Ahrens 	for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
51414843421SMatthew Ahrens 		if (strncmp(name, zfs_userquota_prop_prefixes[prop],
51514843421SMatthew Ahrens 		    strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
51614843421SMatthew Ahrens 			return (B_TRUE);
51714843421SMatthew Ahrens 		}
51814843421SMatthew Ahrens 	}
51914843421SMatthew Ahrens 
52014843421SMatthew Ahrens 	return (B_FALSE);
52114843421SMatthew Ahrens }
52214843421SMatthew Ahrens 
52314843421SMatthew Ahrens /*
52419b94df9SMatthew Ahrens  * Returns true if this is a valid written@ property.
52519b94df9SMatthew Ahrens  * Note that after the @, any character is valid (eg, another @, for
52619b94df9SMatthew Ahrens  * written@pool/fs@origin).
52719b94df9SMatthew Ahrens  */
52819b94df9SMatthew Ahrens boolean_t
52919b94df9SMatthew Ahrens zfs_prop_written(const char *name)
53019b94df9SMatthew Ahrens {
53119b94df9SMatthew Ahrens 	static const char *prefix = "written@";
53219b94df9SMatthew Ahrens 	return (strncmp(name, prefix, strlen(prefix)) == 0);
53319b94df9SMatthew Ahrens }
53419b94df9SMatthew Ahrens 
53519b94df9SMatthew Ahrens /*
536990b4856Slling  * Tables of index types, plus functions to convert between the user view
537990b4856Slling  * (strings) and internal representation (uint64_t).
538fa9e4066Sahrens  */
539990b4856Slling int
540990b4856Slling zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
541fa9e4066Sahrens {
542990b4856Slling 	return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
543990b4856Slling }
544990b4856Slling 
545990b4856Slling int
546990b4856Slling zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
547990b4856Slling {
548990b4856Slling 	return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
549990b4856Slling }
550990b4856Slling 
551b24ab676SJeff Bonwick uint64_t
552b24ab676SJeff Bonwick zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
553b24ab676SJeff Bonwick {
554b24ab676SJeff Bonwick 	return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
555b24ab676SJeff Bonwick }
556b24ab676SJeff Bonwick 
557990b4856Slling /*
558990b4856Slling  * Returns TRUE if the property applies to any of the given dataset types.
559990b4856Slling  */
5604853e976Sgw25295 boolean_t
561990b4856Slling zfs_prop_valid_for_type(int prop, zfs_type_t types)
562990b4856Slling {
563990b4856Slling 	return (zprop_valid_for_type(prop, types));
564990b4856Slling }
565990b4856Slling 
566990b4856Slling zprop_type_t
567990b4856Slling zfs_prop_get_type(zfs_prop_t prop)
568990b4856Slling {
569990b4856Slling 	return (zfs_prop_table[prop].pd_proptype);
570990b4856Slling }
571990b4856Slling 
572990b4856Slling /*
573990b4856Slling  * Returns TRUE if the property is readonly.
574990b4856Slling  */
575990b4856Slling boolean_t
576990b4856Slling zfs_prop_readonly(zfs_prop_t prop)
577990b4856Slling {
578da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
579da6c28aaSamw 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
580da6c28aaSamw }
581da6c28aaSamw 
582da6c28aaSamw /*
583da6c28aaSamw  * Returns TRUE if the property is only allowed to be set once.
584da6c28aaSamw  */
585da6c28aaSamw boolean_t
586da6c28aaSamw zfs_prop_setonce(zfs_prop_t prop)
587da6c28aaSamw {
588da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_ONETIME);
589fa9e4066Sahrens }
590fa9e4066Sahrens 
5913d7072f8Seschrock const char *
592990b4856Slling zfs_prop_default_string(zfs_prop_t prop)
5933d7072f8Seschrock {
5943d7072f8Seschrock 	return (zfs_prop_table[prop].pd_strdefault);
5953d7072f8Seschrock }
5963d7072f8Seschrock 
597fa9e4066Sahrens uint64_t
598fa9e4066Sahrens zfs_prop_default_numeric(zfs_prop_t prop)
599fa9e4066Sahrens {
600fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_numdefault);
601fa9e4066Sahrens }
602fa9e4066Sahrens 
603fa9e4066Sahrens /*
604b1b8ab34Slling  * Given a dataset property ID, returns the corresponding name.
6053d7072f8Seschrock  * Assuming the zfs dataset property ID is valid.
606fa9e4066Sahrens  */
607fa9e4066Sahrens const char *
608fa9e4066Sahrens zfs_prop_to_name(zfs_prop_t prop)
609fa9e4066Sahrens {
610fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_name);
611fa9e4066Sahrens }
612fa9e4066Sahrens 
613fa9e4066Sahrens /*
614fa9e4066Sahrens  * Returns TRUE if the property is inheritable.
615fa9e4066Sahrens  */
616990b4856Slling boolean_t
617fa9e4066Sahrens zfs_prop_inheritable(zfs_prop_t prop)
618fa9e4066Sahrens {
619da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
620da6c28aaSamw 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
621e9dbad6fSeschrock }
622e9dbad6fSeschrock 
623acd76fe5Seschrock #ifndef _KERNEL
624acd76fe5Seschrock 
625fa9e4066Sahrens /*
626fa9e4066Sahrens  * Returns a string describing the set of acceptable values for the given
627b1b8ab34Slling  * zfs property, or NULL if it cannot be set.
628fa9e4066Sahrens  */
629fa9e4066Sahrens const char *
630fa9e4066Sahrens zfs_prop_values(zfs_prop_t prop)
631fa9e4066Sahrens {
632fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_values);
633fa9e4066Sahrens }
634fa9e4066Sahrens 
635fa9e4066Sahrens /*
636fa9e4066Sahrens  * Returns TRUE if this property is a string type.  Note that index types
637fa9e4066Sahrens  * (compression, checksum) are treated as strings in userland, even though they
638fa9e4066Sahrens  * are stored numerically on disk.
639fa9e4066Sahrens  */
640fa9e4066Sahrens int
641fa9e4066Sahrens zfs_prop_is_string(zfs_prop_t prop)
642fa9e4066Sahrens {
64391ebeef5Sahrens 	return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
64491ebeef5Sahrens 	    zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
645fa9e4066Sahrens }
646fa9e4066Sahrens 
647fa9e4066Sahrens /*
648fa9e4066Sahrens  * Returns the column header for the given property.  Used only in
649fa9e4066Sahrens  * 'zfs list -o', but centralized here with the other property information.
650fa9e4066Sahrens  */
651fa9e4066Sahrens const char *
652fa9e4066Sahrens zfs_prop_column_name(zfs_prop_t prop)
653fa9e4066Sahrens {
654fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_colname);
655fa9e4066Sahrens }
656fa9e4066Sahrens 
657fa9e4066Sahrens /*
658e9dbad6fSeschrock  * Returns whether the given property should be displayed right-justified for
659e9dbad6fSeschrock  * 'zfs list'.
660fa9e4066Sahrens  */
661e9dbad6fSeschrock boolean_t
662e9dbad6fSeschrock zfs_prop_align_right(zfs_prop_t prop)
663fa9e4066Sahrens {
664e9dbad6fSeschrock 	return (zfs_prop_table[prop].pd_rightalign);
665fa9e4066Sahrens }
666da6c28aaSamw 
667fa9e4066Sahrens #endif
668