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