xref: /freebsd/sys/contrib/openzfs/module/zcommon/zfs_prop.c (revision e92ffd9b626833ebdbf2742c8ffddc6cd94b963e)
1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9eda14cbcSMatt Macy  * or http://www.opensolaris.org/os/licensing.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy /*
22eda14cbcSMatt Macy  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23eda14cbcSMatt Macy  * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
24eda14cbcSMatt Macy  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25eda14cbcSMatt Macy  * Copyright 2016, Joyent, Inc.
26eda14cbcSMatt Macy  * Copyright (c) 2019, Klara Inc.
27eda14cbcSMatt Macy  * Copyright (c) 2019, Allan Jude
28eda14cbcSMatt Macy  */
29eda14cbcSMatt Macy 
30eda14cbcSMatt Macy /* Portions Copyright 2010 Robert Milkowski */
31eda14cbcSMatt Macy 
32eda14cbcSMatt Macy #include <sys/zio.h>
33eda14cbcSMatt Macy #include <sys/spa.h>
34eda14cbcSMatt Macy #include <sys/u8_textprep.h>
35eda14cbcSMatt Macy #include <sys/zfs_acl.h>
36eda14cbcSMatt Macy #include <sys/zfs_ioctl.h>
37eda14cbcSMatt Macy #include <sys/zfs_znode.h>
38eda14cbcSMatt Macy #include <sys/dsl_crypt.h>
39eda14cbcSMatt Macy 
40eda14cbcSMatt Macy #include "zfs_prop.h"
41eda14cbcSMatt Macy #include "zfs_deleg.h"
42eda14cbcSMatt Macy #include "zfs_fletcher.h"
43eda14cbcSMatt Macy 
44eda14cbcSMatt Macy #if !defined(_KERNEL)
45eda14cbcSMatt Macy #include <stdlib.h>
46eda14cbcSMatt Macy #include <string.h>
47eda14cbcSMatt Macy #include <ctype.h>
48eda14cbcSMatt Macy #endif
49eda14cbcSMatt Macy 
50eda14cbcSMatt Macy static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
51eda14cbcSMatt Macy 
52eda14cbcSMatt Macy /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
53*e92ffd9bSMartin Matuska const char *const zfs_userquota_prop_prefixes[] = {
54eda14cbcSMatt Macy 	"userused@",
55eda14cbcSMatt Macy 	"userquota@",
56eda14cbcSMatt Macy 	"groupused@",
57eda14cbcSMatt Macy 	"groupquota@",
58eda14cbcSMatt Macy 	"userobjused@",
59eda14cbcSMatt Macy 	"userobjquota@",
60eda14cbcSMatt Macy 	"groupobjused@",
61eda14cbcSMatt Macy 	"groupobjquota@",
62eda14cbcSMatt Macy 	"projectused@",
63eda14cbcSMatt Macy 	"projectquota@",
64eda14cbcSMatt Macy 	"projectobjused@",
65eda14cbcSMatt Macy 	"projectobjquota@"
66eda14cbcSMatt Macy };
67eda14cbcSMatt Macy 
68eda14cbcSMatt Macy zprop_desc_t *
69eda14cbcSMatt Macy zfs_prop_get_table(void)
70eda14cbcSMatt Macy {
71eda14cbcSMatt Macy 	return (zfs_prop_table);
72eda14cbcSMatt Macy }
73eda14cbcSMatt Macy 
74eda14cbcSMatt Macy void
75eda14cbcSMatt Macy zfs_prop_init(void)
76eda14cbcSMatt Macy {
77*e92ffd9bSMartin Matuska 	static const zprop_index_t checksum_table[] = {
78eda14cbcSMatt Macy 		{ "on",		ZIO_CHECKSUM_ON },
79eda14cbcSMatt Macy 		{ "off",	ZIO_CHECKSUM_OFF },
80eda14cbcSMatt Macy 		{ "fletcher2",	ZIO_CHECKSUM_FLETCHER_2 },
81eda14cbcSMatt Macy 		{ "fletcher4",	ZIO_CHECKSUM_FLETCHER_4 },
82eda14cbcSMatt Macy 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
83eda14cbcSMatt Macy 		{ "noparity",   ZIO_CHECKSUM_NOPARITY },
84eda14cbcSMatt Macy 		{ "sha512",	ZIO_CHECKSUM_SHA512 },
85eda14cbcSMatt Macy 		{ "skein",	ZIO_CHECKSUM_SKEIN },
86eda14cbcSMatt Macy 		{ "edonr",	ZIO_CHECKSUM_EDONR },
87eda14cbcSMatt Macy 		{ NULL }
88eda14cbcSMatt Macy 	};
89eda14cbcSMatt Macy 
90*e92ffd9bSMartin Matuska 	static const zprop_index_t dedup_table[] = {
91eda14cbcSMatt Macy 		{ "on",		ZIO_CHECKSUM_ON },
92eda14cbcSMatt Macy 		{ "off",	ZIO_CHECKSUM_OFF },
93eda14cbcSMatt Macy 		{ "verify",	ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
94eda14cbcSMatt Macy 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
95eda14cbcSMatt Macy 		{ "sha256,verify",
96eda14cbcSMatt Macy 				ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
97eda14cbcSMatt Macy 		{ "sha512",	ZIO_CHECKSUM_SHA512 },
98eda14cbcSMatt Macy 		{ "sha512,verify",
99eda14cbcSMatt Macy 				ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY },
100eda14cbcSMatt Macy 		{ "skein",	ZIO_CHECKSUM_SKEIN },
101eda14cbcSMatt Macy 		{ "skein,verify",
102eda14cbcSMatt Macy 				ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY },
103eda14cbcSMatt Macy 		{ "edonr,verify",
104eda14cbcSMatt Macy 				ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY },
105eda14cbcSMatt Macy 		{ NULL }
106eda14cbcSMatt Macy 	};
107eda14cbcSMatt Macy 
108*e92ffd9bSMartin Matuska 	static const zprop_index_t compress_table[] = {
109eda14cbcSMatt Macy 		{ "on",		ZIO_COMPRESS_ON },
110eda14cbcSMatt Macy 		{ "off",	ZIO_COMPRESS_OFF },
111eda14cbcSMatt Macy 		{ "lzjb",	ZIO_COMPRESS_LZJB },
112eda14cbcSMatt Macy 		{ "gzip",	ZIO_COMPRESS_GZIP_6 },	/* gzip default */
113eda14cbcSMatt Macy 		{ "gzip-1",	ZIO_COMPRESS_GZIP_1 },
114eda14cbcSMatt Macy 		{ "gzip-2",	ZIO_COMPRESS_GZIP_2 },
115eda14cbcSMatt Macy 		{ "gzip-3",	ZIO_COMPRESS_GZIP_3 },
116eda14cbcSMatt Macy 		{ "gzip-4",	ZIO_COMPRESS_GZIP_4 },
117eda14cbcSMatt Macy 		{ "gzip-5",	ZIO_COMPRESS_GZIP_5 },
118eda14cbcSMatt Macy 		{ "gzip-6",	ZIO_COMPRESS_GZIP_6 },
119eda14cbcSMatt Macy 		{ "gzip-7",	ZIO_COMPRESS_GZIP_7 },
120eda14cbcSMatt Macy 		{ "gzip-8",	ZIO_COMPRESS_GZIP_8 },
121eda14cbcSMatt Macy 		{ "gzip-9",	ZIO_COMPRESS_GZIP_9 },
122eda14cbcSMatt Macy 		{ "zle",	ZIO_COMPRESS_ZLE },
123eda14cbcSMatt Macy 		{ "lz4",	ZIO_COMPRESS_LZ4 },
124eda14cbcSMatt Macy 		{ "zstd",	ZIO_COMPRESS_ZSTD },
125eda14cbcSMatt Macy 		{ "zstd-fast",
126eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_DEFAULT) },
127eda14cbcSMatt Macy 
128eda14cbcSMatt Macy 		/*
129eda14cbcSMatt Macy 		 * ZSTD 1-19 are synthetic. We store the compression level in a
130eda14cbcSMatt Macy 		 * separate hidden property to avoid wasting a large amount of
131eda14cbcSMatt Macy 		 * space in the ZIO_COMPRESS enum.
132eda14cbcSMatt Macy 		 *
133eda14cbcSMatt Macy 		 * The compression level is also stored within the header of the
134eda14cbcSMatt Macy 		 * compressed block since we may need it for later recompression
135eda14cbcSMatt Macy 		 * to avoid checksum errors (L2ARC).
136eda14cbcSMatt Macy 		 *
137eda14cbcSMatt Macy 		 * Note that the level here is defined as bit shifted mask on
138eda14cbcSMatt Macy 		 * top of the method.
139eda14cbcSMatt Macy 		 */
140eda14cbcSMatt Macy 		{ "zstd-1",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_1) },
141eda14cbcSMatt Macy 		{ "zstd-2",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_2) },
142eda14cbcSMatt Macy 		{ "zstd-3",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_3) },
143eda14cbcSMatt Macy 		{ "zstd-4",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_4) },
144eda14cbcSMatt Macy 		{ "zstd-5",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_5) },
145eda14cbcSMatt Macy 		{ "zstd-6",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_6) },
146eda14cbcSMatt Macy 		{ "zstd-7",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_7) },
147eda14cbcSMatt Macy 		{ "zstd-8",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_8) },
148eda14cbcSMatt Macy 		{ "zstd-9",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_9) },
149eda14cbcSMatt Macy 		{ "zstd-10",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_10) },
150eda14cbcSMatt Macy 		{ "zstd-11",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_11) },
151eda14cbcSMatt Macy 		{ "zstd-12",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_12) },
152eda14cbcSMatt Macy 		{ "zstd-13",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_13) },
153eda14cbcSMatt Macy 		{ "zstd-14",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_14) },
154eda14cbcSMatt Macy 		{ "zstd-15",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_15) },
155eda14cbcSMatt Macy 		{ "zstd-16",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_16) },
156eda14cbcSMatt Macy 		{ "zstd-17",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_17) },
157eda14cbcSMatt Macy 		{ "zstd-18",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_18) },
158eda14cbcSMatt Macy 		{ "zstd-19",	ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_19) },
159eda14cbcSMatt Macy 
160eda14cbcSMatt Macy 		/*
161eda14cbcSMatt Macy 		 * The ZSTD-Fast levels are also synthetic.
162eda14cbcSMatt Macy 		 */
163eda14cbcSMatt Macy 		{ "zstd-fast-1",
164eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1) },
165eda14cbcSMatt Macy 		{ "zstd-fast-2",
166eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_2) },
167eda14cbcSMatt Macy 		{ "zstd-fast-3",
168eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_3) },
169eda14cbcSMatt Macy 		{ "zstd-fast-4",
170eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_4) },
171eda14cbcSMatt Macy 		{ "zstd-fast-5",
172eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_5) },
173eda14cbcSMatt Macy 		{ "zstd-fast-6",
174eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_6) },
175eda14cbcSMatt Macy 		{ "zstd-fast-7",
176eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_7) },
177eda14cbcSMatt Macy 		{ "zstd-fast-8",
178eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_8) },
179eda14cbcSMatt Macy 		{ "zstd-fast-9",
180eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_9) },
181eda14cbcSMatt Macy 		{ "zstd-fast-10",
182eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_10) },
183eda14cbcSMatt Macy 		{ "zstd-fast-20",
184eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_20) },
185eda14cbcSMatt Macy 		{ "zstd-fast-30",
186eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_30) },
187eda14cbcSMatt Macy 		{ "zstd-fast-40",
188eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_40) },
189eda14cbcSMatt Macy 		{ "zstd-fast-50",
190eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_50) },
191eda14cbcSMatt Macy 		{ "zstd-fast-60",
192eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_60) },
193eda14cbcSMatt Macy 		{ "zstd-fast-70",
194eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_70) },
195eda14cbcSMatt Macy 		{ "zstd-fast-80",
196eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_80) },
197eda14cbcSMatt Macy 		{ "zstd-fast-90",
198eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_90) },
199eda14cbcSMatt Macy 		{ "zstd-fast-100",
200eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_100) },
201eda14cbcSMatt Macy 		{ "zstd-fast-500",
202eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_500) },
203eda14cbcSMatt Macy 		{ "zstd-fast-1000",
204eda14cbcSMatt Macy 		    ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1000) },
205eda14cbcSMatt Macy 		{ NULL }
206eda14cbcSMatt Macy 	};
207eda14cbcSMatt Macy 
208*e92ffd9bSMartin Matuska 	static const zprop_index_t crypto_table[] = {
209eda14cbcSMatt Macy 		{ "on",			ZIO_CRYPT_ON },
210eda14cbcSMatt Macy 		{ "off",		ZIO_CRYPT_OFF },
211eda14cbcSMatt Macy 		{ "aes-128-ccm",	ZIO_CRYPT_AES_128_CCM },
212eda14cbcSMatt Macy 		{ "aes-192-ccm",	ZIO_CRYPT_AES_192_CCM },
213eda14cbcSMatt Macy 		{ "aes-256-ccm",	ZIO_CRYPT_AES_256_CCM },
214eda14cbcSMatt Macy 		{ "aes-128-gcm",	ZIO_CRYPT_AES_128_GCM },
215eda14cbcSMatt Macy 		{ "aes-192-gcm",	ZIO_CRYPT_AES_192_GCM },
216eda14cbcSMatt Macy 		{ "aes-256-gcm",	ZIO_CRYPT_AES_256_GCM },
217eda14cbcSMatt Macy 		{ NULL }
218eda14cbcSMatt Macy 	};
219eda14cbcSMatt Macy 
220*e92ffd9bSMartin Matuska 	static const zprop_index_t keyformat_table[] = {
221eda14cbcSMatt Macy 		{ "none",		ZFS_KEYFORMAT_NONE },
222eda14cbcSMatt Macy 		{ "raw",		ZFS_KEYFORMAT_RAW },
223eda14cbcSMatt Macy 		{ "hex",		ZFS_KEYFORMAT_HEX },
224eda14cbcSMatt Macy 		{ "passphrase",		ZFS_KEYFORMAT_PASSPHRASE },
225eda14cbcSMatt Macy 		{ NULL }
226eda14cbcSMatt Macy 	};
227eda14cbcSMatt Macy 
228*e92ffd9bSMartin Matuska 	static const zprop_index_t snapdir_table[] = {
229eda14cbcSMatt Macy 		{ "hidden",	ZFS_SNAPDIR_HIDDEN },
230eda14cbcSMatt Macy 		{ "visible",	ZFS_SNAPDIR_VISIBLE },
231eda14cbcSMatt Macy 		{ NULL }
232eda14cbcSMatt Macy 	};
233eda14cbcSMatt Macy 
234*e92ffd9bSMartin Matuska 	static const zprop_index_t snapdev_table[] = {
235eda14cbcSMatt Macy 		{ "hidden",	ZFS_SNAPDEV_HIDDEN },
236eda14cbcSMatt Macy 		{ "visible",	ZFS_SNAPDEV_VISIBLE },
237eda14cbcSMatt Macy 		{ NULL }
238eda14cbcSMatt Macy 	};
239eda14cbcSMatt Macy 
240*e92ffd9bSMartin Matuska 	static const zprop_index_t acl_mode_table[] = {
241eda14cbcSMatt Macy 		{ "discard",	ZFS_ACL_DISCARD },
242eda14cbcSMatt Macy 		{ "groupmask",	ZFS_ACL_GROUPMASK },
243eda14cbcSMatt Macy 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
244eda14cbcSMatt Macy 		{ "restricted",	ZFS_ACL_RESTRICTED },
245eda14cbcSMatt Macy 		{ NULL }
246eda14cbcSMatt Macy 	};
247eda14cbcSMatt Macy 
248*e92ffd9bSMartin Matuska 	static const zprop_index_t acltype_table[] = {
249eda14cbcSMatt Macy 		{ "off",	ZFS_ACLTYPE_OFF },
2502c48331dSMatt Macy 		{ "posix",	ZFS_ACLTYPE_POSIX },
251180f8225SMatt Macy 		{ "nfsv4",	ZFS_ACLTYPE_NFSV4 },
2522c48331dSMatt Macy 		{ "disabled",	ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
2532c48331dSMatt Macy 		{ "noacl",	ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
2542c48331dSMatt Macy 		{ "posixacl",	ZFS_ACLTYPE_POSIX }, /* bkwrd compatibility */
255eda14cbcSMatt Macy 		{ NULL }
256eda14cbcSMatt Macy 	};
257eda14cbcSMatt Macy 
258*e92ffd9bSMartin Matuska 	static const zprop_index_t acl_inherit_table[] = {
259eda14cbcSMatt Macy 		{ "discard",	ZFS_ACL_DISCARD },
260eda14cbcSMatt Macy 		{ "noallow",	ZFS_ACL_NOALLOW },
261eda14cbcSMatt Macy 		{ "restricted",	ZFS_ACL_RESTRICTED },
262eda14cbcSMatt Macy 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
263eda14cbcSMatt Macy 		{ "secure",	ZFS_ACL_RESTRICTED }, /* bkwrd compatibility */
264eda14cbcSMatt Macy 		{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
265eda14cbcSMatt Macy 		{ NULL }
266eda14cbcSMatt Macy 	};
267eda14cbcSMatt Macy 
268*e92ffd9bSMartin Matuska 	static const zprop_index_t case_table[] = {
269eda14cbcSMatt Macy 		{ "sensitive",		ZFS_CASE_SENSITIVE },
270eda14cbcSMatt Macy 		{ "insensitive",	ZFS_CASE_INSENSITIVE },
271eda14cbcSMatt Macy 		{ "mixed",		ZFS_CASE_MIXED },
272eda14cbcSMatt Macy 		{ NULL }
273eda14cbcSMatt Macy 	};
274eda14cbcSMatt Macy 
275*e92ffd9bSMartin Matuska 	static const zprop_index_t copies_table[] = {
276eda14cbcSMatt Macy 		{ "1",		1 },
277eda14cbcSMatt Macy 		{ "2",		2 },
278eda14cbcSMatt Macy 		{ "3",		3 },
279eda14cbcSMatt Macy 		{ NULL }
280eda14cbcSMatt Macy 	};
281eda14cbcSMatt Macy 
282eda14cbcSMatt Macy 	/*
283eda14cbcSMatt Macy 	 * Use the unique flags we have to send to u8_strcmp() and/or
284eda14cbcSMatt Macy 	 * u8_textprep() to represent the various normalization property
285eda14cbcSMatt Macy 	 * values.
286eda14cbcSMatt Macy 	 */
287*e92ffd9bSMartin Matuska 	static const zprop_index_t normalize_table[] = {
288eda14cbcSMatt Macy 		{ "none",	0 },
289eda14cbcSMatt Macy 		{ "formD",	U8_TEXTPREP_NFD },
290eda14cbcSMatt Macy 		{ "formKC",	U8_TEXTPREP_NFKC },
291eda14cbcSMatt Macy 		{ "formC",	U8_TEXTPREP_NFC },
292eda14cbcSMatt Macy 		{ "formKD",	U8_TEXTPREP_NFKD },
293eda14cbcSMatt Macy 		{ NULL }
294eda14cbcSMatt Macy 	};
295eda14cbcSMatt Macy 
296*e92ffd9bSMartin Matuska 	static const zprop_index_t version_table[] = {
297eda14cbcSMatt Macy 		{ "1",		1 },
298eda14cbcSMatt Macy 		{ "2",		2 },
299eda14cbcSMatt Macy 		{ "3",		3 },
300eda14cbcSMatt Macy 		{ "4",		4 },
301eda14cbcSMatt Macy 		{ "5",		5 },
302eda14cbcSMatt Macy 		{ "current",	ZPL_VERSION },
303eda14cbcSMatt Macy 		{ NULL }
304eda14cbcSMatt Macy 	};
305eda14cbcSMatt Macy 
306*e92ffd9bSMartin Matuska 	static const zprop_index_t boolean_table[] = {
307eda14cbcSMatt Macy 		{ "off",	0 },
308eda14cbcSMatt Macy 		{ "on",		1 },
309eda14cbcSMatt Macy 		{ NULL }
310eda14cbcSMatt Macy 	};
311eda14cbcSMatt Macy 
312*e92ffd9bSMartin Matuska 	static const zprop_index_t keystatus_table[] = {
313eda14cbcSMatt Macy 		{ "none",		ZFS_KEYSTATUS_NONE},
314eda14cbcSMatt Macy 		{ "unavailable",	ZFS_KEYSTATUS_UNAVAILABLE},
315eda14cbcSMatt Macy 		{ "available",		ZFS_KEYSTATUS_AVAILABLE},
316eda14cbcSMatt Macy 		{ NULL }
317eda14cbcSMatt Macy 	};
318eda14cbcSMatt Macy 
319*e92ffd9bSMartin Matuska 	static const zprop_index_t logbias_table[] = {
320eda14cbcSMatt Macy 		{ "latency",	ZFS_LOGBIAS_LATENCY },
321eda14cbcSMatt Macy 		{ "throughput",	ZFS_LOGBIAS_THROUGHPUT },
322eda14cbcSMatt Macy 		{ NULL }
323eda14cbcSMatt Macy 	};
324eda14cbcSMatt Macy 
325*e92ffd9bSMartin Matuska 	static const zprop_index_t canmount_table[] = {
326eda14cbcSMatt Macy 		{ "off",	ZFS_CANMOUNT_OFF },
327eda14cbcSMatt Macy 		{ "on",		ZFS_CANMOUNT_ON },
328eda14cbcSMatt Macy 		{ "noauto",	ZFS_CANMOUNT_NOAUTO },
329eda14cbcSMatt Macy 		{ NULL }
330eda14cbcSMatt Macy 	};
331eda14cbcSMatt Macy 
332*e92ffd9bSMartin Matuska 	static const zprop_index_t cache_table[] = {
333eda14cbcSMatt Macy 		{ "none",	ZFS_CACHE_NONE },
334eda14cbcSMatt Macy 		{ "metadata",	ZFS_CACHE_METADATA },
335eda14cbcSMatt Macy 		{ "all",	ZFS_CACHE_ALL },
336eda14cbcSMatt Macy 		{ NULL }
337eda14cbcSMatt Macy 	};
338eda14cbcSMatt Macy 
339*e92ffd9bSMartin Matuska 	static const zprop_index_t sync_table[] = {
340eda14cbcSMatt Macy 		{ "standard",	ZFS_SYNC_STANDARD },
341eda14cbcSMatt Macy 		{ "always",	ZFS_SYNC_ALWAYS },
342eda14cbcSMatt Macy 		{ "disabled",	ZFS_SYNC_DISABLED },
343eda14cbcSMatt Macy 		{ NULL }
344eda14cbcSMatt Macy 	};
345eda14cbcSMatt Macy 
346*e92ffd9bSMartin Matuska 	static const zprop_index_t xattr_table[] = {
347eda14cbcSMatt Macy 		{ "off",	ZFS_XATTR_OFF },
348eda14cbcSMatt Macy 		{ "on",		ZFS_XATTR_DIR },
349eda14cbcSMatt Macy 		{ "sa",		ZFS_XATTR_SA },
350eda14cbcSMatt Macy 		{ "dir",	ZFS_XATTR_DIR },
351eda14cbcSMatt Macy 		{ NULL }
352eda14cbcSMatt Macy 	};
353eda14cbcSMatt Macy 
354*e92ffd9bSMartin Matuska 	static const zprop_index_t dnsize_table[] = {
355eda14cbcSMatt Macy 		{ "legacy",	ZFS_DNSIZE_LEGACY },
356eda14cbcSMatt Macy 		{ "auto",	ZFS_DNSIZE_AUTO },
357eda14cbcSMatt Macy 		{ "1k",		ZFS_DNSIZE_1K },
358eda14cbcSMatt Macy 		{ "2k",		ZFS_DNSIZE_2K },
359eda14cbcSMatt Macy 		{ "4k",		ZFS_DNSIZE_4K },
360eda14cbcSMatt Macy 		{ "8k",		ZFS_DNSIZE_8K },
361eda14cbcSMatt Macy 		{ "16k",	ZFS_DNSIZE_16K },
362eda14cbcSMatt Macy 		{ NULL }
363eda14cbcSMatt Macy 	};
364eda14cbcSMatt Macy 
365*e92ffd9bSMartin Matuska 	static const zprop_index_t redundant_metadata_table[] = {
366eda14cbcSMatt Macy 		{ "all",	ZFS_REDUNDANT_METADATA_ALL },
367eda14cbcSMatt Macy 		{ "most",	ZFS_REDUNDANT_METADATA_MOST },
368eda14cbcSMatt Macy 		{ NULL }
369eda14cbcSMatt Macy 	};
370eda14cbcSMatt Macy 
371*e92ffd9bSMartin Matuska 	static const zprop_index_t volmode_table[] = {
372eda14cbcSMatt Macy 		{ "default",	ZFS_VOLMODE_DEFAULT },
373eda14cbcSMatt Macy 		{ "full",	ZFS_VOLMODE_GEOM },
374eda14cbcSMatt Macy 		{ "geom",	ZFS_VOLMODE_GEOM },
375eda14cbcSMatt Macy 		{ "dev",	ZFS_VOLMODE_DEV },
376eda14cbcSMatt Macy 		{ "none",	ZFS_VOLMODE_NONE },
377eda14cbcSMatt Macy 		{ NULL }
378eda14cbcSMatt Macy 	};
379eda14cbcSMatt Macy 
380*e92ffd9bSMartin Matuska 	struct zfs_mod_supported_features *sfeatures =
381*e92ffd9bSMartin Matuska 	    zfs_mod_list_supported(ZFS_SYSFS_DATASET_PROPERTIES);
382*e92ffd9bSMartin Matuska 
383eda14cbcSMatt Macy 	/* inherit index properties */
384eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
385eda14cbcSMatt Macy 	    ZFS_REDUNDANT_METADATA_ALL,
386eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
387eda14cbcSMatt Macy 	    "all | most", "REDUND_MD",
388*e92ffd9bSMartin Matuska 	    redundant_metadata_table, sfeatures);
389eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
390eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
391eda14cbcSMatt Macy 	    "standard | always | disabled", "SYNC",
392*e92ffd9bSMartin Matuska 	    sync_table, sfeatures);
393eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
394eda14cbcSMatt Macy 	    ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
395eda14cbcSMatt Macy 	    ZFS_TYPE_VOLUME,
396eda14cbcSMatt Macy 	    "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein"
397eda14cbcSMatt Macy 	    " | edonr",
398*e92ffd9bSMartin Matuska 	    "CHECKSUM", checksum_table, sfeatures);
399eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
400eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
401eda14cbcSMatt Macy 	    "on | off | verify | sha256[,verify] | sha512[,verify] | "
402eda14cbcSMatt Macy 	    "skein[,verify] | edonr,verify",
403*e92ffd9bSMartin Matuska 	    "DEDUP", dedup_table, sfeatures);
404eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
405eda14cbcSMatt Macy 	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
406eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
407eda14cbcSMatt Macy 	    "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | "
408eda14cbcSMatt Macy 	    "zstd | zstd-[1-19] | "
4099db44a8eSMartin Matuska 	    "zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]",
410*e92ffd9bSMartin Matuska 	    "COMPRESS", compress_table, sfeatures);
411eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
412eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
413*e92ffd9bSMartin Matuska 	    "hidden | visible", "SNAPDIR", snapdir_table, sfeatures);
414eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN,
415eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
416*e92ffd9bSMartin Matuska 	    "hidden | visible", "SNAPDEV", snapdev_table, sfeatures);
417eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
418eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
419eda14cbcSMatt Macy 	    "discard | groupmask | passthrough | restricted", "ACLMODE",
420*e92ffd9bSMartin Matuska 	    acl_mode_table, sfeatures);
421180f8225SMatt Macy 	zprop_register_index(ZFS_PROP_ACLTYPE, "acltype",
422180f8225SMatt Macy #ifdef __linux__
423180f8225SMatt Macy 	    /* Linux doesn't natively support ZFS's NFSv4-style ACLs. */
424180f8225SMatt Macy 	    ZFS_ACLTYPE_OFF,
425180f8225SMatt Macy #else
426180f8225SMatt Macy 	    ZFS_ACLTYPE_NFSV4,
427eda14cbcSMatt Macy #endif
428180f8225SMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
429*e92ffd9bSMartin Matuska 	    "off | nfsv4 | posix", "ACLTYPE", acltype_table, sfeatures);
430eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
431eda14cbcSMatt Macy 	    ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
432eda14cbcSMatt Macy 	    "discard | noallow | restricted | passthrough | passthrough-x",
433*e92ffd9bSMartin Matuska 	    "ACLINHERIT", acl_inherit_table, sfeatures);
434eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
435eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
436*e92ffd9bSMartin Matuska 	    "1 | 2 | 3", "COPIES", copies_table, sfeatures);
437eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
438eda14cbcSMatt Macy 	    ZFS_CACHE_ALL, PROP_INHERIT,
439eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
440*e92ffd9bSMartin Matuska 	    "all | none | metadata", "PRIMARYCACHE", cache_table, sfeatures);
441eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
442eda14cbcSMatt Macy 	    ZFS_CACHE_ALL, PROP_INHERIT,
443eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
444*e92ffd9bSMartin Matuska 	    "all | none | metadata", "SECONDARYCACHE", cache_table, sfeatures);
445eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
446eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
447*e92ffd9bSMartin Matuska 	    "latency | throughput", "LOGBIAS", logbias_table, sfeatures);
448eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR,
449eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
450*e92ffd9bSMartin Matuska 	    "on | off | dir | sa", "XATTR", xattr_table, sfeatures);
451eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",
452eda14cbcSMatt Macy 	    ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
453*e92ffd9bSMartin Matuska 	    "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table,
454*e92ffd9bSMartin Matuska 	    sfeatures);
455eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_VOLMODE, "volmode",
456eda14cbcSMatt Macy 	    ZFS_VOLMODE_DEFAULT, PROP_INHERIT,
457eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
458*e92ffd9bSMartin Matuska 	    "default | full | geom | dev | none", "VOLMODE", volmode_table,
459*e92ffd9bSMartin Matuska 	    sfeatures);
460eda14cbcSMatt Macy 
461eda14cbcSMatt Macy 	/* inherit index (boolean) properties */
462eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
463*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table, sfeatures);
464eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_RELATIME, "relatime", 0, PROP_INHERIT,
465*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table,
466*e92ffd9bSMartin Matuska 	    sfeatures);
467eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
468eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
469*e92ffd9bSMartin Matuska 	    boolean_table, sfeatures);
470eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
471eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
472*e92ffd9bSMartin Matuska 	    boolean_table, sfeatures);
473eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
474eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
475*e92ffd9bSMartin Matuska 	    boolean_table, sfeatures);
476eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
477eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
478*e92ffd9bSMartin Matuska 	    boolean_table, sfeatures);
479eda14cbcSMatt Macy #ifdef __FreeBSD__
480eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT,
481*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table,
482*e92ffd9bSMartin Matuska 	    sfeatures);
483eda14cbcSMatt Macy #else
484eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
485*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table, sfeatures);
486eda14cbcSMatt Macy #endif
487eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
488*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table, sfeatures);
489eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
490eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
491*e92ffd9bSMartin Matuska 	    boolean_table, sfeatures);
492eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT,
493*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table,
494*e92ffd9bSMartin Matuska 	    sfeatures);
495eda14cbcSMatt Macy 
496eda14cbcSMatt Macy 	/* default index properties */
497eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
498eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
499*e92ffd9bSMartin Matuska 	    "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table, sfeatures);
500eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
501eda14cbcSMatt Macy 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
502*e92ffd9bSMartin Matuska 	    "CANMOUNT", canmount_table, sfeatures);
503eda14cbcSMatt Macy 
504eda14cbcSMatt Macy 	/* readonly index properties */
505eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
506*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table,
507*e92ffd9bSMartin Matuska 	    sfeatures);
508eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
509eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
510*e92ffd9bSMartin Matuska 	    boolean_table, sfeatures);
511eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",
512eda14cbcSMatt Macy 	    ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,
513eda14cbcSMatt Macy 	    "none | unavailable | available",
514*e92ffd9bSMartin Matuska 	    "KEYSTATUS", keystatus_table, sfeatures);
515eda14cbcSMatt Macy 
516eda14cbcSMatt Macy 	/* set once index properties */
517eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
518eda14cbcSMatt Macy 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
519eda14cbcSMatt Macy 	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
520*e92ffd9bSMartin Matuska 	    normalize_table, sfeatures);
521eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
522eda14cbcSMatt Macy 	    ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
523eda14cbcSMatt Macy 	    ZFS_TYPE_SNAPSHOT,
524*e92ffd9bSMartin Matuska 	    "sensitive | insensitive | mixed", "CASE", case_table, sfeatures);
525eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",
526eda14cbcSMatt Macy 	    ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,
527eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
528*e92ffd9bSMartin Matuska 	    "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table,
529*e92ffd9bSMartin Matuska 	    sfeatures);
530eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption",
531eda14cbcSMatt Macy 	    ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET,
532eda14cbcSMatt Macy 	    "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "
533eda14cbcSMatt Macy 	    "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",
534*e92ffd9bSMartin Matuska 	    crypto_table, sfeatures);
535eda14cbcSMatt Macy 
536eda14cbcSMatt Macy 	/* set once index (boolean) properties */
537eda14cbcSMatt Macy 	zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
538eda14cbcSMatt Macy 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
539*e92ffd9bSMartin Matuska 	    "on | off", "UTF8ONLY", boolean_table, sfeatures);
540eda14cbcSMatt Macy 
541eda14cbcSMatt Macy 	/* string properties */
542eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
543*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN",
544*e92ffd9bSMartin Matuska 	    sfeatures);
545eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
546*e92ffd9bSMartin Matuska 	    ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES", sfeatures);
547eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
548eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
549*e92ffd9bSMartin Matuska 	    "MOUNTPOINT", sfeatures);
550eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
5517877fdebSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | NFS share options",
552*e92ffd9bSMartin Matuska 	    "SHARENFS", sfeatures);
553eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
554eda14cbcSMatt Macy 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
555*e92ffd9bSMartin Matuska 	    "filesystem | volume | snapshot | bookmark", "TYPE", sfeatures);
556eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
557eda14cbcSMatt Macy 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
558*e92ffd9bSMartin Matuska 	    "on | off | SMB share options", "SHARESMB", sfeatures);
559eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
560eda14cbcSMatt Macy 	    ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
561*e92ffd9bSMartin Matuska 	    "<sensitivity label>", "MLSLABEL", sfeatures);
562eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context",
563eda14cbcSMatt Macy 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux context>",
564*e92ffd9bSMartin Matuska 	    "CONTEXT", sfeatures);
565eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext",
566eda14cbcSMatt Macy 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux fscontext>",
567*e92ffd9bSMartin Matuska 	    "FSCONTEXT", sfeatures);
568eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext",
569eda14cbcSMatt Macy 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux defcontext>",
570*e92ffd9bSMartin Matuska 	    "DEFCONTEXT", sfeatures);
571eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext",
572eda14cbcSMatt Macy 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux rootcontext>",
573*e92ffd9bSMartin Matuska 	    "ROOTCONTEXT", sfeatures);
574eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN,
575eda14cbcSMatt Macy 	    "receive_resume_token",
576eda14cbcSMatt Macy 	    NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
577*e92ffd9bSMartin Matuska 	    "<string token>", "RESUMETOK", sfeatures);
578eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,
579eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",
580*e92ffd9bSMartin Matuska 	    "ENCROOT", sfeatures);
581eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",
582eda14cbcSMatt Macy 	    "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
583*e92ffd9bSMartin Matuska 	    "prompt | <file URI> | <https URL> | <http URL>", "KEYLOCATION",
584*e92ffd9bSMartin Matuska 	    sfeatures);
585eda14cbcSMatt Macy 	zprop_register_string(ZFS_PROP_REDACT_SNAPS,
586eda14cbcSMatt Macy 	    "redact_snaps", NULL, PROP_READONLY,
587eda14cbcSMatt Macy 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<snapshot>[,...]",
588*e92ffd9bSMartin Matuska 	    "RSNAPS", sfeatures);
589eda14cbcSMatt Macy 
590eda14cbcSMatt Macy 	/* readonly number properties */
591eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
592*e92ffd9bSMartin Matuska 	    ZFS_TYPE_DATASET, "<size>", "USED", sfeatures);
593eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
594*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL",
595*e92ffd9bSMartin Matuska 	    sfeatures);
596eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
597eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
598*e92ffd9bSMartin Matuska 	    "REFER", sfeatures);
599eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
600eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
601*e92ffd9bSMartin Matuska 	    "<1.00x or higher if compressed>", "RATIO", sfeatures);
602eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
603eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_DATASET,
604*e92ffd9bSMartin Matuska 	    "<1.00x or higher if compressed>", "REFRATIO", sfeatures);
605eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
606eda14cbcSMatt Macy 	    ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
607*e92ffd9bSMartin Matuska 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK", sfeatures);
608eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
609eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
610*e92ffd9bSMartin Matuska 	    "USEDSNAP", sfeatures);
611eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
612eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
613*e92ffd9bSMartin Matuska 	    "USEDDS", sfeatures);
614eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
615eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
616*e92ffd9bSMartin Matuska 	    "USEDCHILD", sfeatures);
617eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
618eda14cbcSMatt Macy 	    PROP_READONLY,
619*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV",
620*e92ffd9bSMartin Matuska 	    sfeatures);
621eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
622*e92ffd9bSMartin Matuska 	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS", sfeatures);
623eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
624*e92ffd9bSMartin Matuska 	    ZFS_TYPE_DATASET, "<size>", "WRITTEN", sfeatures);
625eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
626eda14cbcSMatt Macy 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
627*e92ffd9bSMartin Matuska 	    "LUSED", sfeatures);
628eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
629eda14cbcSMatt Macy 	    0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
630*e92ffd9bSMartin Matuska 	    "LREFER", sfeatures);
631eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
632eda14cbcSMatt Macy 	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM,
633*e92ffd9bSMartin Matuska 	    "<count>", "FSCOUNT", sfeatures);
634eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
635eda14cbcSMatt Macy 	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
636*e92ffd9bSMartin Matuska 	    "<count>", "SSCOUNT", sfeatures);
637eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY,
638*e92ffd9bSMartin Matuska 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID",
639*e92ffd9bSMartin Matuska 	    sfeatures);
640eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,
641*e92ffd9bSMartin Matuska 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG",
642*e92ffd9bSMartin Matuska 	    sfeatures);
643eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",
644eda14cbcSMatt Macy 	    0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
645*e92ffd9bSMartin Matuska 	    "<iters>", "PBKDF2ITERS", sfeatures);
646eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_OBJSETID, "objsetid", 0,
647*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_DATASET, "<uint64>", "OBJSETID", sfeatures);
648eda14cbcSMatt Macy 
649eda14cbcSMatt Macy 	/* default number properties */
650eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
651*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA", sfeatures);
652eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
653eda14cbcSMatt Macy 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
654*e92ffd9bSMartin Matuska 	    "<size> | none", "RESERV", sfeatures);
655eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
656*e92ffd9bSMartin Matuska 	    ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE",
657*e92ffd9bSMartin Matuska 	    sfeatures);
658eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
659*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA", sfeatures);
660eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
661eda14cbcSMatt Macy 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
662*e92ffd9bSMartin Matuska 	    "<size> | none", "REFRESERV", sfeatures);
663eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
664eda14cbcSMatt Macy 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
665*e92ffd9bSMartin Matuska 	    "<count> | none", "FSLIMIT", sfeatures);
666eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
667eda14cbcSMatt Macy 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
668*e92ffd9bSMartin Matuska 	    "<count> | none", "SSLIMIT", sfeatures);
669eda14cbcSMatt Macy 
670eda14cbcSMatt Macy 	/* inherit number properties */
671eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
672eda14cbcSMatt Macy 	    SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,
673*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE", sfeatures);
674eda14cbcSMatt Macy 	zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,
675eda14cbcSMatt Macy 	    "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
676*e92ffd9bSMartin Matuska 	    "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS", sfeatures);
677eda14cbcSMatt Macy 
678eda14cbcSMatt Macy 	/* hidden properties */
679eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
680*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES", sfeatures);
681eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
682*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME",
683*e92ffd9bSMartin Matuska 	    sfeatures);
684eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
685*e92ffd9bSMartin Matuska 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS",
686*e92ffd9bSMartin Matuska 	    sfeatures);
687eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
688eda14cbcSMatt Macy 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
689*e92ffd9bSMartin Matuska 	    "STMF_SBD_LU", sfeatures);
690eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
691eda14cbcSMatt Macy 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
692*e92ffd9bSMartin Matuska 	    "USERACCOUNTING", sfeatures);
693eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
694*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE", sfeatures);
695eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
696*e92ffd9bSMartin Matuska 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT",
697*e92ffd9bSMartin Matuska 	    sfeatures);
698eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid",
699eda14cbcSMatt Macy 	    PROP_TYPE_NUMBER, PROP_READONLY,
700*e92ffd9bSMartin Matuska 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID", sfeatures);
701eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
702*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP",
703*e92ffd9bSMartin Matuska 	    sfeatures);
704eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",
705eda14cbcSMatt Macy 	    PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,
706*e92ffd9bSMartin Matuska 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT", sfeatures);
707eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,
708*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID", sfeatures);
709eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_REDACTED, "redacted", PROP_TYPE_NUMBER,
710*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED", sfeatures);
711eda14cbcSMatt Macy 
712eda14cbcSMatt Macy 	/*
713eda14cbcSMatt Macy 	 * Properties that are obsolete and not used.  These are retained so
714eda14cbcSMatt Macy 	 * that we don't have to change the values of the zfs_prop_t enum, or
715eda14cbcSMatt Macy 	 * have NULL pointers in the zfs_prop_table[].
716eda14cbcSMatt Macy 	 */
717eda14cbcSMatt Macy 	zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,
718*e92ffd9bSMartin Matuska 	    PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG", sfeatures);
719eda14cbcSMatt Macy 
720eda14cbcSMatt Macy 	/* oddball properties */
721eda14cbcSMatt Macy 	zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
722eda14cbcSMatt Macy 	    NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
723*e92ffd9bSMartin Matuska 	    "<date>", "CREATION", B_FALSE, B_TRUE, NULL, sfeatures);
724*e92ffd9bSMartin Matuska 
725*e92ffd9bSMartin Matuska 	zfs_mod_list_supported_free(sfeatures);
726eda14cbcSMatt Macy }
727eda14cbcSMatt Macy 
728eda14cbcSMatt Macy boolean_t
729eda14cbcSMatt Macy zfs_prop_delegatable(zfs_prop_t prop)
730eda14cbcSMatt Macy {
731eda14cbcSMatt Macy 	zprop_desc_t *pd = &zfs_prop_table[prop];
732eda14cbcSMatt Macy 
733eda14cbcSMatt Macy 	/* The mlslabel property is never delegatable. */
734eda14cbcSMatt Macy 	if (prop == ZFS_PROP_MLSLABEL)
735eda14cbcSMatt Macy 		return (B_FALSE);
736eda14cbcSMatt Macy 
737eda14cbcSMatt Macy 	return (pd->pd_attr != PROP_READONLY);
738eda14cbcSMatt Macy }
739eda14cbcSMatt Macy 
740eda14cbcSMatt Macy /*
741eda14cbcSMatt Macy  * Given a zfs dataset property name, returns the corresponding property ID.
742eda14cbcSMatt Macy  */
743eda14cbcSMatt Macy zfs_prop_t
744eda14cbcSMatt Macy zfs_name_to_prop(const char *propname)
745eda14cbcSMatt Macy {
746eda14cbcSMatt Macy 	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
747eda14cbcSMatt Macy }
748eda14cbcSMatt Macy 
749eda14cbcSMatt Macy /*
750eda14cbcSMatt Macy  * Returns true if this is a valid user-defined property (one with a ':').
751eda14cbcSMatt Macy  */
752eda14cbcSMatt Macy boolean_t
753eda14cbcSMatt Macy zfs_prop_user(const char *name)
754eda14cbcSMatt Macy {
755eda14cbcSMatt Macy 	int i;
756eda14cbcSMatt Macy 	char c;
757eda14cbcSMatt Macy 	boolean_t foundsep = B_FALSE;
758eda14cbcSMatt Macy 
759eda14cbcSMatt Macy 	for (i = 0; i < strlen(name); i++) {
760eda14cbcSMatt Macy 		c = name[i];
761681ce946SMartin Matuska 		if (!zprop_valid_char(c))
762eda14cbcSMatt Macy 			return (B_FALSE);
763eda14cbcSMatt Macy 		if (c == ':')
764eda14cbcSMatt Macy 			foundsep = B_TRUE;
765eda14cbcSMatt Macy 	}
766eda14cbcSMatt Macy 
767eda14cbcSMatt Macy 	if (!foundsep)
768eda14cbcSMatt Macy 		return (B_FALSE);
769eda14cbcSMatt Macy 
770eda14cbcSMatt Macy 	return (B_TRUE);
771eda14cbcSMatt Macy }
772eda14cbcSMatt Macy 
773eda14cbcSMatt Macy /*
774eda14cbcSMatt Macy  * Returns true if this is a valid userspace-type property (one with a '@').
775eda14cbcSMatt Macy  * Note that after the @, any character is valid (eg, another @, for SID
776eda14cbcSMatt Macy  * user@domain).
777eda14cbcSMatt Macy  */
778eda14cbcSMatt Macy boolean_t
779eda14cbcSMatt Macy zfs_prop_userquota(const char *name)
780eda14cbcSMatt Macy {
781eda14cbcSMatt Macy 	zfs_userquota_prop_t prop;
782eda14cbcSMatt Macy 
783eda14cbcSMatt Macy 	for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
784eda14cbcSMatt Macy 		if (strncmp(name, zfs_userquota_prop_prefixes[prop],
785eda14cbcSMatt Macy 		    strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
786eda14cbcSMatt Macy 			return (B_TRUE);
787eda14cbcSMatt Macy 		}
788eda14cbcSMatt Macy 	}
789eda14cbcSMatt Macy 
790eda14cbcSMatt Macy 	return (B_FALSE);
791eda14cbcSMatt Macy }
792eda14cbcSMatt Macy 
793eda14cbcSMatt Macy /*
794eda14cbcSMatt Macy  * Returns true if this is a valid written@ property.
795eda14cbcSMatt Macy  * Note that after the @, any character is valid (eg, another @, for
796eda14cbcSMatt Macy  * written@pool/fs@origin).
797eda14cbcSMatt Macy  */
798eda14cbcSMatt Macy boolean_t
799eda14cbcSMatt Macy zfs_prop_written(const char *name)
800eda14cbcSMatt Macy {
801eda14cbcSMatt Macy 	static const char *prop_prefix = "written@";
802eda14cbcSMatt Macy 	static const char *book_prefix = "written#";
803eda14cbcSMatt Macy 	return (strncmp(name, prop_prefix, strlen(prop_prefix)) == 0 ||
804eda14cbcSMatt Macy 	    strncmp(name, book_prefix, strlen(book_prefix)) == 0);
805eda14cbcSMatt Macy }
806eda14cbcSMatt Macy 
807eda14cbcSMatt Macy /*
808eda14cbcSMatt Macy  * Tables of index types, plus functions to convert between the user view
809eda14cbcSMatt Macy  * (strings) and internal representation (uint64_t).
810eda14cbcSMatt Macy  */
811eda14cbcSMatt Macy int
812eda14cbcSMatt Macy zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
813eda14cbcSMatt Macy {
814eda14cbcSMatt Macy 	return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
815eda14cbcSMatt Macy }
816eda14cbcSMatt Macy 
817eda14cbcSMatt Macy int
818eda14cbcSMatt Macy zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
819eda14cbcSMatt Macy {
820eda14cbcSMatt Macy 	return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
821eda14cbcSMatt Macy }
822eda14cbcSMatt Macy 
823eda14cbcSMatt Macy uint64_t
824eda14cbcSMatt Macy zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
825eda14cbcSMatt Macy {
826eda14cbcSMatt Macy 	return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
827eda14cbcSMatt Macy }
828eda14cbcSMatt Macy 
829eda14cbcSMatt Macy /*
830eda14cbcSMatt Macy  * Returns TRUE if the property applies to any of the given dataset types.
831eda14cbcSMatt Macy  */
832eda14cbcSMatt Macy boolean_t
833eda14cbcSMatt Macy zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck)
834eda14cbcSMatt Macy {
835eda14cbcSMatt Macy 	return (zprop_valid_for_type(prop, types, headcheck));
836eda14cbcSMatt Macy }
837eda14cbcSMatt Macy 
838eda14cbcSMatt Macy zprop_type_t
839eda14cbcSMatt Macy zfs_prop_get_type(zfs_prop_t prop)
840eda14cbcSMatt Macy {
841eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_proptype);
842eda14cbcSMatt Macy }
843eda14cbcSMatt Macy 
844eda14cbcSMatt Macy /*
845eda14cbcSMatt Macy  * Returns TRUE if the property is readonly.
846eda14cbcSMatt Macy  */
847eda14cbcSMatt Macy boolean_t
848eda14cbcSMatt Macy zfs_prop_readonly(zfs_prop_t prop)
849eda14cbcSMatt Macy {
850eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
851eda14cbcSMatt Macy 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
852eda14cbcSMatt Macy 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
853eda14cbcSMatt Macy }
854eda14cbcSMatt Macy 
855eda14cbcSMatt Macy /*
856eda14cbcSMatt Macy  * Returns TRUE if the property is visible (not hidden).
857eda14cbcSMatt Macy  */
858eda14cbcSMatt Macy boolean_t
859eda14cbcSMatt Macy zfs_prop_visible(zfs_prop_t prop)
860eda14cbcSMatt Macy {
861eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_visible &&
862eda14cbcSMatt Macy 	    zfs_prop_table[prop].pd_zfs_mod_supported);
863eda14cbcSMatt Macy }
864eda14cbcSMatt Macy 
865eda14cbcSMatt Macy /*
866eda14cbcSMatt Macy  * Returns TRUE if the property is only allowed to be set once.
867eda14cbcSMatt Macy  */
868eda14cbcSMatt Macy boolean_t
869eda14cbcSMatt Macy zfs_prop_setonce(zfs_prop_t prop)
870eda14cbcSMatt Macy {
871eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
872eda14cbcSMatt Macy 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
873eda14cbcSMatt Macy }
874eda14cbcSMatt Macy 
875eda14cbcSMatt Macy const char *
876eda14cbcSMatt Macy zfs_prop_default_string(zfs_prop_t prop)
877eda14cbcSMatt Macy {
878eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_strdefault);
879eda14cbcSMatt Macy }
880eda14cbcSMatt Macy 
881eda14cbcSMatt Macy uint64_t
882eda14cbcSMatt Macy zfs_prop_default_numeric(zfs_prop_t prop)
883eda14cbcSMatt Macy {
884eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_numdefault);
885eda14cbcSMatt Macy }
886eda14cbcSMatt Macy 
887eda14cbcSMatt Macy /*
888eda14cbcSMatt Macy  * Given a dataset property ID, returns the corresponding name.
889eda14cbcSMatt Macy  * Assuming the zfs dataset property ID is valid.
890eda14cbcSMatt Macy  */
891eda14cbcSMatt Macy const char *
892eda14cbcSMatt Macy zfs_prop_to_name(zfs_prop_t prop)
893eda14cbcSMatt Macy {
894eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_name);
895eda14cbcSMatt Macy }
896eda14cbcSMatt Macy 
897eda14cbcSMatt Macy /*
898eda14cbcSMatt Macy  * Returns TRUE if the property is inheritable.
899eda14cbcSMatt Macy  */
900eda14cbcSMatt Macy boolean_t
901eda14cbcSMatt Macy zfs_prop_inheritable(zfs_prop_t prop)
902eda14cbcSMatt Macy {
903eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
904eda14cbcSMatt Macy 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
905eda14cbcSMatt Macy }
906eda14cbcSMatt Macy 
907eda14cbcSMatt Macy /*
908eda14cbcSMatt Macy  * Returns TRUE if property is one of the encryption properties that requires
909eda14cbcSMatt Macy  * a loaded encryption key to modify.
910eda14cbcSMatt Macy  */
911eda14cbcSMatt Macy boolean_t
912eda14cbcSMatt Macy zfs_prop_encryption_key_param(zfs_prop_t prop)
913eda14cbcSMatt Macy {
914eda14cbcSMatt Macy 	/*
915eda14cbcSMatt Macy 	 * keylocation does not count as an encryption property. It can be
916eda14cbcSMatt Macy 	 * changed at will without needing the master keys.
917eda14cbcSMatt Macy 	 */
918eda14cbcSMatt Macy 	return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS ||
919eda14cbcSMatt Macy 	    prop == ZFS_PROP_KEYFORMAT);
920eda14cbcSMatt Macy }
921eda14cbcSMatt Macy 
922eda14cbcSMatt Macy /*
923eda14cbcSMatt Macy  * Helper function used by both kernelspace and userspace to check the
924eda14cbcSMatt Macy  * keylocation property. If encrypted is set, the keylocation must be valid
925eda14cbcSMatt Macy  * for an encrypted dataset.
926eda14cbcSMatt Macy  */
927eda14cbcSMatt Macy boolean_t
928eda14cbcSMatt Macy zfs_prop_valid_keylocation(const char *str, boolean_t encrypted)
929eda14cbcSMatt Macy {
930eda14cbcSMatt Macy 	if (strcmp("none", str) == 0)
931eda14cbcSMatt Macy 		return (!encrypted);
932eda14cbcSMatt Macy 	else if (strcmp("prompt", str) == 0)
933eda14cbcSMatt Macy 		return (B_TRUE);
934eda14cbcSMatt Macy 	else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0)
935eda14cbcSMatt Macy 		return (B_TRUE);
93616038816SMartin Matuska 	else if (strlen(str) > 8 && strncmp("https://", str, 8) == 0)
93716038816SMartin Matuska 		return (B_TRUE);
93816038816SMartin Matuska 	else if (strlen(str) > 7 && strncmp("http://", str, 7) == 0)
93916038816SMartin Matuska 		return (B_TRUE);
940eda14cbcSMatt Macy 
941eda14cbcSMatt Macy 	return (B_FALSE);
942eda14cbcSMatt Macy }
943eda14cbcSMatt Macy 
944eda14cbcSMatt Macy 
945eda14cbcSMatt Macy #ifndef _KERNEL
946eda14cbcSMatt Macy #include <libzfs.h>
947eda14cbcSMatt Macy 
948eda14cbcSMatt Macy /*
949eda14cbcSMatt Macy  * Returns a string describing the set of acceptable values for the given
950eda14cbcSMatt Macy  * zfs property, or NULL if it cannot be set.
951eda14cbcSMatt Macy  */
952eda14cbcSMatt Macy const char *
953eda14cbcSMatt Macy zfs_prop_values(zfs_prop_t prop)
954eda14cbcSMatt Macy {
955eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_values);
956eda14cbcSMatt Macy }
957eda14cbcSMatt Macy 
958eda14cbcSMatt Macy /*
959eda14cbcSMatt Macy  * Returns TRUE if this property is a string type.  Note that index types
960eda14cbcSMatt Macy  * (compression, checksum) are treated as strings in userland, even though they
961eda14cbcSMatt Macy  * are stored numerically on disk.
962eda14cbcSMatt Macy  */
963eda14cbcSMatt Macy int
964eda14cbcSMatt Macy zfs_prop_is_string(zfs_prop_t prop)
965eda14cbcSMatt Macy {
966eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
967eda14cbcSMatt Macy 	    zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
968eda14cbcSMatt Macy }
969eda14cbcSMatt Macy 
970eda14cbcSMatt Macy /*
971eda14cbcSMatt Macy  * Returns the column header for the given property.  Used only in
972eda14cbcSMatt Macy  * 'zfs list -o', but centralized here with the other property information.
973eda14cbcSMatt Macy  */
974eda14cbcSMatt Macy const char *
975eda14cbcSMatt Macy zfs_prop_column_name(zfs_prop_t prop)
976eda14cbcSMatt Macy {
977eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_colname);
978eda14cbcSMatt Macy }
979eda14cbcSMatt Macy 
980eda14cbcSMatt Macy /*
981eda14cbcSMatt Macy  * Returns whether the given property should be displayed right-justified for
982eda14cbcSMatt Macy  * 'zfs list'.
983eda14cbcSMatt Macy  */
984eda14cbcSMatt Macy boolean_t
985eda14cbcSMatt Macy zfs_prop_align_right(zfs_prop_t prop)
986eda14cbcSMatt Macy {
987eda14cbcSMatt Macy 	return (zfs_prop_table[prop].pd_rightalign);
988eda14cbcSMatt Macy }
989eda14cbcSMatt Macy 
990eda14cbcSMatt Macy #endif
991eda14cbcSMatt Macy 
992eda14cbcSMatt Macy #if defined(_KERNEL)
993eda14cbcSMatt Macy 
994eda14cbcSMatt Macy #include <sys/simd.h>
995eda14cbcSMatt Macy 
996eda14cbcSMatt Macy #if defined(HAVE_KERNEL_FPU_INTERNAL)
997eda14cbcSMatt Macy union fpregs_state **zfs_kfpu_fpregs;
998eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_kfpu_fpregs);
999eda14cbcSMatt Macy #endif /* HAVE_KERNEL_FPU_INTERNAL */
1000eda14cbcSMatt Macy 
1001eda14cbcSMatt Macy static int __init
1002eda14cbcSMatt Macy zcommon_init(void)
1003eda14cbcSMatt Macy {
1004eda14cbcSMatt Macy 	int error = kfpu_init();
1005eda14cbcSMatt Macy 	if (error)
1006eda14cbcSMatt Macy 		return (error);
1007eda14cbcSMatt Macy 
1008eda14cbcSMatt Macy 	fletcher_4_init();
1009eda14cbcSMatt Macy 
1010eda14cbcSMatt Macy 	return (0);
1011eda14cbcSMatt Macy }
1012eda14cbcSMatt Macy 
1013eda14cbcSMatt Macy static void __exit
1014eda14cbcSMatt Macy zcommon_fini(void)
1015eda14cbcSMatt Macy {
1016eda14cbcSMatt Macy 	fletcher_4_fini();
1017eda14cbcSMatt Macy 	kfpu_fini();
1018eda14cbcSMatt Macy }
1019eda14cbcSMatt Macy 
10207877fdebSMatt Macy module_init_early(zcommon_init);
1021eda14cbcSMatt Macy module_exit(zcommon_fini);
1022eda14cbcSMatt Macy 
1023eda14cbcSMatt Macy #endif
1024eda14cbcSMatt Macy 
1025eda14cbcSMatt Macy ZFS_MODULE_DESCRIPTION("Generic ZFS support");
1026eda14cbcSMatt Macy ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR);
1027eda14cbcSMatt Macy ZFS_MODULE_LICENSE(ZFS_META_LICENSE);
1028eda14cbcSMatt Macy ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE);
1029eda14cbcSMatt Macy 
1030eda14cbcSMatt Macy /* zfs dataset property functions */
1031eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_userquota_prop_prefixes);
1032eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_init);
1033eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_get_type);
1034eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_get_table);
1035eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_delegatable);
1036eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_visible);
1037eda14cbcSMatt Macy 
1038eda14cbcSMatt Macy /* Dataset property functions shared between libzfs and kernel. */
1039eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_default_string);
1040eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_default_numeric);
1041eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_readonly);
1042eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_inheritable);
1043eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_encryption_key_param);
1044eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_valid_keylocation);
1045eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_setonce);
1046eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_to_name);
1047eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_name_to_prop);
1048eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_user);
1049eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_userquota);
1050eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_index_to_string);
1051eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_string_to_index);
1052eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_valid_for_type);
1053eda14cbcSMatt Macy EXPORT_SYMBOL(zfs_prop_written);
1054