xref: /illumos-gate/usr/src/common/zfs/zfs_prop.c (revision 4c2bdae2)
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.
23dfc11533SChris Williamson  * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
24a6f561b4SSašo Kiselkov  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25c3d26abcSMatthew Ahrens  * Copyright (c) 2014 Integros [integros.com]
26007a6c1fSJerry Jelinek  * Copyright 2016, Joyent, Inc.
27fa9e4066Sahrens  */
28fa9e4066Sahrens 
2955da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */
3055da60b9SMark J Musante 
31fa9e4066Sahrens #include <sys/zio.h>
32fa9e4066Sahrens #include <sys/spa.h>
33de8267e0Stimh #include <sys/u8_textprep.h>
34fa9e4066Sahrens #include <sys/zfs_acl.h>
35fa9e4066Sahrens #include <sys/zfs_ioctl.h>
36e7437265Sahrens #include <sys/zfs_znode.h>
37eb633035STom Caputi #include <sys/dsl_crypt.h>
38fa9e4066Sahrens 
39fa9e4066Sahrens #include "zfs_prop.h"
40ecd6cf80Smarks #include "zfs_deleg.h"
41fa9e4066Sahrens 
42fa9e4066Sahrens #if defined(_KERNEL)
43fa9e4066Sahrens #include <sys/systm.h>
44fa9e4066Sahrens #else
45fa9e4066Sahrens #include <stdlib.h>
46fa9e4066Sahrens #include <string.h>
47fa9e4066Sahrens #include <ctype.h>
48fa9e4066Sahrens #endif
49fa9e4066Sahrens 
50990b4856Slling static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
5191ebeef5Sahrens 
5214843421SMatthew Ahrens /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
5314843421SMatthew Ahrens const char *zfs_userquota_prop_prefixes[] = {
5414843421SMatthew Ahrens 	"userused@",
5514843421SMatthew Ahrens 	"userquota@",
5614843421SMatthew Ahrens 	"groupused@",
57f67950b2SNasf-Fan 	"groupquota@",
58f67950b2SNasf-Fan 	"userobjused@",
59f67950b2SNasf-Fan 	"userobjquota@",
60f67950b2SNasf-Fan 	"groupobjused@",
61f67950b2SNasf-Fan 	"groupobjquota@",
62f67950b2SNasf-Fan 	"projectused@",
63f67950b2SNasf-Fan 	"projectquota@",
64f67950b2SNasf-Fan 	"projectobjused@",
65f67950b2SNasf-Fan 	"projectobjquota@"
6614843421SMatthew Ahrens };
6714843421SMatthew Ahrens 
68990b4856Slling zprop_desc_t *
zfs_prop_get_table(void)69990b4856Slling zfs_prop_get_table(void)
7091ebeef5Sahrens {
71990b4856Slling 	return (zfs_prop_table);
7291ebeef5Sahrens }
7391ebeef5Sahrens 
7491ebeef5Sahrens void
zfs_prop_init(void)7591ebeef5Sahrens zfs_prop_init(void)
7691ebeef5Sahrens {
77990b4856Slling 	static zprop_index_t checksum_table[] = {
7891ebeef5Sahrens 		{ "on",		ZIO_CHECKSUM_ON },
7991ebeef5Sahrens 		{ "off",	ZIO_CHECKSUM_OFF },
8091ebeef5Sahrens 		{ "fletcher2",	ZIO_CHECKSUM_FLETCHER_2 },
8191ebeef5Sahrens 		{ "fletcher4",	ZIO_CHECKSUM_FLETCHER_4 },
8291ebeef5Sahrens 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
83810e43b2SBill Pijewski 		{ "noparity",	ZIO_CHECKSUM_NOPARITY },
8445818ee1SMatthew Ahrens 		{ "sha512",	ZIO_CHECKSUM_SHA512 },
8545818ee1SMatthew Ahrens 		{ "skein",	ZIO_CHECKSUM_SKEIN },
8645818ee1SMatthew Ahrens 		{ "edonr",	ZIO_CHECKSUM_EDONR },
8791ebeef5Sahrens 		{ NULL }
8891ebeef5Sahrens 	};
8991ebeef5Sahrens 
90b24ab676SJeff Bonwick 	static zprop_index_t dedup_table[] = {
91b24ab676SJeff Bonwick 		{ "on",		ZIO_CHECKSUM_ON },
92b24ab676SJeff Bonwick 		{ "off",	ZIO_CHECKSUM_OFF },
93b24ab676SJeff Bonwick 		{ "verify",	ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
94b24ab676SJeff Bonwick 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
95b24ab676SJeff Bonwick 		{ "sha256,verify",
96b24ab676SJeff Bonwick 				ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
9745818ee1SMatthew Ahrens 		{ "sha512",	ZIO_CHECKSUM_SHA512 },
9845818ee1SMatthew Ahrens 		{ "sha512,verify",
9945818ee1SMatthew Ahrens 				ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY },
10045818ee1SMatthew Ahrens 		{ "skein",	ZIO_CHECKSUM_SKEIN },
10145818ee1SMatthew Ahrens 		{ "skein,verify",
10245818ee1SMatthew Ahrens 				ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY },
10345818ee1SMatthew Ahrens 		{ "edonr,verify",
10445818ee1SMatthew Ahrens 				ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY },
105b24ab676SJeff Bonwick 		{ NULL }
106b24ab676SJeff Bonwick 	};
107b24ab676SJeff Bonwick 
108990b4856Slling 	static zprop_index_t compress_table[] = {
10991ebeef5Sahrens 		{ "on",		ZIO_COMPRESS_ON },
11091ebeef5Sahrens 		{ "off",	ZIO_COMPRESS_OFF },
11191ebeef5Sahrens 		{ "lzjb",	ZIO_COMPRESS_LZJB },
11291ebeef5Sahrens 		{ "gzip",	ZIO_COMPRESS_GZIP_6 },	/* gzip default */
11391ebeef5Sahrens 		{ "gzip-1",	ZIO_COMPRESS_GZIP_1 },
11491ebeef5Sahrens 		{ "gzip-2",	ZIO_COMPRESS_GZIP_2 },
11591ebeef5Sahrens 		{ "gzip-3",	ZIO_COMPRESS_GZIP_3 },
11691ebeef5Sahrens 		{ "gzip-4",	ZIO_COMPRESS_GZIP_4 },
11791ebeef5Sahrens 		{ "gzip-5",	ZIO_COMPRESS_GZIP_5 },
11891ebeef5Sahrens 		{ "gzip-6",	ZIO_COMPRESS_GZIP_6 },
11991ebeef5Sahrens 		{ "gzip-7",	ZIO_COMPRESS_GZIP_7 },
12091ebeef5Sahrens 		{ "gzip-8",	ZIO_COMPRESS_GZIP_8 },
12191ebeef5Sahrens 		{ "gzip-9",	ZIO_COMPRESS_GZIP_9 },
122b24ab676SJeff Bonwick 		{ "zle",	ZIO_COMPRESS_ZLE },
123a6f561b4SSašo Kiselkov 		{ "lz4",	ZIO_COMPRESS_LZ4 },
12491ebeef5Sahrens 		{ NULL }
12591ebeef5Sahrens 	};
12691ebeef5Sahrens 
127eb633035STom Caputi 	static zprop_index_t crypto_table[] = {
128eb633035STom Caputi 		{ "on",			ZIO_CRYPT_ON },
129eb633035STom Caputi 		{ "off",		ZIO_CRYPT_OFF },
130eb633035STom Caputi 		{ "aes-128-ccm",	ZIO_CRYPT_AES_128_CCM },
131eb633035STom Caputi 		{ "aes-192-ccm",	ZIO_CRYPT_AES_192_CCM },
132eb633035STom Caputi 		{ "aes-256-ccm",	ZIO_CRYPT_AES_256_CCM },
133eb633035STom Caputi 		{ "aes-128-gcm",	ZIO_CRYPT_AES_128_GCM },
134eb633035STom Caputi 		{ "aes-192-gcm",	ZIO_CRYPT_AES_192_GCM },
135eb633035STom Caputi 		{ "aes-256-gcm",	ZIO_CRYPT_AES_256_GCM },
136eb633035STom Caputi 		{ NULL }
137eb633035STom Caputi 	};
138eb633035STom Caputi 
139eb633035STom Caputi 	static zprop_index_t keyformat_table[] = {
140eb633035STom Caputi 		{ "none",		ZFS_KEYFORMAT_NONE },
141eb633035STom Caputi 		{ "raw",		ZFS_KEYFORMAT_RAW },
142eb633035STom Caputi 		{ "hex",		ZFS_KEYFORMAT_HEX },
143eb633035STom Caputi 		{ "passphrase",		ZFS_KEYFORMAT_PASSPHRASE },
144eb633035STom Caputi 		{ NULL }
145eb633035STom Caputi 	};
146eb633035STom Caputi 
147990b4856Slling 	static zprop_index_t snapdir_table[] = {
14891ebeef5Sahrens 		{ "hidden",	ZFS_SNAPDIR_HIDDEN },
14991ebeef5Sahrens 		{ "visible",	ZFS_SNAPDIR_VISIBLE },
15091ebeef5Sahrens 		{ NULL }
15191ebeef5Sahrens 	};
15291ebeef5Sahrens 
153a3c49ce1SAlbert Lee 	static zprop_index_t acl_mode_table[] = {
154a3c49ce1SAlbert Lee 		{ "discard",	ZFS_ACL_DISCARD },
155a3c49ce1SAlbert Lee 		{ "groupmask",	ZFS_ACL_GROUPMASK },
156a3c49ce1SAlbert Lee 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
15771dbfc28SPaul B. Henson 		{ "restricted", ZFS_ACL_RESTRICTED },
158a3c49ce1SAlbert Lee 		{ NULL }
159a3c49ce1SAlbert Lee 	};
160a3c49ce1SAlbert Lee 
161990b4856Slling 	static zprop_index_t acl_inherit_table[] = {
16291ebeef5Sahrens 		{ "discard",	ZFS_ACL_DISCARD },
16391ebeef5Sahrens 		{ "noallow",	ZFS_ACL_NOALLOW },
164b3d141f8Smarks 		{ "restricted",	ZFS_ACL_RESTRICTED },
16591ebeef5Sahrens 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
166b3d141f8Smarks 		{ "secure",	ZFS_ACL_RESTRICTED }, /* bkwrd compatability */
167d0f3f37eSMark Shellenbaum 		{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
16891ebeef5Sahrens 		{ NULL }
16991ebeef5Sahrens 	};
17091ebeef5Sahrens 
171da6c28aaSamw 	static zprop_index_t case_table[] = {
172da6c28aaSamw 		{ "sensitive",		ZFS_CASE_SENSITIVE },
173da6c28aaSamw 		{ "insensitive",	ZFS_CASE_INSENSITIVE },
174da6c28aaSamw 		{ "mixed",		ZFS_CASE_MIXED },
175da6c28aaSamw 		{ NULL }
176da6c28aaSamw 	};
177da6c28aaSamw 
178990b4856Slling 	static zprop_index_t copies_table[] = {
17991ebeef5Sahrens 		{ "1",		1 },
18091ebeef5Sahrens 		{ "2",		2 },
18191ebeef5Sahrens 		{ "3",		3 },
18291ebeef5Sahrens 		{ NULL }
18391ebeef5Sahrens 	};
18491ebeef5Sahrens 
185de8267e0Stimh 	/*
186de8267e0Stimh 	 * Use the unique flags we have to send to u8_strcmp() and/or
187de8267e0Stimh 	 * u8_textprep() to represent the various normalization property
188de8267e0Stimh 	 * values.
189de8267e0Stimh 	 */
190da6c28aaSamw 	static zprop_index_t normalize_table[] = {
191de8267e0Stimh 		{ "none",	0 },
192de8267e0Stimh 		{ "formD",	U8_TEXTPREP_NFD },
193de8267e0Stimh 		{ "formKC",	U8_TEXTPREP_NFKC },
194de8267e0Stimh 		{ "formC",	U8_TEXTPREP_NFC },
195de8267e0Stimh 		{ "formKD",	U8_TEXTPREP_NFKD },
196da6c28aaSamw 		{ NULL }
197da6c28aaSamw 	};
198da6c28aaSamw 
199990b4856Slling 	static zprop_index_t version_table[] = {
20091ebeef5Sahrens 		{ "1",		1 },
20191ebeef5Sahrens 		{ "2",		2 },
202da6c28aaSamw 		{ "3",		3 },
20314843421SMatthew Ahrens 		{ "4",		4 },
2040a586ceaSMark Shellenbaum 		{ "5",		5 },
20591ebeef5Sahrens 		{ "current",	ZPL_VERSION },
20691ebeef5Sahrens 		{ NULL }
20791ebeef5Sahrens 	};
20891ebeef5Sahrens 
209990b4856Slling 	static zprop_index_t boolean_table[] = {
210e45ce728Sahrens 		{ "off",	0 },
211e45ce728Sahrens 		{ "on",		1 },
212e45ce728Sahrens 		{ NULL }
213e45ce728Sahrens 	};
214e45ce728Sahrens 
215eb633035STom Caputi 	static zprop_index_t keystatus_table[] = {
216eb633035STom Caputi 		{ "none",		ZFS_KEYSTATUS_NONE },
217eb633035STom Caputi 		{ "unavailable",	ZFS_KEYSTATUS_UNAVAILABLE },
218eb633035STom Caputi 		{ "available",		ZFS_KEYSTATUS_AVAILABLE },
219eb633035STom Caputi 		{ NULL }
220eb633035STom Caputi 	};
221eb633035STom Caputi 
222e09fa4daSNeil Perrin 	static zprop_index_t logbias_table[] = {
223e09fa4daSNeil Perrin 		{ "latency",	ZFS_LOGBIAS_LATENCY },
224e09fa4daSNeil Perrin 		{ "throughput",	ZFS_LOGBIAS_THROUGHPUT },
225e09fa4daSNeil Perrin 		{ NULL }
226e09fa4daSNeil Perrin 	};
227e09fa4daSNeil Perrin 
228a227b7f4Shs 	static zprop_index_t canmount_table[] = {
229a227b7f4Shs 		{ "off",	ZFS_CANMOUNT_OFF },
230a227b7f4Shs 		{ "on",		ZFS_CANMOUNT_ON },
231a227b7f4Shs 		{ "noauto",	ZFS_CANMOUNT_NOAUTO },
232a227b7f4Shs 		{ NULL }
233a227b7f4Shs 	};
234a227b7f4Shs 
2353baa08fcSek 	static zprop_index_t cache_table[] = {
2363baa08fcSek 		{ "none",	ZFS_CACHE_NONE },
2373baa08fcSek 		{ "metadata",	ZFS_CACHE_METADATA },
2383baa08fcSek 		{ "all",	ZFS_CACHE_ALL },
2393baa08fcSek 		{ NULL }
2403baa08fcSek 	};
2413baa08fcSek 
24255da60b9SMark J Musante 	static zprop_index_t sync_table[] = {
24355da60b9SMark J Musante 		{ "standard",	ZFS_SYNC_STANDARD },
24455da60b9SMark J Musante 		{ "always",	ZFS_SYNC_ALWAYS },
24555da60b9SMark J Musante 		{ "disabled",	ZFS_SYNC_DISABLED },
24655da60b9SMark J Musante 		{ NULL }
24755da60b9SMark J Musante 	};
24855da60b9SMark J Musante 
24954811da5SToomas Soome 	static zprop_index_t dnsize_table[] = {
25054811da5SToomas Soome 		{ "legacy",	ZFS_DNSIZE_LEGACY },
25154811da5SToomas Soome 		{ "auto",	ZFS_DNSIZE_AUTO },
25254811da5SToomas Soome 		{ "1k",		ZFS_DNSIZE_1K },
25354811da5SToomas Soome 		{ "2k",		ZFS_DNSIZE_2K },
25454811da5SToomas Soome 		{ "4k",		ZFS_DNSIZE_4K },
25554811da5SToomas Soome 		{ "8k",		ZFS_DNSIZE_8K },
25654811da5SToomas Soome 		{ "16k",	ZFS_DNSIZE_16K },
25754811da5SToomas Soome 		{ NULL }
25854811da5SToomas Soome 	};
25954811da5SToomas Soome 
260edf345e6SMatthew Ahrens 	static zprop_index_t redundant_metadata_table[] = {
261edf345e6SMatthew Ahrens 		{ "all",	ZFS_REDUNDANT_METADATA_ALL },
262edf345e6SMatthew Ahrens 		{ "most",	ZFS_REDUNDANT_METADATA_MOST },
263edf345e6SMatthew Ahrens 		{ NULL }
264edf345e6SMatthew Ahrens 	};
265edf345e6SMatthew Ahrens 
26691ebeef5Sahrens 	/* inherit index properties */
267edf345e6SMatthew Ahrens 	zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
268edf345e6SMatthew Ahrens 	    ZFS_REDUNDANT_METADATA_ALL,
269edf345e6SMatthew Ahrens 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
270edf345e6SMatthew Ahrens 	    "all | most", "REDUND_MD",
271edf345e6SMatthew Ahrens 	    redundant_metadata_table);
27255da60b9SMark J Musante 	zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
27355da60b9SMark J Musante 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
27455da60b9SMark J Musante 	    "standard | always | disabled", "SYNC",
27555da60b9SMark J Musante 	    sync_table);
27683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
27783d7f9feSTom Erickson 	    ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
27883d7f9feSTom Erickson 	    ZFS_TYPE_VOLUME,
27945818ee1SMatthew Ahrens 	    "on | off | fletcher2 | fletcher4 | sha256 | sha512 | "
28045818ee1SMatthew Ahrens 	    "skein | edonr", "CHECKSUM", checksum_table);
28183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
282b24ab676SJeff Bonwick 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
28345818ee1SMatthew Ahrens 	    "on | off | verify | sha256[,verify], sha512[,verify], "
28445818ee1SMatthew Ahrens 	    "skein[,verify], edonr,verify", "DEDUP", dedup_table);
28583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
286e45ce728Sahrens 	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
287e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
288a6f561b4SSašo Kiselkov 	    "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4",
289a6f561b4SSašo Kiselkov 	    "COMPRESS", compress_table);
29083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
291e45ce728Sahrens 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
292e45ce728Sahrens 	    "hidden | visible", "SNAPDIR", snapdir_table);
293a3c49ce1SAlbert Lee 	zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
294a3c49ce1SAlbert Lee 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
29571dbfc28SPaul B. Henson 	    "discard | groupmask | passthrough | restricted", "ACLMODE",
29671dbfc28SPaul B. Henson 	    acl_mode_table);
29783d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
29883d7f9feSTom Erickson 	    ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
299d0f3f37eSMark Shellenbaum 	    "discard | noallow | restricted | passthrough | passthrough-x",
300b3d141f8Smarks 	    "ACLINHERIT", acl_inherit_table);
30170561057SGordon Ross 	zprop_register_index(ZFS_PROP_ACLIMPLICIT, "aclimplicit", 1,
30270561057SGordon Ross 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off", "ACLIMPL",
30370561057SGordon Ross 	    boolean_table);
30483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
30583d7f9feSTom Erickson 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
30691ebeef5Sahrens 	    "1 | 2 | 3", "COPIES", copies_table);
30783d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
3083baa08fcSek 	    ZFS_CACHE_ALL, PROP_INHERIT,
3093baa08fcSek 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
3103baa08fcSek 	    "all | none | metadata", "PRIMARYCACHE", cache_table);
31183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
3123baa08fcSek 	    ZFS_CACHE_ALL, PROP_INHERIT,
3133baa08fcSek 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
3143baa08fcSek 	    "all | none | metadata", "SECONDARYCACHE", cache_table);
31583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
316e09fa4daSNeil Perrin 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
317e09fa4daSNeil Perrin 	    "latency | throughput", "LOGBIAS", logbias_table);
31854811da5SToomas Soome 
31954811da5SToomas Soome 	zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",
32054811da5SToomas Soome 	    ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
32154811da5SToomas Soome 	    "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table);
322e45ce728Sahrens 
323e45ce728Sahrens 	/* inherit index (boolean) properties */
32483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
325e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
32683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
327e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
328e45ce728Sahrens 	    boolean_table);
32983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
330e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
331e45ce728Sahrens 	    boolean_table);
33283d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
333e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
334e45ce728Sahrens 	    boolean_table);
33583d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
336e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
337e45ce728Sahrens 	    boolean_table);
33883d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
339e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
34083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
341e45ce728Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
342e45ce728Sahrens 	    boolean_table);
34383d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
344da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
345da6c28aaSamw 	    boolean_table);
34683d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
347da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
348da6c28aaSamw 	    boolean_table);
349e45ce728Sahrens 
350e45ce728Sahrens 	/* default index properties */
35183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
3527b55fa8eSck 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
35319b94df9SMatthew Ahrens 	    "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table);
35483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
355a227b7f4Shs 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
356a227b7f4Shs 	    "CANMOUNT", canmount_table);
357e45ce728Sahrens 
358eb633035STom Caputi 	/* readonly index properties */
35983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
360990b4856Slling 	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
36183d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
362842727c2SChris Kirby 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
363842727c2SChris Kirby 	    boolean_table);
364eb633035STom Caputi 	zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",
365eb633035STom Caputi 	    ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,
366eb633035STom Caputi 	    "none | unavailable | available",
367eb633035STom Caputi 	    "KEYSTATUS", keystatus_table);
368e45ce728Sahrens 
369da6c28aaSamw 	/* set once index properties */
37083d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
371da6c28aaSamw 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
372da6c28aaSamw 	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
373da6c28aaSamw 	    normalize_table);
37483d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
37583d7f9feSTom Erickson 	    ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
37683d7f9feSTom Erickson 	    ZFS_TYPE_SNAPSHOT,
377da6c28aaSamw 	    "sensitive | insensitive | mixed", "CASE", case_table);
378eb633035STom Caputi 	zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",
379eb633035STom Caputi 	    ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,
380eb633035STom Caputi 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
381eb633035STom Caputi 	    "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table);
382eb633035STom Caputi 	zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption",
383eb633035STom Caputi 	    ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET,
384eb633035STom Caputi 	    "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "
385eb633035STom Caputi 	    "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",
386eb633035STom Caputi 	    crypto_table);
387da6c28aaSamw 
388da6c28aaSamw 	/* set once index (boolean) properties */
38983d7f9feSTom Erickson 	zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
390da6c28aaSamw 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
391da6c28aaSamw 	    "on | off", "UTF8ONLY", boolean_table);
392da6c28aaSamw 
39391ebeef5Sahrens 	/* string properties */
39483d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
39591ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
39619b94df9SMatthew Ahrens 	zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
39719b94df9SMatthew Ahrens 	    ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES");
39883d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
39983d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
40083d7f9feSTom Erickson 	    "MOUNTPOINT");
40183d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
402bbf21555SRichard Lowe 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(8) options",
40383d7f9feSTom Erickson 	    "SHARENFS");
40483d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
40578f17100SMatthew Ahrens 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
40678f17100SMatthew Ahrens 	    "filesystem | volume | snapshot | bookmark", "TYPE");
40783d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
40883d7f9feSTom Erickson 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
409bbf21555SRichard Lowe 	    "on | off | sharemgr(8) options", "SHARESMB");
41083d7f9feSTom Erickson 	zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
41183d7f9feSTom Erickson 	    ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
41283d7f9feSTom Erickson 	    "<sensitivity label>", "MLSLABEL");
4139c3fd121SMatthew Ahrens 	zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN,
4149c3fd121SMatthew Ahrens 	    "receive_resume_token",
4159c3fd121SMatthew Ahrens 	    NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
4169c3fd121SMatthew Ahrens 	    "<string token>", "RESUMETOK");
417eb633035STom Caputi 	zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,
418eb633035STom Caputi 	    PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",
419eb633035STom Caputi 	    "ENCROOT");
420eb633035STom Caputi 	zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",
421eb633035STom Caputi 	    "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
422eb633035STom Caputi 	    "prompt | <file URI>", "KEYLOCATION");
42391ebeef5Sahrens 
42491ebeef5Sahrens 	/* readonly number properties */
42583d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
426990b4856Slling 	    ZFS_TYPE_DATASET, "<size>", "USED");
42783d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
428990b4856Slling 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
42983d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
43083d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER");
43183d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
432990b4856Slling 	    PROP_READONLY, ZFS_TYPE_DATASET,
43391ebeef5Sahrens 	    "<1.00x or higher if compressed>", "RATIO");
434187d6ac0SMatt Ahrens 	zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
435187d6ac0SMatt Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET,
436187d6ac0SMatt Ahrens 	    "<1.00x or higher if compressed>", "REFRATIO");
43783d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
438c1449561SEric Taylor 	    ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
439da6c28aaSamw 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK");
44083d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
44183d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
44283d7f9feSTom Erickson 	    "USEDSNAP");
44383d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
44483d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
44583d7f9feSTom Erickson 	    "USEDDS");
44683d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
44783d7f9feSTom Erickson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
44883d7f9feSTom Erickson 	    "USEDCHILD");
44983d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
45074e7dc98SMatthew Ahrens 	    PROP_READONLY,
45174e7dc98SMatthew Ahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
45283d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
453842727c2SChris Kirby 	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
45419b94df9SMatthew Ahrens 	zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
45519b94df9SMatthew Ahrens 	    ZFS_TYPE_DATASET, "<size>", "WRITTEN");
45677372cb0SMatthew Ahrens 	zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
457dfc11533SChris Williamson 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
458dfc11533SChris Williamson 	    "LUSED");
45977372cb0SMatthew Ahrens 	zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
46077372cb0SMatthew Ahrens 	    0, PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LREFER");
461007a6c1fSJerry Jelinek 	zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
462007a6c1fSJerry Jelinek 	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM,
463007a6c1fSJerry Jelinek 	    "<count>", "FSCOUNT");
464007a6c1fSJerry Jelinek 	zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
465007a6c1fSJerry Jelinek 	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
466007a6c1fSJerry Jelinek 	    "<count>", "SSCOUNT");
467e8d4a73cSJosh Paetzel 	zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY,
468e8d4a73cSJosh Paetzel 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID");
469e8d4a73cSJosh Paetzel 	zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,
470e8d4a73cSJosh Paetzel 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG");
471eb633035STom Caputi 	zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",
472eb633035STom Caputi 	    0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
473eb633035STom Caputi 	    "<iters>", "PBKDF2ITERS");
47491ebeef5Sahrens 
47591ebeef5Sahrens 	/* default number properties */
47683d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
47791ebeef5Sahrens 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
47883d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
47983d7f9feSTom Erickson 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
48083d7f9feSTom Erickson 	    "<size> | none", "RESERV");
48183d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
482*4c2bdae2STim Chase 	    ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
48383d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
484a9799022Sck 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
48583d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
486a9799022Sck 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
487a9799022Sck 	    "<size> | none", "REFRESERV");
488a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
489a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
490a2afb611SJerry Jelinek 	    "<count> | none", "FSLIMIT");
491a2afb611SJerry Jelinek 	zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
492a2afb611SJerry Jelinek 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
493a2afb611SJerry Jelinek 	    "<count> | none", "SSLIMIT");
49491ebeef5Sahrens 
49591ebeef5Sahrens 	/* inherit number properties */
49683d7f9feSTom Erickson 	zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
497b5152584SMatthew Ahrens 	    SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,
498b5152584SMatthew Ahrens 	    ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE");
499663207adSDon Brady 	zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,
500663207adSDon Brady 	    "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
501663207adSDon Brady 	    "zero or 512 to 128K, power of 2", "SPECIAL_SMALL_BLOCKS");
50291ebeef5Sahrens 
50391ebeef5Sahrens 	/* hidden properties */
5045cabbc6bSPrashanth Sreenivasa 	zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,
5055cabbc6bSPrashanth Sreenivasa 	    PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG");
50683d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
507b24ab676SJeff Bonwick 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
50883d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
50978f17100SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME");
51083d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
51183d7f9feSTom Erickson 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
51283d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
513478ed9adSEric Taylor 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
514478ed9adSEric Taylor 	    "STMF_SBD_LU");
51583d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
516b24ab676SJeff Bonwick 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
517b24ab676SJeff Bonwick 	    "USERACCOUNTING");
51883d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
519b24ab676SJeff Bonwick 	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
52083d7f9feSTom Erickson 	zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
5211d713200SEric Schrock 	    PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
522ca48f36fSKeith M Wesolowski 	zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
523ca48f36fSKeith M Wesolowski 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT");
524eb633035STom Caputi 	zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid",
525eb633035STom Caputi 	    PROP_TYPE_NUMBER, PROP_READONLY,
526eb633035STom Caputi 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID");
527b461c746SMatthew Ahrens 	zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
528b461c746SMatthew Ahrens 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP");
529eb633035STom Caputi 	zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",
530eb633035STom Caputi 	    PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,
531eb633035STom Caputi 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT");
532eb633035STom Caputi 	zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,
533eb633035STom Caputi 	    PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID");
53491ebeef5Sahrens 
53591ebeef5Sahrens 	/* oddball properties */
53683d7f9feSTom Erickson 	zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
53778f17100SMatthew Ahrens 	    NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
53891ebeef5Sahrens 	    "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
53991ebeef5Sahrens }
54091ebeef5Sahrens 
541b1b8ab34Slling boolean_t
zfs_prop_delegatable(zfs_prop_t prop)542990b4856Slling zfs_prop_delegatable(zfs_prop_t prop)
543fa9e4066Sahrens {
544990b4856Slling 	zprop_desc_t *pd = &zfs_prop_table[prop];
5454201a95eSRic Aleshire 
5464201a95eSRic Aleshire 	/* The mlslabel property is never delegatable. */
5474201a95eSRic Aleshire 	if (prop == ZFS_PROP_MLSLABEL)
5484201a95eSRic Aleshire 		return (B_FALSE);
5494201a95eSRic Aleshire 
550990b4856Slling 	return (pd->pd_attr != PROP_READONLY);
551fa9e4066Sahrens }
552fa9e4066Sahrens 
553b1b8ab34Slling /*
554b1b8ab34Slling  * Given a zfs dataset property name, returns the corresponding property ID.
555b1b8ab34Slling  */
556b1b8ab34Slling zfs_prop_t
zfs_name_to_prop(const char * propname)557b1b8ab34Slling zfs_name_to_prop(const char *propname)
558b1b8ab34Slling {
559990b4856Slling 	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
560b1b8ab34Slling }
561b1b8ab34Slling 
562e9dbad6fSeschrock /*
563e9dbad6fSeschrock  * For user property names, we allow all lowercase alphanumeric characters, plus
564e9dbad6fSeschrock  * a few useful punctuation characters.
565e9dbad6fSeschrock  */
566e9dbad6fSeschrock static int
valid_char(char c)567e9dbad6fSeschrock valid_char(char c)
568e9dbad6fSeschrock {
569e9dbad6fSeschrock 	return ((c >= 'a' && c <= 'z') ||
570e9dbad6fSeschrock 	    (c >= '0' && c <= '9') ||
571e9dbad6fSeschrock 	    c == '-' || c == '_' || c == '.' || c == ':');
572e9dbad6fSeschrock }
573e9dbad6fSeschrock 
574e9dbad6fSeschrock /*
575e9dbad6fSeschrock  * Returns true if this is a valid user-defined property (one with a ':').
576e9dbad6fSeschrock  */
577e9dbad6fSeschrock boolean_t
zfs_prop_user(const char * name)578e9dbad6fSeschrock zfs_prop_user(const char *name)
579e9dbad6fSeschrock {
580e9dbad6fSeschrock 	int i;
581e9dbad6fSeschrock 	char c;
582e9dbad6fSeschrock 	boolean_t foundsep = B_FALSE;
583e9dbad6fSeschrock 
584e9dbad6fSeschrock 	for (i = 0; i < strlen(name); i++) {
585e9dbad6fSeschrock 		c = name[i];
586e9dbad6fSeschrock 		if (!valid_char(c))
587e9dbad6fSeschrock 			return (B_FALSE);
588e9dbad6fSeschrock 		if (c == ':')
589e9dbad6fSeschrock 			foundsep = B_TRUE;
590e9dbad6fSeschrock 	}
591e9dbad6fSeschrock 
592e9dbad6fSeschrock 	if (!foundsep)
593e9dbad6fSeschrock 		return (B_FALSE);
594e9dbad6fSeschrock 
595e9dbad6fSeschrock 	return (B_TRUE);
596e9dbad6fSeschrock }
597e9dbad6fSeschrock 
59814843421SMatthew Ahrens /*
59914843421SMatthew Ahrens  * Returns true if this is a valid userspace-type property (one with a '@').
60014843421SMatthew Ahrens  * Note that after the @, any character is valid (eg, another @, for SID
60114843421SMatthew Ahrens  * user@domain).
60214843421SMatthew Ahrens  */
60314843421SMatthew Ahrens boolean_t
zfs_prop_userquota(const char * name)60414843421SMatthew Ahrens zfs_prop_userquota(const char *name)
60514843421SMatthew Ahrens {
60614843421SMatthew Ahrens 	zfs_userquota_prop_t prop;
60714843421SMatthew Ahrens 
60814843421SMatthew Ahrens 	for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
60914843421SMatthew Ahrens 		if (strncmp(name, zfs_userquota_prop_prefixes[prop],
61014843421SMatthew Ahrens 		    strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
61114843421SMatthew Ahrens 			return (B_TRUE);
61214843421SMatthew Ahrens 		}
61314843421SMatthew Ahrens 	}
61414843421SMatthew Ahrens 
61514843421SMatthew Ahrens 	return (B_FALSE);
61614843421SMatthew Ahrens }
61714843421SMatthew Ahrens 
61819b94df9SMatthew Ahrens /*
61919b94df9SMatthew Ahrens  * Returns true if this is a valid written@ property.
62019b94df9SMatthew Ahrens  * Note that after the @, any character is valid (eg, another @, for
62119b94df9SMatthew Ahrens  * written@pool/fs@origin).
62219b94df9SMatthew Ahrens  */
62319b94df9SMatthew Ahrens boolean_t
zfs_prop_written(const char * name)62419b94df9SMatthew Ahrens zfs_prop_written(const char *name)
62519b94df9SMatthew Ahrens {
62619b94df9SMatthew Ahrens 	static const char *prefix = "written@";
62719b94df9SMatthew Ahrens 	return (strncmp(name, prefix, strlen(prefix)) == 0);
62819b94df9SMatthew Ahrens }
62919b94df9SMatthew Ahrens 
630fa9e4066Sahrens /*
631990b4856Slling  * Tables of index types, plus functions to convert between the user view
632990b4856Slling  * (strings) and internal representation (uint64_t).
633fa9e4066Sahrens  */
634990b4856Slling int
zfs_prop_string_to_index(zfs_prop_t prop,const char * string,uint64_t * index)635990b4856Slling zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
636fa9e4066Sahrens {
637990b4856Slling 	return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
638fa9e4066Sahrens }
639fa9e4066Sahrens 
640990b4856Slling int
zfs_prop_index_to_string(zfs_prop_t prop,uint64_t index,const char ** string)641990b4856Slling zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
6423d7072f8Seschrock {
643990b4856Slling 	return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
6443d7072f8Seschrock }
6453d7072f8Seschrock 
646b24ab676SJeff Bonwick uint64_t
zfs_prop_random_value(zfs_prop_t prop,uint64_t seed)647b24ab676SJeff Bonwick zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
648b24ab676SJeff Bonwick {
649b24ab676SJeff Bonwick 	return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
650b24ab676SJeff Bonwick }
651b24ab676SJeff Bonwick 
652990b4856Slling /*
653990b4856Slling  * Returns TRUE if the property applies to any of the given dataset types.
654990b4856Slling  */
6554853e976Sgw boolean_t
zfs_prop_valid_for_type(int prop,zfs_type_t types,boolean_t headcheck)656*4c2bdae2STim Chase zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck)
657fa9e4066Sahrens {
658*4c2bdae2STim Chase 	return (zprop_valid_for_type(prop, types, headcheck));
659fa9e4066Sahrens }
660fa9e4066Sahrens 
661990b4856Slling zprop_type_t
zfs_prop_get_type(zfs_prop_t prop)662990b4856Slling zfs_prop_get_type(zfs_prop_t prop)
6633d7072f8Seschrock {
664990b4856Slling 	return (zfs_prop_table[prop].pd_proptype);
6653d7072f8Seschrock }
6663d7072f8Seschrock 
667fa9e4066Sahrens /*
668fa9e4066Sahrens  * Returns TRUE if the property is readonly.
669fa9e4066Sahrens  */
670990b4856Slling boolean_t
zfs_prop_readonly(zfs_prop_t prop)671fa9e4066Sahrens zfs_prop_readonly(zfs_prop_t prop)
672fa9e4066Sahrens {
673da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
674eb633035STom Caputi 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
675eb633035STom Caputi 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
676da6c28aaSamw }
677da6c28aaSamw 
678dfc11533SChris Williamson /*
679dfc11533SChris Williamson  * Returns TRUE if the property is visible (not hidden).
680dfc11533SChris Williamson  */
681dfc11533SChris Williamson boolean_t
zfs_prop_visible(zfs_prop_t prop)682dfc11533SChris Williamson zfs_prop_visible(zfs_prop_t prop)
683dfc11533SChris Williamson {
684dfc11533SChris Williamson 	return (zfs_prop_table[prop].pd_visible);
685dfc11533SChris Williamson }
686dfc11533SChris Williamson 
687da6c28aaSamw /*
688da6c28aaSamw  * Returns TRUE if the property is only allowed to be set once.
689da6c28aaSamw  */
690da6c28aaSamw boolean_t
zfs_prop_setonce(zfs_prop_t prop)691da6c28aaSamw zfs_prop_setonce(zfs_prop_t prop)
692da6c28aaSamw {
693eb633035STom Caputi 	return (zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
694eb633035STom Caputi 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
695fa9e4066Sahrens }
696fa9e4066Sahrens 
697fa9e4066Sahrens const char *
zfs_prop_default_string(zfs_prop_t prop)698990b4856Slling zfs_prop_default_string(zfs_prop_t prop)
699fa9e4066Sahrens {
700990b4856Slling 	return (zfs_prop_table[prop].pd_strdefault);
701990b4856Slling }
702990b4856Slling 
703990b4856Slling uint64_t
zfs_prop_default_numeric(zfs_prop_t prop)704990b4856Slling zfs_prop_default_numeric(zfs_prop_t prop)
705990b4856Slling {
706990b4856Slling 	return (zfs_prop_table[prop].pd_numdefault);
707fa9e4066Sahrens }
708fa9e4066Sahrens 
709b1b8ab34Slling /*
710990b4856Slling  * Given a dataset property ID, returns the corresponding name.
711990b4856Slling  * Assuming the zfs dataset property ID is valid.
712b1b8ab34Slling  */
713b1b8ab34Slling const char *
zfs_prop_to_name(zfs_prop_t prop)714990b4856Slling zfs_prop_to_name(zfs_prop_t prop)
715b1b8ab34Slling {
716b1b8ab34Slling 	return (zfs_prop_table[prop].pd_name);
717b1b8ab34Slling }
718b1b8ab34Slling 
719fa9e4066Sahrens /*
720fa9e4066Sahrens  * Returns TRUE if the property is inheritable.
721fa9e4066Sahrens  */
722990b4856Slling boolean_t
zfs_prop_inheritable(zfs_prop_t prop)723fa9e4066Sahrens zfs_prop_inheritable(zfs_prop_t prop)
724fa9e4066Sahrens {
725da6c28aaSamw 	return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
726da6c28aaSamw 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
727e9dbad6fSeschrock }
728e9dbad6fSeschrock 
729eb633035STom Caputi /*
730eb633035STom Caputi  * Returns TRUE if property is one of the encryption properties that requires
731eb633035STom Caputi  * a loaded encryption key to modify.
732eb633035STom Caputi  */
733eb633035STom Caputi boolean_t
zfs_prop_encryption_key_param(zfs_prop_t prop)734eb633035STom Caputi zfs_prop_encryption_key_param(zfs_prop_t prop)
735eb633035STom Caputi {
736eb633035STom Caputi 	/*
737eb633035STom Caputi 	 * keylocation does not count as an encryption property. It can be
738eb633035STom Caputi 	 * changed at will without needing the master keys.
739eb633035STom Caputi 	 */
740eb633035STom Caputi 	return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS ||
741eb633035STom Caputi 	    prop == ZFS_PROP_KEYFORMAT);
742eb633035STom Caputi }
743eb633035STom Caputi 
744eb633035STom Caputi /*
745eb633035STom Caputi  * Helper function used by both kernelspace and userspace to check the
746eb633035STom Caputi  * keylocation property. If encrypted is set, the keylocation must be valid
747eb633035STom Caputi  * for an encrypted dataset.
748eb633035STom Caputi  */
749eb633035STom Caputi boolean_t
zfs_prop_valid_keylocation(const char * str,boolean_t encrypted)750eb633035STom Caputi zfs_prop_valid_keylocation(const char *str, boolean_t encrypted)
751eb633035STom Caputi {
752eb633035STom Caputi 	if (strcmp("none", str) == 0)
753eb633035STom Caputi 		return (!encrypted);
754eb633035STom Caputi 	else if (strcmp("prompt", str) == 0)
755eb633035STom Caputi 		return (B_TRUE);
756eb633035STom Caputi 	else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0)
757eb633035STom Caputi 		return (B_TRUE);
758eb633035STom Caputi 
759eb633035STom Caputi 	return (B_FALSE);
760eb633035STom Caputi }
761eb633035STom Caputi 
762eb633035STom Caputi 
763acd76fe5Seschrock #ifndef _KERNEL
764acd76fe5Seschrock 
765fa9e4066Sahrens /*
766b1b8ab34Slling  * Returns a string describing the set of acceptable values for the given
767b1b8ab34Slling  * zfs property, or NULL if it cannot be set.
768fa9e4066Sahrens  */
769b1b8ab34Slling const char *
zfs_prop_values(zfs_prop_t prop)770b1b8ab34Slling zfs_prop_values(zfs_prop_t prop)
771fa9e4066Sahrens {
772fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_values);
773fa9e4066Sahrens }
774fa9e4066Sahrens 
775fa9e4066Sahrens /*
776fa9e4066Sahrens  * Returns TRUE if this property is a string type.  Note that index types
777fa9e4066Sahrens  * (compression, checksum) are treated as strings in userland, even though they
778fa9e4066Sahrens  * are stored numerically on disk.
779fa9e4066Sahrens  */
780fa9e4066Sahrens int
zfs_prop_is_string(zfs_prop_t prop)781fa9e4066Sahrens zfs_prop_is_string(zfs_prop_t prop)
782fa9e4066Sahrens {
78391ebeef5Sahrens 	return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
78491ebeef5Sahrens 	    zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
785fa9e4066Sahrens }
786fa9e4066Sahrens 
787fa9e4066Sahrens /*
788fa9e4066Sahrens  * Returns the column header for the given property.  Used only in
789fa9e4066Sahrens  * 'zfs list -o', but centralized here with the other property information.
790fa9e4066Sahrens  */
791fa9e4066Sahrens const char *
zfs_prop_column_name(zfs_prop_t prop)792fa9e4066Sahrens zfs_prop_column_name(zfs_prop_t prop)
793fa9e4066Sahrens {
794fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_colname);
795fa9e4066Sahrens }
796fa9e4066Sahrens 
797fa9e4066Sahrens /*
798e9dbad6fSeschrock  * Returns whether the given property should be displayed right-justified for
799e9dbad6fSeschrock  * 'zfs list'.
800fa9e4066Sahrens  */
801e9dbad6fSeschrock boolean_t
zfs_prop_align_right(zfs_prop_t prop)802e9dbad6fSeschrock zfs_prop_align_right(zfs_prop_t prop)
803fa9e4066Sahrens {
804e9dbad6fSeschrock 	return (zfs_prop_table[prop].pd_rightalign);
805fa9e4066Sahrens }
806da6c28aaSamw 
807fa9e4066Sahrens #endif
808