xref: /titanic_52/usr/src/common/zfs/zfs_prop.c (revision b461c7460e5e77cf65f00151162e654220c6e2fb)
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 },
7491ebeef5Sahrens 		{ NULL }
75fa9e4066Sahrens 	};
76fa9e4066Sahrens 
77b24ab676SJeff Bonwick 	static zprop_index_t dedup_table[] = {
78b24ab676SJeff Bonwick 		{ "on",		ZIO_CHECKSUM_ON },
79b24ab676SJeff Bonwick 		{ "off",	ZIO_CHECKSUM_OFF },
80b24ab676SJeff Bonwick 		{ "verify",	ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
81b24ab676SJeff Bonwick 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
82b24ab676SJeff Bonwick 		{ "sha256,verify",
83b24ab676SJeff Bonwick 				ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
84b24ab676SJeff Bonwick 		{ NULL }
85b24ab676SJeff Bonwick 	};
86b24ab676SJeff Bonwick 
87990b4856Slling 	static zprop_index_t compress_table[] = {
8891ebeef5Sahrens 		{ "on",		ZIO_COMPRESS_ON },
8991ebeef5Sahrens 		{ "off",	ZIO_COMPRESS_OFF },
9091ebeef5Sahrens 		{ "lzjb",	ZIO_COMPRESS_LZJB },
9191ebeef5Sahrens 		{ "gzip",	ZIO_COMPRESS_GZIP_6 },	/* gzip default */
9291ebeef5Sahrens 		{ "gzip-1",	ZIO_COMPRESS_GZIP_1 },
9391ebeef5Sahrens 		{ "gzip-2",	ZIO_COMPRESS_GZIP_2 },
9491ebeef5Sahrens 		{ "gzip-3",	ZIO_COMPRESS_GZIP_3 },
9591ebeef5Sahrens 		{ "gzip-4",	ZIO_COMPRESS_GZIP_4 },
9691ebeef5Sahrens 		{ "gzip-5",	ZIO_COMPRESS_GZIP_5 },
9791ebeef5Sahrens 		{ "gzip-6",	ZIO_COMPRESS_GZIP_6 },
9891ebeef5Sahrens 		{ "gzip-7",	ZIO_COMPRESS_GZIP_7 },
9991ebeef5Sahrens 		{ "gzip-8",	ZIO_COMPRESS_GZIP_8 },
10091ebeef5Sahrens 		{ "gzip-9",	ZIO_COMPRESS_GZIP_9 },
101b24ab676SJeff Bonwick 		{ "zle",	ZIO_COMPRESS_ZLE },
102a6f561b4SSašo Kiselkov 		{ "lz4",	ZIO_COMPRESS_LZ4 },
10391ebeef5Sahrens 		{ NULL }
10491ebeef5Sahrens 	};
10591ebeef5Sahrens 
106990b4856Slling 	static zprop_index_t snapdir_table[] = {
10791ebeef5Sahrens 		{ "hidden",	ZFS_SNAPDIR_HIDDEN },
10891ebeef5Sahrens 		{ "visible",	ZFS_SNAPDIR_VISIBLE },
10991ebeef5Sahrens 		{ NULL }
11091ebeef5Sahrens 	};
11191ebeef5Sahrens 
112a3c49ce1SAlbert Lee 	static zprop_index_t acl_mode_table[] = {
113a3c49ce1SAlbert Lee 		{ "discard",	ZFS_ACL_DISCARD },
114a3c49ce1SAlbert Lee 		{ "groupmask",	ZFS_ACL_GROUPMASK },
115a3c49ce1SAlbert Lee 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
11671dbfc28SPaul B. Henson 		{ "restricted", ZFS_ACL_RESTRICTED },
117a3c49ce1SAlbert Lee 		{ NULL }
118a3c49ce1SAlbert Lee 	};
119a3c49ce1SAlbert Lee 
120990b4856Slling 	static zprop_index_t acl_inherit_table[] = {
12191ebeef5Sahrens 		{ "discard",	ZFS_ACL_DISCARD },
12291ebeef5Sahrens 		{ "noallow",	ZFS_ACL_NOALLOW },
123b3d141f8Smarks 		{ "restricted",	ZFS_ACL_RESTRICTED },
12491ebeef5Sahrens 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
125b3d141f8Smarks 		{ "secure",	ZFS_ACL_RESTRICTED }, /* bkwrd compatability */
126d0f3f37eSMark Shellenbaum 		{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
12791ebeef5Sahrens 		{ NULL }
12891ebeef5Sahrens 	};
12991ebeef5Sahrens 
130da6c28aaSamw 	static zprop_index_t case_table[] = {
131da6c28aaSamw 		{ "sensitive",		ZFS_CASE_SENSITIVE },
132da6c28aaSamw 		{ "insensitive",	ZFS_CASE_INSENSITIVE },
133da6c28aaSamw 		{ "mixed",		ZFS_CASE_MIXED },
134da6c28aaSamw 		{ NULL }
135da6c28aaSamw 	};
136da6c28aaSamw 
137990b4856Slling 	static zprop_index_t copies_table[] = {
13891ebeef5Sahrens 		{ "1",		1 },
13991ebeef5Sahrens 		{ "2",		2 },
14091ebeef5Sahrens 		{ "3",		3 },
14191ebeef5Sahrens 		{ NULL }
14291ebeef5Sahrens 	};
14391ebeef5Sahrens 
144de8267e0Stimh 	/*
145de8267e0Stimh 	 * Use the unique flags we have to send to u8_strcmp() and/or
146de8267e0Stimh 	 * u8_textprep() to represent the various normalization property
147de8267e0Stimh 	 * values.
148de8267e0Stimh 	 */
149da6c28aaSamw 	static zprop_index_t normalize_table[] = {
150de8267e0Stimh 		{ "none",	0 },
151de8267e0Stimh 		{ "formD",	U8_TEXTPREP_NFD },
152de8267e0Stimh 		{ "formKC",	U8_TEXTPREP_NFKC },
153de8267e0Stimh 		{ "formC",	U8_TEXTPREP_NFC },
154de8267e0Stimh 		{ "formKD",	U8_TEXTPREP_NFKD },
155da6c28aaSamw 		{ NULL }
156da6c28aaSamw 	};
157da6c28aaSamw 
158990b4856Slling 	static zprop_index_t version_table[] = {
15991ebeef5Sahrens 		{ "1",		1 },
16091ebeef5Sahrens 		{ "2",		2 },
161da6c28aaSamw 		{ "3",		3 },
16214843421SMatthew Ahrens 		{ "4",		4 },
1630a586ceaSMark Shellenbaum 		{ "5",		5 },
16491ebeef5Sahrens 		{ "current",	ZPL_VERSION },
16591ebeef5Sahrens 		{ NULL }
16691ebeef5Sahrens 	};
16791ebeef5Sahrens 
168990b4856Slling 	static zprop_index_t boolean_table[] = {
169e45ce728Sahrens 		{ "off",	0 },
170e45ce728Sahrens 		{ "on",		1 },
171e45ce728Sahrens 		{ NULL }
172e45ce728Sahrens 	};
173e45ce728Sahrens 
174e09fa4daSNeil Perrin 	static zprop_index_t logbias_table[] = {
175e09fa4daSNeil Perrin 		{ "latency",	ZFS_LOGBIAS_LATENCY },
176e09fa4daSNeil Perrin 		{ "throughput",	ZFS_LOGBIAS_THROUGHPUT },
177e09fa4daSNeil Perrin 		{ NULL }
178e09fa4daSNeil Perrin 	};
179e09fa4daSNeil Perrin 
180a227b7f4Shs24103 	static zprop_index_t canmount_table[] = {
181a227b7f4Shs24103 		{ "off",	ZFS_CANMOUNT_OFF },
182a227b7f4Shs24103 		{ "on",		ZFS_CANMOUNT_ON },
183a227b7f4Shs24103 		{ "noauto",	ZFS_CANMOUNT_NOAUTO },
184a227b7f4Shs24103 		{ NULL }
185a227b7f4Shs24103 	};
186a227b7f4Shs24103 
1873baa08fcSek110237 	static zprop_index_t cache_table[] = {
1883baa08fcSek110237 		{ "none",	ZFS_CACHE_NONE },
1893baa08fcSek110237 		{ "metadata",	ZFS_CACHE_METADATA },
1903baa08fcSek110237 		{ "all",	ZFS_CACHE_ALL },
1913baa08fcSek110237 		{ NULL }
1923baa08fcSek110237 	};
1933baa08fcSek110237 
19455da60b9SMark J Musante 	static zprop_index_t sync_table[] = {
19555da60b9SMark J Musante 		{ "standard",	ZFS_SYNC_STANDARD },
19655da60b9SMark J Musante 		{ "always",	ZFS_SYNC_ALWAYS },
19755da60b9SMark J Musante 		{ "disabled",	ZFS_SYNC_DISABLED },
19855da60b9SMark J Musante 		{ NULL }
19955da60b9SMark J Musante 	};
20055da60b9SMark J Musante 
201edf345e6SMatthew Ahrens 	static zprop_index_t redundant_metadata_table[] = {
202edf345e6SMatthew Ahrens 		{ "all",	ZFS_REDUNDANT_METADATA_ALL },
203edf345e6SMatthew Ahrens 		{ "most",	ZFS_REDUNDANT_METADATA_MOST },
204edf345e6SMatthew Ahrens 		{ NULL }
205edf345e6SMatthew Ahrens 	};
206edf345e6SMatthew Ahrens 
20791ebeef5Sahrens 	/* inherit index properties */
208edf345e6SMatthew Ahrens 	zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
209edf345e6SMatthew Ahrens 	    ZFS_REDUNDANT_METADATA_ALL,
210edf345e6SMatthew Ahrens 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
211edf345e6SMatthew Ahrens 	    "all | most", "REDUND_MD",
212edf345e6SMatthew Ahrens 	    redundant_metadata_table);
21355da60b9SMark J Musante 	zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
21455da60b9SMark J Musante 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
21555da60b9SMark J Musante 	    "standard | always | disabled", "SYNC",
21655da60b9SMark J Musante 	    sync_table);
21783d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
21883d7f9feSTom Erickson 	    ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
21983d7f9feSTom Erickson 	    ZFS_TYPE_VOLUME,
22091ebeef5Sahrens 	    "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
22191ebeef5Sahrens 	    checksum_table);
22283d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
223b24ab676SJeff Bonwick 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
224b1033ae2SMatthew Ahrens 	    "on | off | verify | sha256[,verify]", "DEDUP",
225b24ab676SJeff Bonwick 	    dedup_table);
22683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
227e45ce728Sahrens 	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
228e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
229a6f561b4SSašo Kiselkov 	    "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4",
230a6f561b4SSašo Kiselkov 	    "COMPRESS", compress_table);
23183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
232e45ce728Sahrens 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
233e45ce728Sahrens 	    "hidden | visible", "SNAPDIR", snapdir_table);
234a3c49ce1SAlbert Lee 	zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
235a3c49ce1SAlbert Lee 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
23671dbfc28SPaul B. Henson 	    "discard | groupmask | passthrough | restricted", "ACLMODE",
23771dbfc28SPaul B. Henson 	    acl_mode_table);
23883d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
23983d7f9feSTom Erickson 	    ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
240d0f3f37eSMark Shellenbaum 	    "discard | noallow | restricted | passthrough | passthrough-x",
241b3d141f8Smarks 	    "ACLINHERIT", acl_inherit_table);
24283d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
24383d7f9feSTom Erickson 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
24491ebeef5Sahrens 	    "1 | 2 | 3", "COPIES", copies_table);
24583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
2463baa08fcSek110237 	    ZFS_CACHE_ALL, PROP_INHERIT,
2473baa08fcSek110237 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
2483baa08fcSek110237 	    "all | none | metadata", "PRIMARYCACHE", cache_table);
24983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
2503baa08fcSek110237 	    ZFS_CACHE_ALL, PROP_INHERIT,
2513baa08fcSek110237 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
2523baa08fcSek110237 	    "all | none | metadata", "SECONDARYCACHE", cache_table);
25383d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
254e09fa4daSNeil Perrin 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
255e09fa4daSNeil Perrin 	    "latency | throughput", "LOGBIAS", logbias_table);
256e45ce728Sahrens 
257e45ce728Sahrens 	/* inherit index (boolean) properties */
25883d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
259e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
26083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
261e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
262e45ce728Sahrens 	    boolean_table);
26383d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
264e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
265e45ce728Sahrens 	    boolean_table);
26683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
267e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
268e45ce728Sahrens 	    boolean_table);
26983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
270e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
271e45ce728Sahrens 	    boolean_table);
27283d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
273e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
27483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
275e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
276e45ce728Sahrens 	    boolean_table);
27783d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
278da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
279da6c28aaSamw 	    boolean_table);
28083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
281da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
282da6c28aaSamw 	    boolean_table);
283e45ce728Sahrens 
284e45ce728Sahrens 	/* default index properties */
28583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
28691ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
28719b94df9SMatthew Ahrens 	    "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table);
28883d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
289a227b7f4Shs24103 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
290a227b7f4Shs24103 	    "CANMOUNT", canmount_table);
291e45ce728Sahrens 
292e45ce728Sahrens 	/* readonly index (boolean) properties */
29383d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
294990b4856Slling 	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
29583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
296842727c2SChris Kirby 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
297842727c2SChris Kirby 	    boolean_table);
298e45ce728Sahrens 
299da6c28aaSamw 	/* set once index properties */
30083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
301da6c28aaSamw 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
302da6c28aaSamw 	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
303da6c28aaSamw 	    normalize_table);
30483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
30583d7f9feSTom Erickson 	    ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
30683d7f9feSTom Erickson 	    ZFS_TYPE_SNAPSHOT,
307da6c28aaSamw 	    "sensitive | insensitive | mixed", "CASE", case_table);
308da6c28aaSamw 
309da6c28aaSamw 	/* set once index (boolean) properties */
31083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
311da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
312da6c28aaSamw 	    "on | off", "UTF8ONLY", boolean_table);
313da6c28aaSamw 
31491ebeef5Sahrens 	/* string properties */
31583d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
31691ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
31719b94df9SMatthew Ahrens 	zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
31819b94df9SMatthew Ahrens 	    ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES");
31983d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
32083d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
32183d7f9feSTom Erickson 	    "MOUNTPOINT");
32283d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
32383d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options",
32483d7f9feSTom Erickson 	    "SHARENFS");
32583d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
32678f17100SMatthew Ahrens 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
32778f17100SMatthew Ahrens 	    "filesystem | volume | snapshot | bookmark", "TYPE");
32883d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
32983d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
33083d7f9feSTom Erickson 	    "on | off | sharemgr(1M) options", "SHARESMB");
33183d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
33283d7f9feSTom Erickson 	    ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
33383d7f9feSTom Erickson 	    "<sensitivity label>", "MLSLABEL");
33491ebeef5Sahrens 
33591ebeef5Sahrens 	/* readonly number properties */
33683d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
337990b4856Slling 	    ZFS_TYPE_DATASET, "<size>", "USED");
33883d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
339990b4856Slling 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
34083d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
34183d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER");
34283d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
343990b4856Slling 	    PROP_READONLY, ZFS_TYPE_DATASET,
34491ebeef5Sahrens 	    "<1.00x or higher if compressed>", "RATIO");
345187d6ac0SMatt Ahrens 	zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
346187d6ac0SMatt Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET,
347187d6ac0SMatt Ahrens 	    "<1.00x or higher if compressed>", "REFRATIO");
34883d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
349c1449561SEric Taylor 	    ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
350da6c28aaSamw 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK");
35183d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
35283d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
35383d7f9feSTom Erickson 	    "USEDSNAP");
35483d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
35583d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
35683d7f9feSTom Erickson 	    "USEDDS");
35783d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
35883d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
35983d7f9feSTom Erickson 	    "USEDCHILD");
36083d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
36174e7dc98SMatthew Ahrens 	    PROP_READONLY,
36274e7dc98SMatthew Ahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
36383d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
364842727c2SChris Kirby 	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
36519b94df9SMatthew Ahrens 	zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
36619b94df9SMatthew Ahrens 	    ZFS_TYPE_DATASET, "<size>", "WRITTEN");
36777372cb0SMatthew Ahrens 	zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
36877372cb0SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LUSED");
36977372cb0SMatthew Ahrens 	zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
37077372cb0SMatthew Ahrens 	    0, PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LREFER");
37191ebeef5Sahrens 
37291ebeef5Sahrens 	/* default number properties */
37383d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
37491ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
37583d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
37683d7f9feSTom Erickson 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
37783d7f9feSTom Erickson 	    "<size> | none", "RESERV");
37883d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
37991ebeef5Sahrens 	    ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
38083d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
381a9799022Sck153898 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
38283d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
383a9799022Sck153898 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
384a9799022Sck153898 	    "<size> | none", "REFRESERV");
385a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
386a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
387a2afb611SJerry Jelinek 	    "<count> | none", "FSLIMIT");
388a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
389a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
390a2afb611SJerry Jelinek 	    "<count> | none", "SSLIMIT");
391a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
392a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
393a2afb611SJerry Jelinek 	    "<count>", "FSCOUNT");
394a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
395a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
396a2afb611SJerry Jelinek 	    "<count>", "SSCOUNT");
39791ebeef5Sahrens 
39891ebeef5Sahrens 	/* inherit number properties */
39983d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
40083d7f9feSTom Erickson 	    SPA_MAXBLOCKSIZE, PROP_INHERIT,
40191ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE");
40291ebeef5Sahrens 
40391ebeef5Sahrens 	/* hidden properties */
40483d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
40578f17100SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "CREATETXG");
40683d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
407b24ab676SJeff Bonwick 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
40883d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
40978f17100SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME");
41083d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
41183d7f9feSTom Erickson 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
41283d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
413478ed9adSEric Taylor 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
414478ed9adSEric Taylor 	    "STMF_SBD_LU");
41583d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER,
41678f17100SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "GUID");
41783d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
418b24ab676SJeff Bonwick 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
419b24ab676SJeff Bonwick 	    "USERACCOUNTING");
42083d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
421b24ab676SJeff Bonwick 	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
42283d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
4231d713200SEric Schrock 	    PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
424ca48f36fSKeith M Wesolowski 	zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
425ca48f36fSKeith M Wesolowski 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT");
426*b461c746SMatthew Ahrens 	zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
427*b461c746SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP");
42891ebeef5Sahrens 
42991ebeef5Sahrens 	/* oddball properties */
43083d7f9feSTom Erickson 	zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
43178f17100SMatthew Ahrens 	    NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
43291ebeef5Sahrens 	    "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
43391ebeef5Sahrens }
43491ebeef5Sahrens 
435b1b8ab34Slling boolean_t
436990b4856Slling zfs_prop_delegatable(zfs_prop_t prop)
437b1b8ab34Slling {
438990b4856Slling 	zprop_desc_t *pd = &zfs_prop_table[prop];
4394201a95eSRic Aleshire 
4404201a95eSRic Aleshire 	/* The mlslabel property is never delegatable. */
4414201a95eSRic Aleshire 	if (prop == ZFS_PROP_MLSLABEL)
4424201a95eSRic Aleshire 		return (B_FALSE);
4434201a95eSRic Aleshire 
444990b4856Slling 	return (pd->pd_attr != PROP_READONLY);
445b1b8ab34Slling }
446b1b8ab34Slling 
447b1b8ab34Slling /*
448b1b8ab34Slling  * Given a zfs dataset property name, returns the corresponding property ID.
449fa9e4066Sahrens  */
450fa9e4066Sahrens zfs_prop_t
451fa9e4066Sahrens zfs_name_to_prop(const char *propname)
452fa9e4066Sahrens {
453990b4856Slling 	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
454b1b8ab34Slling }
455fa9e4066Sahrens 
456fa9e4066Sahrens /*
457e9dbad6fSeschrock  * For user property names, we allow all lowercase alphanumeric characters, plus
458e9dbad6fSeschrock  * a few useful punctuation characters.
459e9dbad6fSeschrock  */
460e9dbad6fSeschrock static int
461e9dbad6fSeschrock valid_char(char c)
462e9dbad6fSeschrock {
463e9dbad6fSeschrock 	return ((c >= 'a' && c <= 'z') ||
464e9dbad6fSeschrock 	    (c >= '0' && c <= '9') ||
465e9dbad6fSeschrock 	    c == '-' || c == '_' || c == '.' || c == ':');
466e9dbad6fSeschrock }
467e9dbad6fSeschrock 
468e9dbad6fSeschrock /*
469e9dbad6fSeschrock  * Returns true if this is a valid user-defined property (one with a ':').
470e9dbad6fSeschrock  */
471e9dbad6fSeschrock boolean_t
472e9dbad6fSeschrock zfs_prop_user(const char *name)
473e9dbad6fSeschrock {
474e9dbad6fSeschrock 	int i;
475e9dbad6fSeschrock 	char c;
476e9dbad6fSeschrock 	boolean_t foundsep = B_FALSE;
477e9dbad6fSeschrock 
478e9dbad6fSeschrock 	for (i = 0; i < strlen(name); i++) {
479e9dbad6fSeschrock 		c = name[i];
480e9dbad6fSeschrock 		if (!valid_char(c))
481e9dbad6fSeschrock 			return (B_FALSE);
482e9dbad6fSeschrock 		if (c == ':')
483e9dbad6fSeschrock 			foundsep = B_TRUE;
484e9dbad6fSeschrock 	}
485e9dbad6fSeschrock 
486e9dbad6fSeschrock 	if (!foundsep)
487e9dbad6fSeschrock 		return (B_FALSE);
488e9dbad6fSeschrock 
489e9dbad6fSeschrock 	return (B_TRUE);
490e9dbad6fSeschrock }
491e9dbad6fSeschrock 
492e9dbad6fSeschrock /*
49314843421SMatthew Ahrens  * Returns true if this is a valid userspace-type property (one with a '@').
49414843421SMatthew Ahrens  * Note that after the @, any character is valid (eg, another @, for SID
49514843421SMatthew Ahrens  * user@domain).
49614843421SMatthew Ahrens  */
49714843421SMatthew Ahrens boolean_t
49814843421SMatthew Ahrens zfs_prop_userquota(const char *name)
49914843421SMatthew Ahrens {
50014843421SMatthew Ahrens 	zfs_userquota_prop_t prop;
50114843421SMatthew Ahrens 
50214843421SMatthew Ahrens 	for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
50314843421SMatthew Ahrens 		if (strncmp(name, zfs_userquota_prop_prefixes[prop],
50414843421SMatthew Ahrens 		    strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
50514843421SMatthew Ahrens 			return (B_TRUE);
50614843421SMatthew Ahrens 		}
50714843421SMatthew Ahrens 	}
50814843421SMatthew Ahrens 
50914843421SMatthew Ahrens 	return (B_FALSE);
51014843421SMatthew Ahrens }
51114843421SMatthew Ahrens 
51214843421SMatthew Ahrens /*
51319b94df9SMatthew Ahrens  * Returns true if this is a valid written@ property.
51419b94df9SMatthew Ahrens  * Note that after the @, any character is valid (eg, another @, for
51519b94df9SMatthew Ahrens  * written@pool/fs@origin).
51619b94df9SMatthew Ahrens  */
51719b94df9SMatthew Ahrens boolean_t
51819b94df9SMatthew Ahrens zfs_prop_written(const char *name)
51919b94df9SMatthew Ahrens {
52019b94df9SMatthew Ahrens 	static const char *prefix = "written@";
52119b94df9SMatthew Ahrens 	return (strncmp(name, prefix, strlen(prefix)) == 0);
52219b94df9SMatthew Ahrens }
52319b94df9SMatthew Ahrens 
52419b94df9SMatthew Ahrens /*
525990b4856Slling  * Tables of index types, plus functions to convert between the user view
526990b4856Slling  * (strings) and internal representation (uint64_t).
527fa9e4066Sahrens  */
528990b4856Slling int
529990b4856Slling zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
530fa9e4066Sahrens {
531990b4856Slling 	return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
532990b4856Slling }
533990b4856Slling 
534990b4856Slling int
535990b4856Slling zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
536990b4856Slling {
537990b4856Slling 	return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
538990b4856Slling }
539990b4856Slling 
540b24ab676SJeff Bonwick uint64_t
541b24ab676SJeff Bonwick zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
542b24ab676SJeff Bonwick {
543b24ab676SJeff Bonwick 	return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
544b24ab676SJeff Bonwick }
545b24ab676SJeff Bonwick 
546990b4856Slling /*
547990b4856Slling  * Returns TRUE if the property applies to any of the given dataset types.
548990b4856Slling  */
5494853e976Sgw25295 boolean_t
550990b4856Slling zfs_prop_valid_for_type(int prop, zfs_type_t types)
551990b4856Slling {
552990b4856Slling 	return (zprop_valid_for_type(prop, types));
553990b4856Slling }
554990b4856Slling 
555990b4856Slling zprop_type_t
556990b4856Slling zfs_prop_get_type(zfs_prop_t prop)
557990b4856Slling {
558990b4856Slling 	return (zfs_prop_table[prop].pd_proptype);
559990b4856Slling }
560990b4856Slling 
561990b4856Slling /*
562990b4856Slling  * Returns TRUE if the property is readonly.
563990b4856Slling  */
564990b4856Slling boolean_t
565990b4856Slling zfs_prop_readonly(zfs_prop_t prop)
566990b4856Slling {
567da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
568da6c28aaSamw 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
569da6c28aaSamw }
570da6c28aaSamw 
571da6c28aaSamw /*
572da6c28aaSamw  * Returns TRUE if the property is only allowed to be set once.
573da6c28aaSamw  */
574da6c28aaSamw boolean_t
575da6c28aaSamw zfs_prop_setonce(zfs_prop_t prop)
576da6c28aaSamw {
577da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_ONETIME);
578fa9e4066Sahrens }
579fa9e4066Sahrens 
5803d7072f8Seschrock const char *
581990b4856Slling zfs_prop_default_string(zfs_prop_t prop)
5823d7072f8Seschrock {
5833d7072f8Seschrock 	return (zfs_prop_table[prop].pd_strdefault);
5843d7072f8Seschrock }
5853d7072f8Seschrock 
586fa9e4066Sahrens uint64_t
587fa9e4066Sahrens zfs_prop_default_numeric(zfs_prop_t prop)
588fa9e4066Sahrens {
589fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_numdefault);
590fa9e4066Sahrens }
591fa9e4066Sahrens 
592fa9e4066Sahrens /*
593b1b8ab34Slling  * Given a dataset property ID, returns the corresponding name.
5943d7072f8Seschrock  * Assuming the zfs dataset property ID is valid.
595fa9e4066Sahrens  */
596fa9e4066Sahrens const char *
597fa9e4066Sahrens zfs_prop_to_name(zfs_prop_t prop)
598fa9e4066Sahrens {
599fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_name);
600fa9e4066Sahrens }
601fa9e4066Sahrens 
602fa9e4066Sahrens /*
603fa9e4066Sahrens  * Returns TRUE if the property is inheritable.
604fa9e4066Sahrens  */
605990b4856Slling boolean_t
606fa9e4066Sahrens zfs_prop_inheritable(zfs_prop_t prop)
607fa9e4066Sahrens {
608da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
609da6c28aaSamw 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
610e9dbad6fSeschrock }
611e9dbad6fSeschrock 
612acd76fe5Seschrock #ifndef _KERNEL
613acd76fe5Seschrock 
614fa9e4066Sahrens /*
615fa9e4066Sahrens  * Returns a string describing the set of acceptable values for the given
616b1b8ab34Slling  * zfs property, or NULL if it cannot be set.
617fa9e4066Sahrens  */
618fa9e4066Sahrens const char *
619fa9e4066Sahrens zfs_prop_values(zfs_prop_t prop)
620fa9e4066Sahrens {
621fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_values);
622fa9e4066Sahrens }
623fa9e4066Sahrens 
624fa9e4066Sahrens /*
625fa9e4066Sahrens  * Returns TRUE if this property is a string type.  Note that index types
626fa9e4066Sahrens  * (compression, checksum) are treated as strings in userland, even though they
627fa9e4066Sahrens  * are stored numerically on disk.
628fa9e4066Sahrens  */
629fa9e4066Sahrens int
630fa9e4066Sahrens zfs_prop_is_string(zfs_prop_t prop)
631fa9e4066Sahrens {
63291ebeef5Sahrens 	return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
63391ebeef5Sahrens 	    zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
634fa9e4066Sahrens }
635fa9e4066Sahrens 
636fa9e4066Sahrens /*
637fa9e4066Sahrens  * Returns the column header for the given property.  Used only in
638fa9e4066Sahrens  * 'zfs list -o', but centralized here with the other property information.
639fa9e4066Sahrens  */
640fa9e4066Sahrens const char *
641fa9e4066Sahrens zfs_prop_column_name(zfs_prop_t prop)
642fa9e4066Sahrens {
643fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_colname);
644fa9e4066Sahrens }
645fa9e4066Sahrens 
646fa9e4066Sahrens /*
647e9dbad6fSeschrock  * Returns whether the given property should be displayed right-justified for
648e9dbad6fSeschrock  * 'zfs list'.
649fa9e4066Sahrens  */
650e9dbad6fSeschrock boolean_t
651e9dbad6fSeschrock zfs_prop_align_right(zfs_prop_t prop)
652fa9e4066Sahrens {
653e9dbad6fSeschrock 	return (zfs_prop_table[prop].pd_rightalign);
654fa9e4066Sahrens }
655da6c28aaSamw 
656fa9e4066Sahrens #endif
657