xref: /freebsd/sys/contrib/openzfs/module/zcommon/zfs_prop.c (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
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 prefetch_table[] = {
349 		{ "none",	ZFS_PREFETCH_NONE },
350 		{ "metadata",	ZFS_PREFETCH_METADATA },
351 		{ "all",	ZFS_PREFETCH_ALL },
352 		{ NULL }
353 	};
354 
355 	static const zprop_index_t sync_table[] = {
356 		{ "standard",	ZFS_SYNC_STANDARD },
357 		{ "always",	ZFS_SYNC_ALWAYS },
358 		{ "disabled",	ZFS_SYNC_DISABLED },
359 		{ NULL }
360 	};
361 
362 	static const zprop_index_t xattr_table[] = {
363 		{ "off",	ZFS_XATTR_OFF },
364 		{ "on",		ZFS_XATTR_DIR },
365 		{ "sa",		ZFS_XATTR_SA },
366 		{ "dir",	ZFS_XATTR_DIR },
367 		{ NULL }
368 	};
369 
370 	static const zprop_index_t dnsize_table[] = {
371 		{ "legacy",	ZFS_DNSIZE_LEGACY },
372 		{ "auto",	ZFS_DNSIZE_AUTO },
373 		{ "1k",		ZFS_DNSIZE_1K },
374 		{ "2k",		ZFS_DNSIZE_2K },
375 		{ "4k",		ZFS_DNSIZE_4K },
376 		{ "8k",		ZFS_DNSIZE_8K },
377 		{ "16k",	ZFS_DNSIZE_16K },
378 		{ NULL }
379 	};
380 
381 	static const zprop_index_t redundant_metadata_table[] = {
382 		{ "all",	ZFS_REDUNDANT_METADATA_ALL },
383 		{ "most",	ZFS_REDUNDANT_METADATA_MOST },
384 		{ "some",	ZFS_REDUNDANT_METADATA_SOME },
385 		{ "none",	ZFS_REDUNDANT_METADATA_NONE },
386 		{ NULL }
387 	};
388 
389 	static const zprop_index_t volmode_table[] = {
390 		{ "default",	ZFS_VOLMODE_DEFAULT },
391 		{ "full",	ZFS_VOLMODE_GEOM },
392 		{ "geom",	ZFS_VOLMODE_GEOM },
393 		{ "dev",	ZFS_VOLMODE_DEV },
394 		{ "none",	ZFS_VOLMODE_NONE },
395 		{ NULL }
396 	};
397 
398 	struct zfs_mod_supported_features *sfeatures =
399 	    zfs_mod_list_supported(ZFS_SYSFS_DATASET_PROPERTIES);
400 
401 	/* inherit index properties */
402 	zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
403 	    ZFS_REDUNDANT_METADATA_ALL,
404 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
405 	    "all | most | some | none", "REDUND_MD",
406 	    redundant_metadata_table, sfeatures);
407 	zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
408 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
409 	    "standard | always | disabled", "SYNC",
410 	    sync_table, sfeatures);
411 	zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
412 	    ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
413 	    ZFS_TYPE_VOLUME,
414 	    "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein"
415 	    " | edonr | blake3",
416 	    "CHECKSUM", checksum_table, sfeatures);
417 	zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
418 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
419 	    "on | off | verify | sha256[,verify] | sha512[,verify] | "
420 	    "skein[,verify] | edonr,verify | blake3[,verify]",
421 	    "DEDUP", dedup_table, sfeatures);
422 	zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
423 	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
424 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
425 	    "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | "
426 	    "zstd | zstd-[1-19] | "
427 	    "zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]",
428 	    "COMPRESS", compress_table, sfeatures);
429 	zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
430 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
431 	    "hidden | visible", "SNAPDIR", snapdir_table, sfeatures);
432 	zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN,
433 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
434 	    "hidden | visible", "SNAPDEV", snapdev_table, sfeatures);
435 	zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
436 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
437 	    "discard | groupmask | passthrough | restricted", "ACLMODE",
438 	    acl_mode_table, sfeatures);
439 	zprop_register_index(ZFS_PROP_ACLTYPE, "acltype",
440 #ifdef __linux__
441 	    /* Linux doesn't natively support ZFS's NFSv4-style ACLs. */
442 	    ZFS_ACLTYPE_OFF,
443 #else
444 	    ZFS_ACLTYPE_NFSV4,
445 #endif
446 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
447 	    "off | nfsv4 | posix", "ACLTYPE", acltype_table, sfeatures);
448 	zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
449 	    ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
450 	    "discard | noallow | restricted | passthrough | passthrough-x",
451 	    "ACLINHERIT", acl_inherit_table, sfeatures);
452 	zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
453 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
454 	    "1 | 2 | 3", "COPIES", copies_table, sfeatures);
455 	zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
456 	    ZFS_CACHE_ALL, PROP_INHERIT,
457 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
458 	    "all | none | metadata", "PRIMARYCACHE", cache_table, sfeatures);
459 	zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
460 	    ZFS_CACHE_ALL, PROP_INHERIT,
461 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
462 	    "all | none | metadata", "SECONDARYCACHE", cache_table, sfeatures);
463 	zprop_register_index(ZFS_PROP_PREFETCH, "prefetch",
464 	    ZFS_PREFETCH_ALL, PROP_INHERIT,
465 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
466 	    "none | metadata | all", "PREFETCH", prefetch_table, sfeatures);
467 	zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
468 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
469 	    "latency | throughput", "LOGBIAS", logbias_table, sfeatures);
470 	zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR,
471 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
472 	    "on | off | dir | sa", "XATTR", xattr_table, sfeatures);
473 	zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",
474 	    ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
475 	    "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table,
476 	    sfeatures);
477 	zprop_register_index(ZFS_PROP_VOLMODE, "volmode",
478 	    ZFS_VOLMODE_DEFAULT, PROP_INHERIT,
479 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
480 	    "default | full | geom | dev | none", "VOLMODE", volmode_table,
481 	    sfeatures);
482 
483 	/* inherit index (boolean) properties */
484 	zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
485 	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table, sfeatures);
486 	zprop_register_index(ZFS_PROP_RELATIME, "relatime", 1, PROP_INHERIT,
487 	    ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table,
488 	    sfeatures);
489 	zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
490 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
491 	    boolean_table, sfeatures);
492 	zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
493 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
494 	    boolean_table, sfeatures);
495 	zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
496 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
497 	    boolean_table, sfeatures);
498 	zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
499 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
500 	    boolean_table, sfeatures);
501 #ifdef __FreeBSD__
502 	zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT,
503 	    ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table,
504 	    sfeatures);
505 #else
506 	zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
507 	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table, sfeatures);
508 #endif
509 	zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
510 	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table, sfeatures);
511 	zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
512 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
513 	    boolean_table, sfeatures);
514 	zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT,
515 	    ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table,
516 	    sfeatures);
517 
518 	/* default index properties */
519 	zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
520 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
521 	    "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table, sfeatures);
522 	zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
523 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
524 	    "CANMOUNT", canmount_table, sfeatures);
525 
526 	/* readonly index properties */
527 	zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
528 	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table,
529 	    sfeatures);
530 	zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
531 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
532 	    boolean_table, sfeatures);
533 	zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",
534 	    ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,
535 	    "none | unavailable | available",
536 	    "KEYSTATUS", keystatus_table, sfeatures);
537 
538 	/* set once index properties */
539 	zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
540 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
541 	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
542 	    normalize_table, sfeatures);
543 	zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
544 	    ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
545 	    ZFS_TYPE_SNAPSHOT,
546 	    "sensitive | insensitive | mixed", "CASE", case_table, sfeatures);
547 	zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",
548 	    ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,
549 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
550 	    "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table,
551 	    sfeatures);
552 	zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption",
553 	    ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET,
554 	    "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "
555 	    "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",
556 	    crypto_table, sfeatures);
557 
558 	/* set once index (boolean) properties */
559 	zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
560 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
561 	    "on | off", "UTF8ONLY", boolean_table, sfeatures);
562 
563 	/* string properties */
564 	zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
565 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN",
566 	    sfeatures);
567 	zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
568 	    ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES", sfeatures);
569 	zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
570 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
571 	    "MOUNTPOINT", sfeatures);
572 	zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
573 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | NFS share options",
574 	    "SHARENFS", sfeatures);
575 	zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
576 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
577 	    "filesystem | volume | snapshot | bookmark", "TYPE", sfeatures);
578 	zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
579 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
580 	    "on | off | SMB share options", "SHARESMB", sfeatures);
581 	zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
582 	    ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
583 	    "<sensitivity label>", "MLSLABEL", sfeatures);
584 	zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context",
585 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux context>",
586 	    "CONTEXT", sfeatures);
587 	zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext",
588 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux fscontext>",
589 	    "FSCONTEXT", sfeatures);
590 	zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext",
591 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux defcontext>",
592 	    "DEFCONTEXT", sfeatures);
593 	zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext",
594 	    "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux rootcontext>",
595 	    "ROOTCONTEXT", sfeatures);
596 	zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN,
597 	    "receive_resume_token",
598 	    NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
599 	    "<string token>", "RESUMETOK", sfeatures);
600 	zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,
601 	    PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",
602 	    "ENCROOT", sfeatures);
603 	zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",
604 	    "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
605 	    "prompt | <file URI> | <https URL> | <http URL>", "KEYLOCATION",
606 	    sfeatures);
607 	zprop_register_string(ZFS_PROP_REDACT_SNAPS,
608 	    "redact_snaps", NULL, PROP_READONLY,
609 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<snapshot>[,...]",
610 	    "RSNAPS", sfeatures);
611 
612 	/* readonly number properties */
613 	zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
614 	    ZFS_TYPE_DATASET, "<size>", "USED", B_FALSE, sfeatures);
615 	zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
616 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL",
617 	    B_FALSE, sfeatures);
618 	zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
619 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
620 	    "REFER", B_FALSE, sfeatures);
621 	zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
622 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
623 	    "<1.00x or higher if compressed>", "RATIO", B_FALSE, sfeatures);
624 	zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
625 	    PROP_READONLY, ZFS_TYPE_DATASET,
626 	    "<1.00x or higher if compressed>", "REFRATIO", B_FALSE, sfeatures);
627 	zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
628 	    ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
629 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK", B_FALSE,
630 	    sfeatures);
631 	zprop_register_index(ZFS_PROP_VOLTHREADING, "volthreading",
632 	    1, PROP_DEFAULT, ZFS_TYPE_VOLUME, "on | off", "zvol threading",
633 	    boolean_table, sfeatures);
634 	zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
635 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
636 	    "USEDSNAP", B_FALSE, sfeatures);
637 	zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
638 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
639 	    "USEDDS", B_FALSE, sfeatures);
640 	zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
641 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
642 	    "USEDCHILD", B_FALSE, sfeatures);
643 	zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
644 	    PROP_READONLY,
645 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV",
646 	    B_FALSE, sfeatures);
647 	zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
648 	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS", B_FALSE, sfeatures);
649 	zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
650 	    ZFS_TYPE_DATASET, "<size>", "WRITTEN", B_FALSE, sfeatures);
651 	zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
652 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
653 	    "LUSED", B_FALSE, sfeatures);
654 	zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
655 	    0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
656 	    "LREFER", B_FALSE, sfeatures);
657 	zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
658 	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM,
659 	    "<count>", "FSCOUNT", B_FALSE, sfeatures);
660 	zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
661 	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
662 	    "<count>", "SSCOUNT", B_FALSE, sfeatures);
663 	zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY,
664 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID",
665 	    B_TRUE, sfeatures);
666 	zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,
667 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG",
668 	    B_TRUE, sfeatures);
669 	zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",
670 	    0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
671 	    "<iters>", "PBKDF2ITERS", B_TRUE, sfeatures);
672 	zprop_register_number(ZFS_PROP_OBJSETID, "objsetid", 0,
673 	    PROP_READONLY, ZFS_TYPE_DATASET, "<uint64>", "OBJSETID", B_TRUE,
674 	    sfeatures);
675 
676 	/* default number properties */
677 	zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
678 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA", B_FALSE, sfeatures);
679 	zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
680 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
681 	    "<size> | none", "RESERV", B_FALSE, sfeatures);
682 	zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
683 	    ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE",
684 	    B_FALSE, sfeatures);
685 	zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
686 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA", B_FALSE,
687 	    sfeatures);
688 	zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
689 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
690 	    "<size> | none", "REFRESERV", B_FALSE, sfeatures);
691 	zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
692 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
693 	    "<count> | none", "FSLIMIT", B_FALSE, sfeatures);
694 	zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
695 	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
696 	    "<count> | none", "SSLIMIT", B_FALSE, sfeatures);
697 
698 	/* inherit number properties */
699 	zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
700 	    SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,
701 	    ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE", B_FALSE,
702 	    sfeatures);
703 	zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,
704 	    "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
705 	    "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS", B_FALSE,
706 	    sfeatures);
707 
708 	/* hidden properties */
709 	zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
710 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES", B_FALSE, sfeatures);
711 	zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
712 	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME",
713 	    B_TRUE, sfeatures);
714 	zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
715 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS",
716 	    B_TRUE, sfeatures);
717 	zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
718 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
719 	    "STMF_SBD_LU", B_TRUE, sfeatures);
720 	zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
721 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
722 	    "USERACCOUNTING", B_FALSE, sfeatures);
723 	zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
724 	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE", B_FALSE, sfeatures);
725 	zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
726 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT",
727 	    B_FALSE, sfeatures);
728 	zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid",
729 	    PROP_TYPE_NUMBER, PROP_READONLY,
730 	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID", B_TRUE,
731 	    sfeatures);
732 	zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
733 	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP",
734 	    B_TRUE, sfeatures);
735 	zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",
736 	    PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,
737 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT", B_FALSE,
738 	    sfeatures);
739 	zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,
740 	    PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID", B_TRUE, sfeatures);
741 	zprop_register_hidden(ZFS_PROP_REDACTED, "redacted", PROP_TYPE_NUMBER,
742 	    PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED", B_FALSE, sfeatures);
743 
744 	/*
745 	 * Properties that are obsolete and not used.  These are retained so
746 	 * that we don't have to change the values of the zfs_prop_t enum, or
747 	 * have NULL pointers in the zfs_prop_table[].
748 	 */
749 	zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,
750 	    PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG", B_FALSE, sfeatures);
751 
752 	/* oddball properties */
753 	/* 'creation' is a number but displayed as human-readable => flex */
754 	zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
755 	    NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
756 	    "<date>", "CREATION", B_FALSE, B_TRUE, B_TRUE, NULL, sfeatures);
757 
758 	zprop_register_impl(ZFS_PROP_SNAPSHOTS_CHANGED, "snapshots_changed",
759 	    PROP_TYPE_NUMBER, 0, NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM |
760 	    ZFS_TYPE_VOLUME, "<date>", "SNAPSHOTS_CHANGED", B_FALSE, B_TRUE,
761 	    B_TRUE, NULL, sfeatures);
762 
763 	zfs_mod_list_supported_free(sfeatures);
764 }
765 
766 boolean_t
767 zfs_prop_delegatable(zfs_prop_t prop)
768 {
769 	ASSERT3S(prop, >=, 0);
770 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
771 	zprop_desc_t *pd = &zfs_prop_table[prop];
772 
773 	/* The mlslabel property is never delegatable. */
774 	if (prop == ZFS_PROP_MLSLABEL)
775 		return (B_FALSE);
776 
777 	return (pd->pd_attr != PROP_READONLY);
778 }
779 
780 /*
781  * Given a zfs dataset property name, returns the corresponding property ID.
782  */
783 zfs_prop_t
784 zfs_name_to_prop(const char *propname)
785 {
786 	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
787 }
788 
789 /*
790  * Returns true if this is a valid user-defined property (one with a ':').
791  */
792 boolean_t
793 zfs_prop_user(const char *name)
794 {
795 	int i;
796 	char c;
797 	boolean_t foundsep = B_FALSE;
798 
799 	for (i = 0; i < strlen(name); i++) {
800 		c = name[i];
801 		if (!zprop_valid_char(c))
802 			return (B_FALSE);
803 		if (c == ':')
804 			foundsep = B_TRUE;
805 	}
806 
807 	if (!foundsep)
808 		return (B_FALSE);
809 
810 	return (B_TRUE);
811 }
812 
813 /*
814  * Returns true if this is a valid userspace-type property (one with a '@').
815  * Note that after the @, any character is valid (eg, another @, for SID
816  * user@domain).
817  */
818 boolean_t
819 zfs_prop_userquota(const char *name)
820 {
821 	zfs_userquota_prop_t prop;
822 
823 	for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
824 		if (strncmp(name, zfs_userquota_prop_prefixes[prop],
825 		    strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
826 			return (B_TRUE);
827 		}
828 	}
829 
830 	return (B_FALSE);
831 }
832 
833 /*
834  * Returns true if this is a valid written@ property.
835  * Note that after the @, any character is valid (eg, another @, for
836  * written@pool/fs@origin).
837  */
838 boolean_t
839 zfs_prop_written(const char *name)
840 {
841 	static const char *prop_prefix = "written@";
842 	static const char *book_prefix = "written#";
843 	return (strncmp(name, prop_prefix, strlen(prop_prefix)) == 0 ||
844 	    strncmp(name, book_prefix, strlen(book_prefix)) == 0);
845 }
846 
847 /*
848  * Tables of index types, plus functions to convert between the user view
849  * (strings) and internal representation (uint64_t).
850  */
851 int
852 zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
853 {
854 	return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
855 }
856 
857 int
858 zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
859 {
860 	return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
861 }
862 
863 uint64_t
864 zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
865 {
866 	return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
867 }
868 
869 /*
870  * Returns TRUE if the property applies to any of the given dataset types.
871  */
872 boolean_t
873 zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck)
874 {
875 	return (zprop_valid_for_type(prop, types, headcheck));
876 }
877 
878 zprop_type_t
879 zfs_prop_get_type(zfs_prop_t prop)
880 {
881 	ASSERT3S(prop, >=, 0);
882 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
883 	return (zfs_prop_table[prop].pd_proptype);
884 }
885 
886 /*
887  * Returns TRUE if the property is readonly.
888  */
889 boolean_t
890 zfs_prop_readonly(zfs_prop_t prop)
891 {
892 	ASSERT3S(prop, >=, 0);
893 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
894 	return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
895 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
896 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
897 }
898 
899 /*
900  * Returns TRUE if the property is visible (not hidden).
901  */
902 boolean_t
903 zfs_prop_visible(zfs_prop_t prop)
904 {
905 	ASSERT3S(prop, >=, 0);
906 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
907 	return (zfs_prop_table[prop].pd_visible &&
908 	    zfs_prop_table[prop].pd_zfs_mod_supported);
909 }
910 
911 /*
912  * Returns TRUE if the property is only allowed to be set once.
913  */
914 boolean_t
915 zfs_prop_setonce(zfs_prop_t prop)
916 {
917 	ASSERT3S(prop, >=, 0);
918 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
919 	return (zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
920 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
921 }
922 
923 const char *
924 zfs_prop_default_string(zfs_prop_t prop)
925 {
926 	ASSERT3S(prop, >=, 0);
927 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
928 	return (zfs_prop_table[prop].pd_strdefault);
929 }
930 
931 uint64_t
932 zfs_prop_default_numeric(zfs_prop_t prop)
933 {
934 	ASSERT3S(prop, >=, 0);
935 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
936 	return (zfs_prop_table[prop].pd_numdefault);
937 }
938 
939 /*
940  * Given a dataset property ID, returns the corresponding name.
941  * Assuming the zfs dataset property ID is valid.
942  */
943 const char *
944 zfs_prop_to_name(zfs_prop_t prop)
945 {
946 	ASSERT3S(prop, >=, 0);
947 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
948 	return (zfs_prop_table[prop].pd_name);
949 }
950 
951 /*
952  * Returns TRUE if the property is inheritable.
953  */
954 boolean_t
955 zfs_prop_inheritable(zfs_prop_t prop)
956 {
957 	ASSERT3S(prop, >=, 0);
958 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
959 	return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
960 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
961 }
962 
963 /*
964  * Returns TRUE if property is one of the encryption properties that requires
965  * a loaded encryption key to modify.
966  */
967 boolean_t
968 zfs_prop_encryption_key_param(zfs_prop_t prop)
969 {
970 	/*
971 	 * keylocation does not count as an encryption property. It can be
972 	 * changed at will without needing the master keys.
973 	 */
974 	return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS ||
975 	    prop == ZFS_PROP_KEYFORMAT);
976 }
977 
978 /*
979  * Helper function used by both kernelspace and userspace to check the
980  * keylocation property. If encrypted is set, the keylocation must be valid
981  * for an encrypted dataset.
982  */
983 boolean_t
984 zfs_prop_valid_keylocation(const char *str, boolean_t encrypted)
985 {
986 	if (strcmp("none", str) == 0)
987 		return (!encrypted);
988 	else if (strcmp("prompt", str) == 0)
989 		return (B_TRUE);
990 	else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0)
991 		return (B_TRUE);
992 	else if (strlen(str) > 8 && strncmp("https://", str, 8) == 0)
993 		return (B_TRUE);
994 	else if (strlen(str) > 7 && strncmp("http://", str, 7) == 0)
995 		return (B_TRUE);
996 
997 	return (B_FALSE);
998 }
999 
1000 
1001 #ifndef _KERNEL
1002 #include <libzfs.h>
1003 
1004 /*
1005  * Returns a string describing the set of acceptable values for the given
1006  * zfs property, or NULL if it cannot be set.
1007  */
1008 const char *
1009 zfs_prop_values(zfs_prop_t prop)
1010 {
1011 	ASSERT3S(prop, >=, 0);
1012 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
1013 	return (zfs_prop_table[prop].pd_values);
1014 }
1015 
1016 /*
1017  * Returns TRUE if this property is a string type.  Note that index types
1018  * (compression, checksum) are treated as strings in userland, even though they
1019  * are stored numerically on disk.
1020  */
1021 int
1022 zfs_prop_is_string(zfs_prop_t prop)
1023 {
1024 	ASSERT3S(prop, >=, 0);
1025 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
1026 	return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
1027 	    zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
1028 }
1029 
1030 /*
1031  * Returns the column header for the given property.  Used only in
1032  * 'zfs list -o', but centralized here with the other property information.
1033  */
1034 const char *
1035 zfs_prop_column_name(zfs_prop_t prop)
1036 {
1037 	ASSERT3S(prop, >=, 0);
1038 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
1039 	return (zfs_prop_table[prop].pd_colname);
1040 }
1041 
1042 /*
1043  * Returns whether the given property should be displayed right-justified for
1044  * 'zfs list'.
1045  */
1046 boolean_t
1047 zfs_prop_align_right(zfs_prop_t prop)
1048 {
1049 	ASSERT3S(prop, >=, 0);
1050 	ASSERT3S(prop, <, ZFS_NUM_PROPS);
1051 	return (zfs_prop_table[prop].pd_rightalign);
1052 }
1053 
1054 #endif
1055 
1056 #if defined(_KERNEL)
1057 
1058 #if defined(HAVE_KERNEL_FPU_INTERNAL)
1059 uint8_t **zfs_kfpu_fpregs;
1060 EXPORT_SYMBOL(zfs_kfpu_fpregs);
1061 #endif /* defined(HAVE_KERNEL_FPU_INTERNAL) */
1062 
1063 extern int __init zcommon_init(void);
1064 extern void zcommon_fini(void);
1065 
1066 int __init
1067 zcommon_init(void)
1068 {
1069 	int error = kfpu_init();
1070 	if (error)
1071 		return (error);
1072 
1073 	fletcher_4_init();
1074 
1075 	return (0);
1076 }
1077 
1078 void
1079 zcommon_fini(void)
1080 {
1081 	fletcher_4_fini();
1082 	kfpu_fini();
1083 }
1084 
1085 #ifdef __FreeBSD__
1086 module_init_early(zcommon_init);
1087 module_exit(zcommon_fini);
1088 #endif
1089 
1090 #endif
1091 
1092 /* zfs dataset property functions */
1093 EXPORT_SYMBOL(zfs_userquota_prop_prefixes);
1094 EXPORT_SYMBOL(zfs_prop_init);
1095 EXPORT_SYMBOL(zfs_prop_get_type);
1096 EXPORT_SYMBOL(zfs_prop_get_table);
1097 EXPORT_SYMBOL(zfs_prop_delegatable);
1098 EXPORT_SYMBOL(zfs_prop_visible);
1099 
1100 /* Dataset property functions shared between libzfs and kernel. */
1101 EXPORT_SYMBOL(zfs_prop_default_string);
1102 EXPORT_SYMBOL(zfs_prop_default_numeric);
1103 EXPORT_SYMBOL(zfs_prop_readonly);
1104 EXPORT_SYMBOL(zfs_prop_inheritable);
1105 EXPORT_SYMBOL(zfs_prop_encryption_key_param);
1106 EXPORT_SYMBOL(zfs_prop_valid_keylocation);
1107 EXPORT_SYMBOL(zfs_prop_setonce);
1108 EXPORT_SYMBOL(zfs_prop_to_name);
1109 EXPORT_SYMBOL(zfs_name_to_prop);
1110 EXPORT_SYMBOL(zfs_prop_user);
1111 EXPORT_SYMBOL(zfs_prop_userquota);
1112 EXPORT_SYMBOL(zfs_prop_index_to_string);
1113 EXPORT_SYMBOL(zfs_prop_string_to_index);
1114 EXPORT_SYMBOL(zfs_prop_valid_for_type);
1115 EXPORT_SYMBOL(zfs_prop_written);
1116