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