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