]> git.proxmox.com Git - mirror_zfs.git/blame - module/zcommon/zfs_prop.c
Improve block sizes checks during cloning
[mirror_zfs.git] / module / zcommon / zfs_prop.c
CommitLineData
34dc7c2f
BB
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
1d3ba0bf 9 * or https://opensource.org/licenses/CDDL-1.0.
34dc7c2f
BB
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/*
428870ff 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
30af21b0 23 * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
632a242e 24 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
911c41af 25 * Copyright 2016, Joyent, Inc.
10b3c7f5
MN
26 * Copyright (c) 2019, Klara Inc.
27 * Copyright (c) 2019, Allan Jude
5405be03 28 * Copyright (c) 2022 Hewlett Packard Enterprise Development LP.
34dc7c2f
BB
29 */
30
428870ff
BB
31/* Portions Copyright 2010 Robert Milkowski */
32
a3f82aec
MM
33#if defined(_KERNEL)
34#include <sys/simd.h>
35#endif
36
34dc7c2f
BB
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>
b5256303 43#include <sys/dsl_crypt.h>
34dc7c2f
BB
44
45#include "zfs_prop.h"
46#include "zfs_deleg.h"
1eeb4562 47#include "zfs_fletcher.h"
34dc7c2f 48
93ce2b4c 49#if !defined(_KERNEL)
34dc7c2f
BB
50#include <stdlib.h>
51#include <string.h>
52#include <ctype.h>
53#endif
54
55static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
56
9babb374 57/* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
18168da7 58const char *const zfs_userquota_prop_prefixes[] = {
9babb374
BB
59 "userused@",
60 "userquota@",
61 "groupused@",
1de321e6
JX
62 "groupquota@",
63 "userobjused@",
64 "userobjquota@",
65 "groupobjused@",
9c5167d1
NF
66 "groupobjquota@",
67 "projectused@",
68 "projectquota@",
69 "projectobjused@",
70 "projectobjquota@"
9babb374
BB
71};
72
34dc7c2f
BB
73zprop_desc_t *
74zfs_prop_get_table(void)
75{
76 return (zfs_prop_table);
77}
78
79void
80zfs_prop_init(void)
81{
8fdc6f61 82 static const zprop_index_t checksum_table[] = {
34dc7c2f
BB
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 },
3c67d83a
TH
88 { "noparity", ZIO_CHECKSUM_NOPARITY },
89 { "sha512", ZIO_CHECKSUM_SHA512 },
90 { "skein", ZIO_CHECKSUM_SKEIN },
91 { "edonr", ZIO_CHECKSUM_EDONR },
985c33b1 92 { "blake3", ZIO_CHECKSUM_BLAKE3 },
34dc7c2f
BB
93 { NULL }
94 };
95
8fdc6f61 96 static const zprop_index_t dedup_table[] = {
428870ff
BB
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 },
3c67d83a
TH
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 },
985c33b1
TR
111 { "blake3", ZIO_CHECKSUM_BLAKE3 },
112 { "blake3,verify",
113 ZIO_CHECKSUM_BLAKE3 | ZIO_CHECKSUM_VERIFY },
428870ff
BB
114 { NULL }
115 };
116
8fdc6f61 117 static const zprop_index_t compress_table[] = {
34dc7c2f
BB
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 },
428870ff 131 { "zle", ZIO_COMPRESS_ZLE },
9759c60f 132 { "lz4", ZIO_COMPRESS_LZ4 },
10b3c7f5
MN
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) },
34dc7c2f
BB
214 { NULL }
215 };
216
8fdc6f61 217 static const zprop_index_t crypto_table[] = {
b5256303
TC
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
8fdc6f61 229 static const zprop_index_t keyformat_table[] = {
b5256303
TC
230 { "none", ZFS_KEYFORMAT_NONE },
231 { "raw", ZFS_KEYFORMAT_RAW },
232 { "hex", ZFS_KEYFORMAT_HEX },
233 { "passphrase", ZFS_KEYFORMAT_PASSPHRASE },
234 { NULL }
235 };
236
8fdc6f61 237 static const zprop_index_t snapdir_table[] = {
34dc7c2f
BB
238 { "hidden", ZFS_SNAPDIR_HIDDEN },
239 { "visible", ZFS_SNAPDIR_VISIBLE },
240 { NULL }
241 };
242
8fdc6f61 243 static const zprop_index_t snapdev_table[] = {
0b4d1b58
ED
244 { "hidden", ZFS_SNAPDEV_HIDDEN },
245 { "visible", ZFS_SNAPDEV_VISIBLE },
246 { NULL }
247 };
248
8fdc6f61 249 static const zprop_index_t acl_mode_table[] = {
8c4987c4
RM
250 { "discard", ZFS_ACL_DISCARD },
251 { "groupmask", ZFS_ACL_GROUPMASK },
252 { "passthrough", ZFS_ACL_PASSTHROUGH },
253 { "restricted", ZFS_ACL_RESTRICTED },
254 { NULL }
255 };
256
8fdc6f61 257 static const zprop_index_t acltype_table[] = {
023699cd 258 { "off", ZFS_ACLTYPE_OFF },
7ead2be3 259 { "posix", ZFS_ACLTYPE_POSIX },
485b50bb 260 { "nfsv4", ZFS_ACLTYPE_NFSV4 },
7ead2be3
RM
261 { "disabled", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
262 { "noacl", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
263 { "posixacl", ZFS_ACLTYPE_POSIX }, /* bkwrd compatibility */
023699cd
MM
264 { NULL }
265 };
266
8fdc6f61 267 static const zprop_index_t acl_inherit_table[] = {
34dc7c2f
BB
268 { "discard", ZFS_ACL_DISCARD },
269 { "noallow", ZFS_ACL_NOALLOW },
270 { "restricted", ZFS_ACL_RESTRICTED },
271 { "passthrough", ZFS_ACL_PASSTHROUGH },
4e33ba4c 272 { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatibility */
b128c09f 273 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
34dc7c2f
BB
274 { NULL }
275 };
276
8fdc6f61 277 static const zprop_index_t case_table[] = {
34dc7c2f
BB
278 { "sensitive", ZFS_CASE_SENSITIVE },
279 { "insensitive", ZFS_CASE_INSENSITIVE },
280 { "mixed", ZFS_CASE_MIXED },
281 { NULL }
282 };
283
8fdc6f61 284 static const zprop_index_t copies_table[] = {
34dc7c2f
BB
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 */
8fdc6f61 296 static const zprop_index_t normalize_table[] = {
34dc7c2f
BB
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
8fdc6f61 305 static const zprop_index_t version_table[] = {
34dc7c2f
BB
306 { "1", 1 },
307 { "2", 2 },
308 { "3", 3 },
9babb374 309 { "4", 4 },
428870ff 310 { "5", 5 },
34dc7c2f
BB
311 { "current", ZPL_VERSION },
312 { NULL }
313 };
314
8fdc6f61 315 static const zprop_index_t boolean_table[] = {
34dc7c2f
BB
316 { "off", 0 },
317 { "on", 1 },
318 { NULL }
319 };
320
8fdc6f61 321 static const zprop_index_t keystatus_table[] = {
b5256303
TC
322 { "none", ZFS_KEYSTATUS_NONE},
323 { "unavailable", ZFS_KEYSTATUS_UNAVAILABLE},
324 { "available", ZFS_KEYSTATUS_AVAILABLE},
325 { NULL }
326 };
327
8fdc6f61 328 static const zprop_index_t logbias_table[] = {
428870ff
BB
329 { "latency", ZFS_LOGBIAS_LATENCY },
330 { "throughput", ZFS_LOGBIAS_THROUGHPUT },
331 { NULL }
332 };
333
8fdc6f61 334 static const zprop_index_t canmount_table[] = {
34dc7c2f
BB
335 { "off", ZFS_CANMOUNT_OFF },
336 { "on", ZFS_CANMOUNT_ON },
337 { "noauto", ZFS_CANMOUNT_NOAUTO },
338 { NULL }
339 };
340
8fdc6f61 341 static const zprop_index_t cache_table[] = {
b128c09f
BB
342 { "none", ZFS_CACHE_NONE },
343 { "metadata", ZFS_CACHE_METADATA },
344 { "all", ZFS_CACHE_ALL },
345 { NULL }
346 };
347
07345ac2
BB
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
8fdc6f61 355 static const zprop_index_t sync_table[] = {
428870ff
BB
356 { "standard", ZFS_SYNC_STANDARD },
357 { "always", ZFS_SYNC_ALWAYS },
358 { "disabled", ZFS_SYNC_DISABLED },
359 { NULL }
360 };
361
8fdc6f61 362 static const zprop_index_t xattr_table[] = {
82a37189
BB
363 { "off", ZFS_XATTR_OFF },
364 { "on", ZFS_XATTR_DIR },
365 { "sa", ZFS_XATTR_SA },
366 { "dir", ZFS_XATTR_DIR },
367 { NULL }
368 };
369
8fdc6f61 370 static const zprop_index_t dnsize_table[] = {
50c957f7
NB
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
8fdc6f61 381 static const zprop_index_t redundant_metadata_table[] = {
faf0f58c
MA
382 { "all", ZFS_REDUNDANT_METADATA_ALL },
383 { "most", ZFS_REDUNDANT_METADATA_MOST },
5405be03
A
384 { "some", ZFS_REDUNDANT_METADATA_SOME },
385 { "none", ZFS_REDUNDANT_METADATA_NONE },
faf0f58c
MA
386 { NULL }
387 };
388
8fdc6f61 389 static const zprop_index_t volmode_table[] = {
cf8738d8 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
eb51a9d7
AZ
398 struct zfs_mod_supported_features *sfeatures =
399 zfs_mod_list_supported(ZFS_SYSFS_DATASET_PROPERTIES);
400
34dc7c2f 401 /* inherit index properties */
faf0f58c
MA
402 zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
403 ZFS_REDUNDANT_METADATA_ALL,
404 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
5405be03 405 "all | most | some | none", "REDUND_MD",
eb51a9d7 406 redundant_metadata_table, sfeatures);
428870ff 407 zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
34dc7c2f 408 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
428870ff 409 "standard | always | disabled", "SYNC",
eb51a9d7 410 sync_table, sfeatures);
428870ff
BB
411 zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
412 ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
413 ZFS_TYPE_VOLUME,
f95704ca 414 "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein"
985c33b1 415 " | edonr | blake3",
eb51a9d7 416 "CHECKSUM", checksum_table, sfeatures);
428870ff
BB
417 zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
418 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
1ddd7cdb 419 "on | off | verify | sha256[,verify] | sha512[,verify] | "
985c33b1 420 "skein[,verify] | edonr,verify | blake3[,verify]",
eb51a9d7 421 "DEDUP", dedup_table, sfeatures);
428870ff 422 zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
34dc7c2f
BB
423 ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
424 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
10b3c7f5
MN
425 "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | "
426 "zstd | zstd-[1-19] | "
3242b535 427 "zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]",
eb51a9d7 428 "COMPRESS", compress_table, sfeatures);
428870ff 429 zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
34dc7c2f 430 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
eb51a9d7 431 "hidden | visible", "SNAPDIR", snapdir_table, sfeatures);
0b4d1b58
ED
432 zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN,
433 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
eb51a9d7 434 "hidden | visible", "SNAPDEV", snapdev_table, sfeatures);
8c4987c4
RM
435 zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
436 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
437 "discard | groupmask | passthrough | restricted", "ACLMODE",
eb51a9d7 438 acl_mode_table, sfeatures);
485b50bb
RM
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,
7bf3e1fa 445#endif
485b50bb 446 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
eb51a9d7 447 "off | nfsv4 | posix", "ACLTYPE", acltype_table, sfeatures);
428870ff
BB
448 zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
449 ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
b128c09f 450 "discard | noallow | restricted | passthrough | passthrough-x",
eb51a9d7 451 "ACLINHERIT", acl_inherit_table, sfeatures);
428870ff
BB
452 zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
453 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
eb51a9d7 454 "1 | 2 | 3", "COPIES", copies_table, sfeatures);
428870ff 455 zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
b128c09f
BB
456 ZFS_CACHE_ALL, PROP_INHERIT,
457 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
eb51a9d7 458 "all | none | metadata", "PRIMARYCACHE", cache_table, sfeatures);
428870ff 459 zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
b128c09f
BB
460 ZFS_CACHE_ALL, PROP_INHERIT,
461 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
eb51a9d7 462 "all | none | metadata", "SECONDARYCACHE", cache_table, sfeatures);
07345ac2
BB
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);
428870ff
BB
467 zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
468 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
eb51a9d7 469 "latency | throughput", "LOGBIAS", logbias_table, sfeatures);
82a37189
BB
470 zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR,
471 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
eb51a9d7 472 "on | off | dir | sa", "XATTR", xattr_table, sfeatures);
50c957f7
NB
473 zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",
474 ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
eb51a9d7
AZ
475 "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table,
476 sfeatures);
cf8738d8 477 zprop_register_index(ZFS_PROP_VOLMODE, "volmode",
478 ZFS_VOLMODE_DEFAULT, PROP_INHERIT,
479 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
eb51a9d7
AZ
480 "default | full | geom | dev | none", "VOLMODE", volmode_table,
481 sfeatures);
34dc7c2f
BB
482
483 /* inherit index (boolean) properties */
428870ff 484 zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
eb51a9d7 485 ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table, sfeatures);
fbc210fa 486 zprop_register_index(ZFS_PROP_RELATIME, "relatime", 1, PROP_INHERIT,
eb51a9d7
AZ
487 ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table,
488 sfeatures);
428870ff 489 zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
34dc7c2f 490 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
eb51a9d7 491 boolean_table, sfeatures);
428870ff 492 zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
34dc7c2f 493 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
eb51a9d7 494 boolean_table, sfeatures);
428870ff 495 zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
34dc7c2f 496 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
eb51a9d7 497 boolean_table, sfeatures);
428870ff 498 zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
34dc7c2f 499 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
eb51a9d7 500 boolean_table, sfeatures);
4bc72196
MM
501#ifdef __FreeBSD__
502 zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT,
eb51a9d7
AZ
503 ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table,
504 sfeatures);
4bc72196 505#else
428870ff 506 zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
eb51a9d7 507 ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table, sfeatures);
4bc72196 508#endif
428870ff 509 zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
eb51a9d7 510 ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table, sfeatures);
428870ff 511 zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
34dc7c2f 512 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
eb51a9d7 513 boolean_table, sfeatures);
f5f6fb03 514 zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT,
eb51a9d7
AZ
515 ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table,
516 sfeatures);
34dc7c2f
BB
517
518 /* default index properties */
428870ff 519 zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
34dc7c2f 520 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
eb51a9d7 521 "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table, sfeatures);
428870ff 522 zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
34dc7c2f 523 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
eb51a9d7 524 "CANMOUNT", canmount_table, sfeatures);
34dc7c2f 525
b5256303 526 /* readonly index properties */
428870ff 527 zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
eb51a9d7
AZ
528 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table,
529 sfeatures);
428870ff 530 zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
45d1cae3 531 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
eb51a9d7 532 boolean_table, sfeatures);
b5256303
TC
533 zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",
534 ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,
535 "none | unavailable | available",
eb51a9d7 536 "KEYSTATUS", keystatus_table, sfeatures);
34dc7c2f
BB
537
538 /* set once index properties */
428870ff 539 zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
34dc7c2f
BB
540 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
541 "none | formC | formD | formKC | formKD", "NORMALIZATION",
eb51a9d7 542 normalize_table, sfeatures);
428870ff
BB
543 zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
544 ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
545 ZFS_TYPE_SNAPSHOT,
eb51a9d7 546 "sensitive | insensitive | mixed", "CASE", case_table, sfeatures);
b5256303
TC
547 zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",
548 ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,
549 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
eb51a9d7
AZ
550 "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table,
551 sfeatures);
b5256303
TC
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",
eb51a9d7 556 crypto_table, sfeatures);
34dc7c2f
BB
557
558 /* set once index (boolean) properties */
428870ff 559 zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
34dc7c2f 560 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
eb51a9d7 561 "on | off", "UTF8ONLY", boolean_table, sfeatures);
34dc7c2f
BB
562
563 /* string properties */
428870ff 564 zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
eb51a9d7
AZ
565 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN",
566 sfeatures);
330d06f9 567 zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
eb51a9d7 568 ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES", sfeatures);
428870ff
BB
569 zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
570 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
eb51a9d7 571 "MOUNTPOINT", sfeatures);
428870ff 572 zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
76d04993 573 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | NFS share options",
eb51a9d7 574 "SHARENFS", sfeatures);
428870ff 575 zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
da536844 576 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
eb51a9d7 577 "filesystem | volume | snapshot | bookmark", "TYPE", sfeatures);
428870ff
BB
578 zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
579 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
eb51a9d7 580 "on | off | SMB share options", "SHARESMB", sfeatures);
428870ff
BB
581 zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
582 ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
eb51a9d7 583 "<sensitivity label>", "MLSLABEL", sfeatures);
11b9ec23
MT
584 zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context",
585 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux context>",
eb51a9d7 586 "CONTEXT", sfeatures);
11b9ec23
MT
587 zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext",
588 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux fscontext>",
eb51a9d7 589 "FSCONTEXT", sfeatures);
11b9ec23
MT
590 zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext",
591 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux defcontext>",
eb51a9d7 592 "DEFCONTEXT", sfeatures);
11b9ec23
MT
593 zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext",
594 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux rootcontext>",
eb51a9d7 595 "ROOTCONTEXT", sfeatures);
47dfff3b
MA
596 zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN,
597 "receive_resume_token",
598 NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
eb51a9d7 599 "<string token>", "RESUMETOK", sfeatures);
b5256303
TC
600 zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,
601 PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",
eb51a9d7 602 "ENCROOT", sfeatures);
b5256303
TC
603 zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",
604 "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
eb51a9d7
AZ
605 "prompt | <file URI> | <https URL> | <http URL>", "KEYLOCATION",
606 sfeatures);
30af21b0
PD
607 zprop_register_string(ZFS_PROP_REDACT_SNAPS,
608 "redact_snaps", NULL, PROP_READONLY,
609 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<snapshot>[,...]",
eb51a9d7 610 "RSNAPS", sfeatures);
34dc7c2f
BB
611
612 /* readonly number properties */
428870ff 613 zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
be8e1d81 614 ZFS_TYPE_DATASET, "<size>", "USED", B_FALSE, sfeatures);
428870ff 615 zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
eb51a9d7 616 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL",
be8e1d81 617 B_FALSE, sfeatures);
428870ff 618 zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
30af21b0 619 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
be8e1d81 620 "REFER", B_FALSE, sfeatures);
428870ff 621 zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
30af21b0 622 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
be8e1d81 623 "<1.00x or higher if compressed>", "RATIO", B_FALSE, sfeatures);
f5fc4aca
MA
624 zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
625 PROP_READONLY, ZFS_TYPE_DATASET,
be8e1d81 626 "<1.00x or higher if compressed>", "REFRATIO", B_FALSE, sfeatures);
428870ff
BB
627 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
628 ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
be8e1d81
AZ
629 ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK", B_FALSE,
630 sfeatures);
60387fac
AH
631 zprop_register_index(ZFS_PROP_VOLTHREADING, "volthreading",
632 1, PROP_DEFAULT, ZFS_TYPE_VOLUME, "on | off", "zvol threading",
633 boolean_table, sfeatures);
428870ff
BB
634 zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
635 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
be8e1d81 636 "USEDSNAP", B_FALSE, sfeatures);
428870ff
BB
637 zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
638 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
be8e1d81 639 "USEDDS", B_FALSE, sfeatures);
428870ff
BB
640 zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
641 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
be8e1d81 642 "USEDCHILD", B_FALSE, sfeatures);
428870ff 643 zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
b128c09f 644 PROP_READONLY,
eb51a9d7 645 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV",
be8e1d81 646 B_FALSE, sfeatures);
428870ff 647 zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
be8e1d81 648 ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS", B_FALSE, sfeatures);
330d06f9 649 zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
be8e1d81 650 ZFS_TYPE_DATASET, "<size>", "WRITTEN", B_FALSE, sfeatures);
24a64651 651 zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
d99a0153 652 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
be8e1d81 653 "LUSED", B_FALSE, sfeatures);
24a64651 654 zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
30af21b0 655 0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
be8e1d81 656 "LREFER", B_FALSE, sfeatures);
911c41af
GM
657 zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
658 UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM,
be8e1d81 659 "<count>", "FSCOUNT", B_FALSE, sfeatures);
911c41af
GM
660 zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
661 UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
be8e1d81 662 "<count>", "SSCOUNT", B_FALSE, sfeatures);
305bc4b3 663 zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY,
eb51a9d7 664 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID",
be8e1d81 665 B_TRUE, sfeatures);
305bc4b3 666 zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,
eb51a9d7 667 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG",
be8e1d81 668 B_TRUE, sfeatures);
b5256303
TC
669 zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",
670 0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
be8e1d81 671 "<iters>", "PBKDF2ITERS", B_TRUE, sfeatures);
a448a255 672 zprop_register_number(ZFS_PROP_OBJSETID, "objsetid", 0,
be8e1d81
AZ
673 PROP_READONLY, ZFS_TYPE_DATASET, "<uint64>", "OBJSETID", B_TRUE,
674 sfeatures);
34dc7c2f
BB
675
676 /* default number properties */
428870ff 677 zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
be8e1d81 678 ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA", B_FALSE, sfeatures);
428870ff
BB
679 zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
680 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
be8e1d81 681 "<size> | none", "RESERV", B_FALSE, sfeatures);
428870ff 682 zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
eb51a9d7 683 ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE",
be8e1d81 684 B_FALSE, sfeatures);
428870ff 685 zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
be8e1d81
AZ
686 ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA", B_FALSE,
687 sfeatures);
428870ff 688 zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
34dc7c2f 689 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
be8e1d81 690 "<size> | none", "REFRESERV", B_FALSE, sfeatures);
788eb90c
JJ
691 zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
692 UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
be8e1d81 693 "<count> | none", "FSLIMIT", B_FALSE, sfeatures);
788eb90c
JJ
694 zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
695 UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
be8e1d81 696 "<count> | none", "SSLIMIT", B_FALSE, sfeatures);
34dc7c2f
BB
697
698 /* inherit number properties */
428870ff 699 zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
f1512ee6 700 SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,
be8e1d81
AZ
701 ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE", B_FALSE,
702 sfeatures);
cc99f275
DB
703 zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,
704 "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
be8e1d81
AZ
705 "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS", B_FALSE,
706 sfeatures);
34dc7c2f
BB
707
708 /* hidden properties */
428870ff 709 zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
be8e1d81 710 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES", B_FALSE, sfeatures);
428870ff 711 zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
eb51a9d7 712 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME",
be8e1d81 713 B_TRUE, sfeatures);
428870ff 714 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
eb51a9d7 715 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS",
be8e1d81 716 B_TRUE, sfeatures);
428870ff 717 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
9babb374 718 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
be8e1d81 719 "STMF_SBD_LU", B_TRUE, sfeatures);
428870ff
BB
720 zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
721 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
be8e1d81 722 "USERACCOUNTING", B_FALSE, sfeatures);
428870ff 723 zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
be8e1d81 724 PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE", B_FALSE, sfeatures);
96c2e961 725 zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
eb51a9d7 726 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT",
be8e1d81 727 B_FALSE, sfeatures);
f00ab3f2
TC
728 zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid",
729 PROP_TYPE_NUMBER, PROP_READONLY,
be8e1d81
AZ
730 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID", B_TRUE,
731 sfeatures);
1715493f 732 zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
eb51a9d7 733 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP",
be8e1d81 734 B_TRUE, sfeatures);
b5256303
TC
735 zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",
736 PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,
be8e1d81
AZ
737 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT", B_FALSE,
738 sfeatures);
b5256303 739 zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,
be8e1d81 740 PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID", B_TRUE, sfeatures);
30af21b0 741 zprop_register_hidden(ZFS_PROP_REDACTED, "redacted", PROP_TYPE_NUMBER,
be8e1d81 742 PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED", B_FALSE, sfeatures);
428870ff
BB
743
744 /*
59ec30a3
MA
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[].
428870ff 748 */
59ec30a3 749 zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,
be8e1d81 750 PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG", B_FALSE, sfeatures);
34dc7c2f
BB
751
752 /* oddball properties */
be8e1d81 753 /* 'creation' is a number but displayed as human-readable => flex */
428870ff 754 zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
da536844 755 NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
be8e1d81 756 "<date>", "CREATION", B_FALSE, B_TRUE, B_TRUE, NULL, sfeatures);
eb51a9d7 757
9681de46
US
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
eb51a9d7 763 zfs_mod_list_supported_free(sfeatures);
34dc7c2f
BB
764}
765
766boolean_t
767zfs_prop_delegatable(zfs_prop_t prop)
768{
109731cd
DS
769 ASSERT3S(prop, >=, 0);
770 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f 771 zprop_desc_t *pd = &zfs_prop_table[prop];
428870ff
BB
772
773 /* The mlslabel property is never delegatable. */
774 if (prop == ZFS_PROP_MLSLABEL)
775 return (B_FALSE);
776
34dc7c2f
BB
777 return (pd->pd_attr != PROP_READONLY);
778}
779
780/*
781 * Given a zfs dataset property name, returns the corresponding property ID.
782 */
783zfs_prop_t
784zfs_name_to_prop(const char *propname)
785{
786 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
787}
788
34dc7c2f
BB
789/*
790 * Returns true if this is a valid user-defined property (one with a ':').
791 */
792boolean_t
793zfs_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];
2a673e76 801 if (!zprop_valid_char(c))
34dc7c2f
BB
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
9babb374
BB
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 */
818boolean_t
819zfs_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
330d06f9
MA
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 */
838boolean_t
839zfs_prop_written(const char *name)
840{
30af21b0
PD
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);
330d06f9
MA
845}
846
34dc7c2f
BB
847/*
848 * Tables of index types, plus functions to convert between the user view
849 * (strings) and internal representation (uint64_t).
850 */
851int
852zfs_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
857int
858zfs_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
428870ff
BB
863uint64_t
864zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
865{
866 return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
867}
868
34dc7c2f
BB
869/*
870 * Returns TRUE if the property applies to any of the given dataset types.
871 */
b128c09f 872boolean_t
962d5242 873zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck)
34dc7c2f 874{
962d5242 875 return (zprop_valid_for_type(prop, types, headcheck));
34dc7c2f
BB
876}
877
878zprop_type_t
879zfs_prop_get_type(zfs_prop_t prop)
880{
109731cd
DS
881 ASSERT3S(prop, >=, 0);
882 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
883 return (zfs_prop_table[prop].pd_proptype);
884}
885
886/*
887 * Returns TRUE if the property is readonly.
888 */
889boolean_t
890zfs_prop_readonly(zfs_prop_t prop)
891{
109731cd
DS
892 ASSERT3S(prop, >=, 0);
893 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f 894 return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
b5256303
TC
895 zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
896 zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
34dc7c2f
BB
897}
898
d99a0153
CW
899/*
900 * Returns TRUE if the property is visible (not hidden).
901 */
902boolean_t
903zfs_prop_visible(zfs_prop_t prop)
904{
109731cd
DS
905 ASSERT3S(prop, >=, 0);
906 ASSERT3S(prop, <, ZFS_NUM_PROPS);
e8bcb693
DB
907 return (zfs_prop_table[prop].pd_visible &&
908 zfs_prop_table[prop].pd_zfs_mod_supported);
d99a0153
CW
909}
910
34dc7c2f
BB
911/*
912 * Returns TRUE if the property is only allowed to be set once.
913 */
914boolean_t
915zfs_prop_setonce(zfs_prop_t prop)
916{
109731cd
DS
917 ASSERT3S(prop, >=, 0);
918 ASSERT3S(prop, <, ZFS_NUM_PROPS);
b5256303
TC
919 return (zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
920 zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
34dc7c2f
BB
921}
922
923const char *
924zfs_prop_default_string(zfs_prop_t prop)
925{
109731cd
DS
926 ASSERT3S(prop, >=, 0);
927 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
928 return (zfs_prop_table[prop].pd_strdefault);
929}
930
931uint64_t
932zfs_prop_default_numeric(zfs_prop_t prop)
933{
109731cd
DS
934 ASSERT3S(prop, >=, 0);
935 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
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 */
943const char *
944zfs_prop_to_name(zfs_prop_t prop)
945{
109731cd
DS
946 ASSERT3S(prop, >=, 0);
947 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
948 return (zfs_prop_table[prop].pd_name);
949}
950
951/*
952 * Returns TRUE if the property is inheritable.
953 */
954boolean_t
955zfs_prop_inheritable(zfs_prop_t prop)
956{
109731cd
DS
957 ASSERT3S(prop, >=, 0);
958 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
959 return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
960 zfs_prop_table[prop].pd_attr == PROP_ONETIME);
961}
962
b5256303
TC
963/*
964 * Returns TRUE if property is one of the encryption properties that requires
965 * a loaded encryption key to modify.
966 */
967boolean_t
968zfs_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 */
983boolean_t
984zfs_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);
37086897
AZ
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);
b5256303
TC
996
997 return (B_FALSE);
998}
999
1000
34dc7c2f 1001#ifndef _KERNEL
60356b1a 1002#include <libzfs.h>
34dc7c2f
BB
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 */
1008const char *
1009zfs_prop_values(zfs_prop_t prop)
1010{
109731cd
DS
1011 ASSERT3S(prop, >=, 0);
1012 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
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 */
1021int
1022zfs_prop_is_string(zfs_prop_t prop)
1023{
109731cd
DS
1024 ASSERT3S(prop, >=, 0);
1025 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
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 */
1034const char *
1035zfs_prop_column_name(zfs_prop_t prop)
1036{
109731cd
DS
1037 ASSERT3S(prop, >=, 0);
1038 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
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 */
1046boolean_t
1047zfs_prop_align_right(zfs_prop_t prop)
1048{
109731cd
DS
1049 ASSERT3S(prop, >=, 0);
1050 ASSERT3S(prop, <, ZFS_NUM_PROPS);
34dc7c2f
BB
1051 return (zfs_prop_table[prop].pd_rightalign);
1052}
1053
1054#endif
c28b2279 1055
93ce2b4c 1056#if defined(_KERNEL)
10fa2545 1057
ce7a5dbf
AF
1058#if defined(HAVE_KERNEL_FPU_INTERNAL)
1059uint8_t **zfs_kfpu_fpregs;
10fa2545 1060EXPORT_SYMBOL(zfs_kfpu_fpregs);
ce7a5dbf 1061#endif /* defined(HAVE_KERNEL_FPU_INTERNAL) */
10fa2545 1062
ad9e7676
AZ
1063extern int __init zcommon_init(void);
1064extern void zcommon_fini(void);
1065
1066int __init
b4f3666a
BB
1067zcommon_init(void)
1068{
10fa2545
BB
1069 int error = kfpu_init();
1070 if (error)
1071 return (error);
1072
1eeb4562 1073 fletcher_4_init();
10fa2545 1074
b4f3666a
BB
1075 return (0);
1076}
c28b2279 1077
ad9e7676 1078void
b4f3666a
BB
1079zcommon_fini(void)
1080{
1eeb4562 1081 fletcher_4_fini();
10fa2545 1082 kfpu_fini();
b4f3666a 1083}
c28b2279 1084
ad9e7676 1085#ifdef __FreeBSD__
e0716250 1086module_init_early(zcommon_init);
b4f3666a 1087module_exit(zcommon_fini);
4a2ed900
MM
1088#endif
1089
ad9e7676 1090#endif
c28b2279
BB
1091
1092/* zfs dataset property functions */
1093EXPORT_SYMBOL(zfs_userquota_prop_prefixes);
1094EXPORT_SYMBOL(zfs_prop_init);
1095EXPORT_SYMBOL(zfs_prop_get_type);
1096EXPORT_SYMBOL(zfs_prop_get_table);
1097EXPORT_SYMBOL(zfs_prop_delegatable);
d99a0153 1098EXPORT_SYMBOL(zfs_prop_visible);
c28b2279
BB
1099
1100/* Dataset property functions shared between libzfs and kernel. */
1101EXPORT_SYMBOL(zfs_prop_default_string);
1102EXPORT_SYMBOL(zfs_prop_default_numeric);
1103EXPORT_SYMBOL(zfs_prop_readonly);
1104EXPORT_SYMBOL(zfs_prop_inheritable);
b5256303
TC
1105EXPORT_SYMBOL(zfs_prop_encryption_key_param);
1106EXPORT_SYMBOL(zfs_prop_valid_keylocation);
c28b2279
BB
1107EXPORT_SYMBOL(zfs_prop_setonce);
1108EXPORT_SYMBOL(zfs_prop_to_name);
1109EXPORT_SYMBOL(zfs_name_to_prop);
1110EXPORT_SYMBOL(zfs_prop_user);
1111EXPORT_SYMBOL(zfs_prop_userquota);
1112EXPORT_SYMBOL(zfs_prop_index_to_string);
1113EXPORT_SYMBOL(zfs_prop_string_to_index);
1114EXPORT_SYMBOL(zfs_prop_valid_for_type);
d99a0153 1115EXPORT_SYMBOL(zfs_prop_written);