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 http://www.opensolaris.org/os/licensing.
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]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
24 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25 * Copyright 2016, Joyent, Inc.
28 /* Portions Copyright 2010 Robert Milkowski */
32 #include <sys/u8_textprep.h>
33 #include <sys/zfs_acl.h>
34 #include <sys/zfs_ioctl.h>
35 #include <sys/zfs_znode.h>
36 #include <sys/dsl_crypt.h>
39 #include "zfs_deleg.h"
40 #include "zfs_fletcher.h"
43 #include <sys/systm.h>
50 static zprop_desc_t zfs_prop_table
[ZFS_NUM_PROPS
];
52 /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
53 const char *zfs_userquota_prop_prefixes
[] = {
65 zfs_prop_get_table(void)
67 return (zfs_prop_table
);
73 static zprop_index_t checksum_table
[] = {
74 { "on", ZIO_CHECKSUM_ON
},
75 { "off", ZIO_CHECKSUM_OFF
},
76 { "fletcher2", ZIO_CHECKSUM_FLETCHER_2
},
77 { "fletcher4", ZIO_CHECKSUM_FLETCHER_4
},
78 { "sha256", ZIO_CHECKSUM_SHA256
},
79 { "noparity", ZIO_CHECKSUM_NOPARITY
},
80 { "sha512", ZIO_CHECKSUM_SHA512
},
81 { "skein", ZIO_CHECKSUM_SKEIN
},
82 { "edonr", ZIO_CHECKSUM_EDONR
},
86 static zprop_index_t dedup_table
[] = {
87 { "on", ZIO_CHECKSUM_ON
},
88 { "off", ZIO_CHECKSUM_OFF
},
89 { "verify", ZIO_CHECKSUM_ON
| ZIO_CHECKSUM_VERIFY
},
90 { "sha256", ZIO_CHECKSUM_SHA256
},
92 ZIO_CHECKSUM_SHA256
| ZIO_CHECKSUM_VERIFY
},
93 { "sha512", ZIO_CHECKSUM_SHA512
},
95 ZIO_CHECKSUM_SHA512
| ZIO_CHECKSUM_VERIFY
},
96 { "skein", ZIO_CHECKSUM_SKEIN
},
98 ZIO_CHECKSUM_SKEIN
| ZIO_CHECKSUM_VERIFY
},
100 ZIO_CHECKSUM_EDONR
| ZIO_CHECKSUM_VERIFY
},
104 static zprop_index_t compress_table
[] = {
105 { "on", ZIO_COMPRESS_ON
},
106 { "off", ZIO_COMPRESS_OFF
},
107 { "lzjb", ZIO_COMPRESS_LZJB
},
108 { "gzip", ZIO_COMPRESS_GZIP_6
}, /* gzip default */
109 { "gzip-1", ZIO_COMPRESS_GZIP_1
},
110 { "gzip-2", ZIO_COMPRESS_GZIP_2
},
111 { "gzip-3", ZIO_COMPRESS_GZIP_3
},
112 { "gzip-4", ZIO_COMPRESS_GZIP_4
},
113 { "gzip-5", ZIO_COMPRESS_GZIP_5
},
114 { "gzip-6", ZIO_COMPRESS_GZIP_6
},
115 { "gzip-7", ZIO_COMPRESS_GZIP_7
},
116 { "gzip-8", ZIO_COMPRESS_GZIP_8
},
117 { "gzip-9", ZIO_COMPRESS_GZIP_9
},
118 { "zle", ZIO_COMPRESS_ZLE
},
119 { "lz4", ZIO_COMPRESS_LZ4
},
123 static zprop_index_t crypto_table
[] = {
124 { "on", ZIO_CRYPT_ON
},
125 { "off", ZIO_CRYPT_OFF
},
126 { "aes-128-ccm", ZIO_CRYPT_AES_128_CCM
},
127 { "aes-192-ccm", ZIO_CRYPT_AES_192_CCM
},
128 { "aes-256-ccm", ZIO_CRYPT_AES_256_CCM
},
129 { "aes-128-gcm", ZIO_CRYPT_AES_128_GCM
},
130 { "aes-192-gcm", ZIO_CRYPT_AES_192_GCM
},
131 { "aes-256-gcm", ZIO_CRYPT_AES_256_GCM
},
135 static zprop_index_t keyformat_table
[] = {
136 { "none", ZFS_KEYFORMAT_NONE
},
137 { "raw", ZFS_KEYFORMAT_RAW
},
138 { "hex", ZFS_KEYFORMAT_HEX
},
139 { "passphrase", ZFS_KEYFORMAT_PASSPHRASE
},
143 static zprop_index_t snapdir_table
[] = {
144 { "hidden", ZFS_SNAPDIR_HIDDEN
},
145 { "visible", ZFS_SNAPDIR_VISIBLE
},
149 static zprop_index_t snapdev_table
[] = {
150 { "hidden", ZFS_SNAPDEV_HIDDEN
},
151 { "visible", ZFS_SNAPDEV_VISIBLE
},
155 static zprop_index_t acltype_table
[] = {
156 { "off", ZFS_ACLTYPE_OFF
},
157 { "disabled", ZFS_ACLTYPE_OFF
},
158 { "noacl", ZFS_ACLTYPE_OFF
},
159 { "posixacl", ZFS_ACLTYPE_POSIXACL
},
163 static zprop_index_t acl_inherit_table
[] = {
164 { "discard", ZFS_ACL_DISCARD
},
165 { "noallow", ZFS_ACL_NOALLOW
},
166 { "restricted", ZFS_ACL_RESTRICTED
},
167 { "passthrough", ZFS_ACL_PASSTHROUGH
},
168 { "secure", ZFS_ACL_RESTRICTED
}, /* bkwrd compatibility */
169 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X
},
173 static zprop_index_t case_table
[] = {
174 { "sensitive", ZFS_CASE_SENSITIVE
},
175 { "insensitive", ZFS_CASE_INSENSITIVE
},
176 { "mixed", ZFS_CASE_MIXED
},
180 static zprop_index_t copies_table
[] = {
188 * Use the unique flags we have to send to u8_strcmp() and/or
189 * u8_textprep() to represent the various normalization property
192 static zprop_index_t normalize_table
[] = {
194 { "formD", U8_TEXTPREP_NFD
},
195 { "formKC", U8_TEXTPREP_NFKC
},
196 { "formC", U8_TEXTPREP_NFC
},
197 { "formKD", U8_TEXTPREP_NFKD
},
201 static zprop_index_t version_table
[] = {
207 { "current", ZPL_VERSION
},
211 static zprop_index_t boolean_table
[] = {
217 static zprop_index_t keystatus_table
[] = {
218 { "none", ZFS_KEYSTATUS_NONE
},
219 { "unavailable", ZFS_KEYSTATUS_UNAVAILABLE
},
220 { "available", ZFS_KEYSTATUS_AVAILABLE
},
224 static zprop_index_t logbias_table
[] = {
225 { "latency", ZFS_LOGBIAS_LATENCY
},
226 { "throughput", ZFS_LOGBIAS_THROUGHPUT
},
230 static zprop_index_t canmount_table
[] = {
231 { "off", ZFS_CANMOUNT_OFF
},
232 { "on", ZFS_CANMOUNT_ON
},
233 { "noauto", ZFS_CANMOUNT_NOAUTO
},
237 static zprop_index_t cache_table
[] = {
238 { "none", ZFS_CACHE_NONE
},
239 { "metadata", ZFS_CACHE_METADATA
},
240 { "all", ZFS_CACHE_ALL
},
244 static zprop_index_t sync_table
[] = {
245 { "standard", ZFS_SYNC_STANDARD
},
246 { "always", ZFS_SYNC_ALWAYS
},
247 { "disabled", ZFS_SYNC_DISABLED
},
251 static zprop_index_t xattr_table
[] = {
252 { "off", ZFS_XATTR_OFF
},
253 { "on", ZFS_XATTR_DIR
},
254 { "sa", ZFS_XATTR_SA
},
255 { "dir", ZFS_XATTR_DIR
},
259 static zprop_index_t dnsize_table
[] = {
260 { "legacy", ZFS_DNSIZE_LEGACY
},
261 { "auto", ZFS_DNSIZE_AUTO
},
262 { "1k", ZFS_DNSIZE_1K
},
263 { "2k", ZFS_DNSIZE_2K
},
264 { "4k", ZFS_DNSIZE_4K
},
265 { "8k", ZFS_DNSIZE_8K
},
266 { "16k", ZFS_DNSIZE_16K
},
270 static zprop_index_t redundant_metadata_table
[] = {
271 { "all", ZFS_REDUNDANT_METADATA_ALL
},
272 { "most", ZFS_REDUNDANT_METADATA_MOST
},
276 static zprop_index_t volmode_table
[] = {
277 { "default", ZFS_VOLMODE_DEFAULT
},
278 { "full", ZFS_VOLMODE_GEOM
},
279 { "geom", ZFS_VOLMODE_GEOM
},
280 { "dev", ZFS_VOLMODE_DEV
},
281 { "none", ZFS_VOLMODE_NONE
},
285 /* inherit index properties */
286 zprop_register_index(ZFS_PROP_REDUNDANT_METADATA
, "redundant_metadata",
287 ZFS_REDUNDANT_METADATA_ALL
,
288 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
289 "all | most", "REDUND_MD",
290 redundant_metadata_table
);
291 zprop_register_index(ZFS_PROP_SYNC
, "sync", ZFS_SYNC_STANDARD
,
292 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
293 "standard | always | disabled", "SYNC",
295 zprop_register_index(ZFS_PROP_CHECKSUM
, "checksum",
296 ZIO_CHECKSUM_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
|
298 "on | off | fletcher2 | fletcher4 | sha256 | sha512 | "
299 "skein | edonr", "CHECKSUM", checksum_table
);
300 zprop_register_index(ZFS_PROP_DEDUP
, "dedup", ZIO_CHECKSUM_OFF
,
301 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
302 "on | off | verify | sha256[,verify], sha512[,verify], "
303 "skein[,verify], edonr,verify", "DEDUP", dedup_table
);
304 zprop_register_index(ZFS_PROP_COMPRESSION
, "compression",
305 ZIO_COMPRESS_DEFAULT
, PROP_INHERIT
,
306 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
307 "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", "COMPRESS",
309 zprop_register_index(ZFS_PROP_SNAPDIR
, "snapdir", ZFS_SNAPDIR_HIDDEN
,
310 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
311 "hidden | visible", "SNAPDIR", snapdir_table
);
312 zprop_register_index(ZFS_PROP_SNAPDEV
, "snapdev", ZFS_SNAPDEV_HIDDEN
,
313 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
314 "hidden | visible", "SNAPDEV", snapdev_table
);
315 zprop_register_index(ZFS_PROP_ACLTYPE
, "acltype", ZFS_ACLTYPE_OFF
,
316 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
317 "noacl | posixacl", "ACLTYPE", acltype_table
);
318 zprop_register_index(ZFS_PROP_ACLINHERIT
, "aclinherit",
319 ZFS_ACL_RESTRICTED
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
320 "discard | noallow | restricted | passthrough | passthrough-x",
321 "ACLINHERIT", acl_inherit_table
);
322 zprop_register_index(ZFS_PROP_COPIES
, "copies", 1, PROP_INHERIT
,
323 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
324 "1 | 2 | 3", "COPIES", copies_table
);
325 zprop_register_index(ZFS_PROP_PRIMARYCACHE
, "primarycache",
326 ZFS_CACHE_ALL
, PROP_INHERIT
,
327 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
328 "all | none | metadata", "PRIMARYCACHE", cache_table
);
329 zprop_register_index(ZFS_PROP_SECONDARYCACHE
, "secondarycache",
330 ZFS_CACHE_ALL
, PROP_INHERIT
,
331 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
332 "all | none | metadata", "SECONDARYCACHE", cache_table
);
333 zprop_register_index(ZFS_PROP_LOGBIAS
, "logbias", ZFS_LOGBIAS_LATENCY
,
334 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
335 "latency | throughput", "LOGBIAS", logbias_table
);
336 zprop_register_index(ZFS_PROP_XATTR
, "xattr", ZFS_XATTR_DIR
,
337 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
338 "on | off | dir | sa", "XATTR", xattr_table
);
339 zprop_register_index(ZFS_PROP_DNODESIZE
, "dnodesize",
340 ZFS_DNSIZE_LEGACY
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
341 "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table
);
342 zprop_register_index(ZFS_PROP_VOLMODE
, "volmode",
343 ZFS_VOLMODE_DEFAULT
, PROP_INHERIT
,
344 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
345 "default | full | geom | dev | none", "VOLMODE", volmode_table
);
347 /* inherit index (boolean) properties */
348 zprop_register_index(ZFS_PROP_ATIME
, "atime", 1, PROP_INHERIT
,
349 ZFS_TYPE_FILESYSTEM
, "on | off", "ATIME", boolean_table
);
350 zprop_register_index(ZFS_PROP_RELATIME
, "relatime", 0, PROP_INHERIT
,
351 ZFS_TYPE_FILESYSTEM
, "on | off", "RELATIME", boolean_table
);
352 zprop_register_index(ZFS_PROP_DEVICES
, "devices", 1, PROP_INHERIT
,
353 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "DEVICES",
355 zprop_register_index(ZFS_PROP_EXEC
, "exec", 1, PROP_INHERIT
,
356 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "EXEC",
358 zprop_register_index(ZFS_PROP_SETUID
, "setuid", 1, PROP_INHERIT
,
359 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "SETUID",
361 zprop_register_index(ZFS_PROP_READONLY
, "readonly", 0, PROP_INHERIT
,
362 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "on | off", "RDONLY",
364 zprop_register_index(ZFS_PROP_ZONED
, "zoned", 0, PROP_INHERIT
,
365 ZFS_TYPE_FILESYSTEM
, "on | off", "ZONED", boolean_table
);
366 zprop_register_index(ZFS_PROP_VSCAN
, "vscan", 0, PROP_INHERIT
,
367 ZFS_TYPE_FILESYSTEM
, "on | off", "VSCAN", boolean_table
);
368 zprop_register_index(ZFS_PROP_NBMAND
, "nbmand", 0, PROP_INHERIT
,
369 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "NBMAND",
371 zprop_register_index(ZFS_PROP_OVERLAY
, "overlay", 0, PROP_INHERIT
,
372 ZFS_TYPE_FILESYSTEM
, "on | off", "OVERLAY", boolean_table
);
374 /* default index properties */
375 zprop_register_index(ZFS_PROP_VERSION
, "version", 0, PROP_DEFAULT
,
376 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
377 "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table
);
378 zprop_register_index(ZFS_PROP_CANMOUNT
, "canmount", ZFS_CANMOUNT_ON
,
379 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
, "on | off | noauto",
380 "CANMOUNT", canmount_table
);
382 /* readonly index properties */
383 zprop_register_index(ZFS_PROP_MOUNTED
, "mounted", 0, PROP_READONLY
,
384 ZFS_TYPE_FILESYSTEM
, "yes | no", "MOUNTED", boolean_table
);
385 zprop_register_index(ZFS_PROP_DEFER_DESTROY
, "defer_destroy", 0,
386 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "yes | no", "DEFER_DESTROY",
388 zprop_register_index(ZFS_PROP_KEYSTATUS
, "keystatus",
389 ZFS_KEYSTATUS_NONE
, PROP_READONLY
, ZFS_TYPE_DATASET
,
390 "none | unavailable | available",
391 "KEYSTATUS", keystatus_table
);
393 /* set once index properties */
394 zprop_register_index(ZFS_PROP_NORMALIZE
, "normalization", 0,
395 PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
396 "none | formC | formD | formKC | formKD", "NORMALIZATION",
398 zprop_register_index(ZFS_PROP_CASE
, "casesensitivity",
399 ZFS_CASE_SENSITIVE
, PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
|
401 "sensitive | insensitive | mixed", "CASE", case_table
);
402 zprop_register_index(ZFS_PROP_KEYFORMAT
, "keyformat",
403 ZFS_KEYFORMAT_NONE
, PROP_ONETIME_DEFAULT
,
404 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
405 "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table
);
406 zprop_register_index(ZFS_PROP_ENCRYPTION
, "encryption",
407 ZIO_CRYPT_DEFAULT
, PROP_ONETIME
, ZFS_TYPE_DATASET
,
408 "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "
409 "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",
412 /* set once index (boolean) properties */
413 zprop_register_index(ZFS_PROP_UTF8ONLY
, "utf8only", 0, PROP_ONETIME
,
414 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
415 "on | off", "UTF8ONLY", boolean_table
);
417 /* string properties */
418 zprop_register_string(ZFS_PROP_ORIGIN
, "origin", NULL
, PROP_READONLY
,
419 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<snapshot>", "ORIGIN");
420 zprop_register_string(ZFS_PROP_CLONES
, "clones", NULL
, PROP_READONLY
,
421 ZFS_TYPE_SNAPSHOT
, "<dataset>[,...]", "CLONES");
422 zprop_register_string(ZFS_PROP_MOUNTPOINT
, "mountpoint", "/",
423 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "<path> | legacy | none",
425 zprop_register_string(ZFS_PROP_SHARENFS
, "sharenfs", "off",
426 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "on | off | share(1M) options",
428 zprop_register_string(ZFS_PROP_TYPE
, "type", NULL
, PROP_READONLY
,
429 ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
,
430 "filesystem | volume | snapshot | bookmark", "TYPE");
431 zprop_register_string(ZFS_PROP_SHARESMB
, "sharesmb", "off",
432 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
433 "on | off | sharemgr(1M) options", "SHARESMB");
434 zprop_register_string(ZFS_PROP_MLSLABEL
, "mlslabel",
435 ZFS_MLSLABEL_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_DATASET
,
436 "<sensitivity label>", "MLSLABEL");
437 zprop_register_string(ZFS_PROP_SELINUX_CONTEXT
, "context",
438 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux context>",
440 zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT
, "fscontext",
441 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux fscontext>",
443 zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT
, "defcontext",
444 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux defcontext>",
446 zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT
, "rootcontext",
447 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux rootcontext>",
449 zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN
,
450 "receive_resume_token",
451 NULL
, PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
452 "<string token>", "RESUMETOK");
453 zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT
, "encryptionroot", NULL
,
454 PROP_READONLY
, ZFS_TYPE_DATASET
, "<filesystem | volume>",
456 zprop_register_string(ZFS_PROP_KEYLOCATION
, "keylocation",
457 "none", PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
458 "prompt | <file URI>", "KEYLOCATION");
460 /* readonly number properties */
461 zprop_register_number(ZFS_PROP_USED
, "used", 0, PROP_READONLY
,
462 ZFS_TYPE_DATASET
, "<size>", "USED");
463 zprop_register_number(ZFS_PROP_AVAILABLE
, "available", 0, PROP_READONLY
,
464 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "AVAIL");
465 zprop_register_number(ZFS_PROP_REFERENCED
, "referenced", 0,
466 PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "REFER");
467 zprop_register_number(ZFS_PROP_COMPRESSRATIO
, "compressratio", 0,
468 PROP_READONLY
, ZFS_TYPE_DATASET
,
469 "<1.00x or higher if compressed>", "RATIO");
470 zprop_register_number(ZFS_PROP_REFRATIO
, "refcompressratio", 0,
471 PROP_READONLY
, ZFS_TYPE_DATASET
,
472 "<1.00x or higher if compressed>", "REFRATIO");
473 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE
, "volblocksize",
474 ZVOL_DEFAULT_BLOCKSIZE
, PROP_ONETIME
,
475 ZFS_TYPE_VOLUME
, "512 to 128k, power of 2", "VOLBLOCK");
476 zprop_register_number(ZFS_PROP_USEDSNAP
, "usedbysnapshots", 0,
477 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
479 zprop_register_number(ZFS_PROP_USEDDS
, "usedbydataset", 0,
480 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
482 zprop_register_number(ZFS_PROP_USEDCHILD
, "usedbychildren", 0,
483 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
485 zprop_register_number(ZFS_PROP_USEDREFRESERV
, "usedbyrefreservation", 0,
487 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "USEDREFRESERV");
488 zprop_register_number(ZFS_PROP_USERREFS
, "userrefs", 0, PROP_READONLY
,
489 ZFS_TYPE_SNAPSHOT
, "<count>", "USERREFS");
490 zprop_register_number(ZFS_PROP_WRITTEN
, "written", 0, PROP_READONLY
,
491 ZFS_TYPE_DATASET
, "<size>", "WRITTEN");
492 zprop_register_number(ZFS_PROP_LOGICALUSED
, "logicalused", 0,
493 PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "LUSED");
494 zprop_register_number(ZFS_PROP_LOGICALREFERENCED
, "logicalreferenced",
495 0, PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "LREFER");
496 zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT
, "filesystem_count",
497 UINT64_MAX
, PROP_READONLY
, ZFS_TYPE_FILESYSTEM
,
498 "<count>", "FSCOUNT");
499 zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT
, "snapshot_count",
500 UINT64_MAX
, PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
501 "<count>", "SSCOUNT");
502 zprop_register_number(ZFS_PROP_GUID
, "guid", 0, PROP_READONLY
,
503 ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
, "<uint64>", "GUID");
504 zprop_register_number(ZFS_PROP_CREATETXG
, "createtxg", 0, PROP_READONLY
,
505 ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
, "<uint64>", "CREATETXG");
506 zprop_register_number(ZFS_PROP_PBKDF2_ITERS
, "pbkdf2iters",
507 0, PROP_ONETIME_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
508 "<iters>", "PBKDF2ITERS");
510 /* default number properties */
511 zprop_register_number(ZFS_PROP_QUOTA
, "quota", 0, PROP_DEFAULT
,
512 ZFS_TYPE_FILESYSTEM
, "<size> | none", "QUOTA");
513 zprop_register_number(ZFS_PROP_RESERVATION
, "reservation", 0,
514 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
515 "<size> | none", "RESERV");
516 zprop_register_number(ZFS_PROP_VOLSIZE
, "volsize", 0, PROP_DEFAULT
,
517 ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
, "<size>", "VOLSIZE");
518 zprop_register_number(ZFS_PROP_REFQUOTA
, "refquota", 0, PROP_DEFAULT
,
519 ZFS_TYPE_FILESYSTEM
, "<size> | none", "REFQUOTA");
520 zprop_register_number(ZFS_PROP_REFRESERVATION
, "refreservation", 0,
521 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
522 "<size> | none", "REFRESERV");
523 zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT
, "filesystem_limit",
524 UINT64_MAX
, PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
,
525 "<count> | none", "FSLIMIT");
526 zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT
, "snapshot_limit",
527 UINT64_MAX
, PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
528 "<count> | none", "SSLIMIT");
530 /* inherit number properties */
531 zprop_register_number(ZFS_PROP_RECORDSIZE
, "recordsize",
532 SPA_OLD_MAXBLOCKSIZE
, PROP_INHERIT
,
533 ZFS_TYPE_FILESYSTEM
, "512 to 1M, power of 2", "RECSIZE");
535 /* hidden properties */
536 zprop_register_hidden(ZFS_PROP_NUMCLONES
, "numclones", PROP_TYPE_NUMBER
,
537 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "NUMCLONES");
538 zprop_register_hidden(ZFS_PROP_NAME
, "name", PROP_TYPE_STRING
,
539 PROP_READONLY
, ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
, "NAME");
540 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS
, "iscsioptions",
541 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
, "ISCSIOPTIONS");
542 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO
, "stmf_sbd_lu",
543 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
,
545 zprop_register_hidden(ZFS_PROP_USERACCOUNTING
, "useraccounting",
546 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_DATASET
,
548 zprop_register_hidden(ZFS_PROP_UNIQUE
, "unique", PROP_TYPE_NUMBER
,
549 PROP_READONLY
, ZFS_TYPE_DATASET
, "UNIQUE");
550 zprop_register_hidden(ZFS_PROP_OBJSETID
, "objsetid", PROP_TYPE_NUMBER
,
551 PROP_READONLY
, ZFS_TYPE_DATASET
, "OBJSETID");
552 zprop_register_hidden(ZFS_PROP_INCONSISTENT
, "inconsistent",
553 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_DATASET
, "INCONSISTENT");
554 zprop_register_hidden(ZFS_PROP_PREV_SNAP
, "prevsnap", PROP_TYPE_STRING
,
555 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "PREVSNAP");
556 zprop_register_hidden(ZFS_PROP_PBKDF2_SALT
, "pbkdf2salt",
557 PROP_TYPE_NUMBER
, PROP_ONETIME_DEFAULT
,
558 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "PBKDF2SALT");
559 zprop_register_hidden(ZFS_PROP_KEY_GUID
, "keyguid", PROP_TYPE_NUMBER
,
560 PROP_READONLY
, ZFS_TYPE_DATASET
, "KEYGUID");
563 * Property to be removed once libbe is integrated
565 zprop_register_hidden(ZFS_PROP_PRIVATE
, "priv_prop",
566 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_FILESYSTEM
,
569 /* oddball properties */
570 zprop_register_impl(ZFS_PROP_CREATION
, "creation", PROP_TYPE_NUMBER
, 0,
571 NULL
, PROP_READONLY
, ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
,
572 "<date>", "CREATION", B_FALSE
, B_TRUE
, NULL
);
576 zfs_prop_delegatable(zfs_prop_t prop
)
578 zprop_desc_t
*pd
= &zfs_prop_table
[prop
];
580 /* The mlslabel property is never delegatable. */
581 if (prop
== ZFS_PROP_MLSLABEL
)
584 return (pd
->pd_attr
!= PROP_READONLY
);
588 * Given a zfs dataset property name, returns the corresponding property ID.
591 zfs_name_to_prop(const char *propname
)
593 return (zprop_name_to_prop(propname
, ZFS_TYPE_DATASET
));
597 * For user property names, we allow all lowercase alphanumeric characters, plus
598 * a few useful punctuation characters.
603 return ((c
>= 'a' && c
<= 'z') ||
604 (c
>= '0' && c
<= '9') ||
605 c
== '-' || c
== '_' || c
== '.' || c
== ':');
609 * Returns true if this is a valid user-defined property (one with a ':').
612 zfs_prop_user(const char *name
)
616 boolean_t foundsep
= B_FALSE
;
618 for (i
= 0; i
< strlen(name
); i
++) {
633 * Returns true if this is a valid userspace-type property (one with a '@').
634 * Note that after the @, any character is valid (eg, another @, for SID
638 zfs_prop_userquota(const char *name
)
640 zfs_userquota_prop_t prop
;
642 for (prop
= 0; prop
< ZFS_NUM_USERQUOTA_PROPS
; prop
++) {
643 if (strncmp(name
, zfs_userquota_prop_prefixes
[prop
],
644 strlen(zfs_userquota_prop_prefixes
[prop
])) == 0) {
653 * Returns true if this is a valid written@ property.
654 * Note that after the @, any character is valid (eg, another @, for
655 * written@pool/fs@origin).
658 zfs_prop_written(const char *name
)
660 static const char *prefix
= "written@";
661 return (strncmp(name
, prefix
, strlen(prefix
)) == 0);
665 * Tables of index types, plus functions to convert between the user view
666 * (strings) and internal representation (uint64_t).
669 zfs_prop_string_to_index(zfs_prop_t prop
, const char *string
, uint64_t *index
)
671 return (zprop_string_to_index(prop
, string
, index
, ZFS_TYPE_DATASET
));
675 zfs_prop_index_to_string(zfs_prop_t prop
, uint64_t index
, const char **string
)
677 return (zprop_index_to_string(prop
, index
, string
, ZFS_TYPE_DATASET
));
681 zfs_prop_random_value(zfs_prop_t prop
, uint64_t seed
)
683 return (zprop_random_value(prop
, seed
, ZFS_TYPE_DATASET
));
687 * Returns TRUE if the property applies to any of the given dataset types.
690 zfs_prop_valid_for_type(int prop
, zfs_type_t types
, boolean_t headcheck
)
692 return (zprop_valid_for_type(prop
, types
, headcheck
));
696 zfs_prop_get_type(zfs_prop_t prop
)
698 return (zfs_prop_table
[prop
].pd_proptype
);
702 * Returns TRUE if the property is readonly.
705 zfs_prop_readonly(zfs_prop_t prop
)
707 return (zfs_prop_table
[prop
].pd_attr
== PROP_READONLY
||
708 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
||
709 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME_DEFAULT
);
713 * Returns TRUE if the property is only allowed to be set once.
716 zfs_prop_setonce(zfs_prop_t prop
)
718 return (zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
||
719 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME_DEFAULT
);
723 zfs_prop_default_string(zfs_prop_t prop
)
725 return (zfs_prop_table
[prop
].pd_strdefault
);
729 zfs_prop_default_numeric(zfs_prop_t prop
)
731 return (zfs_prop_table
[prop
].pd_numdefault
);
735 * Given a dataset property ID, returns the corresponding name.
736 * Assuming the zfs dataset property ID is valid.
739 zfs_prop_to_name(zfs_prop_t prop
)
741 return (zfs_prop_table
[prop
].pd_name
);
745 * Returns TRUE if the property is inheritable.
748 zfs_prop_inheritable(zfs_prop_t prop
)
750 return (zfs_prop_table
[prop
].pd_attr
== PROP_INHERIT
||
751 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
755 * Returns TRUE if property is one of the encryption properties that requires
756 * a loaded encryption key to modify.
759 zfs_prop_encryption_key_param(zfs_prop_t prop
)
762 * keylocation does not count as an encryption property. It can be
763 * changed at will without needing the master keys.
765 return (prop
== ZFS_PROP_PBKDF2_SALT
|| prop
== ZFS_PROP_PBKDF2_ITERS
||
766 prop
== ZFS_PROP_KEYFORMAT
);
770 * Helper function used by both kernelspace and userspace to check the
771 * keylocation property. If encrypted is set, the keylocation must be valid
772 * for an encrypted dataset.
775 zfs_prop_valid_keylocation(const char *str
, boolean_t encrypted
)
777 if (strcmp("none", str
) == 0)
779 else if (strcmp("prompt", str
) == 0)
781 else if (strlen(str
) > 8 && strncmp("file:///", str
, 8) == 0)
791 * Returns a string describing the set of acceptable values for the given
792 * zfs property, or NULL if it cannot be set.
795 zfs_prop_values(zfs_prop_t prop
)
797 return (zfs_prop_table
[prop
].pd_values
);
801 * Returns TRUE if this property is a string type. Note that index types
802 * (compression, checksum) are treated as strings in userland, even though they
803 * are stored numerically on disk.
806 zfs_prop_is_string(zfs_prop_t prop
)
808 return (zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_STRING
||
809 zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_INDEX
);
813 * Returns the column header for the given property. Used only in
814 * 'zfs list -o', but centralized here with the other property information.
817 zfs_prop_column_name(zfs_prop_t prop
)
819 return (zfs_prop_table
[prop
].pd_colname
);
823 * Returns whether the given property should be displayed right-justified for
827 zfs_prop_align_right(zfs_prop_t prop
)
829 return (zfs_prop_table
[prop
].pd_rightalign
);
834 #if defined(_KERNEL) && defined(HAVE_SPL)
848 module_init(zcommon_init
);
849 module_exit(zcommon_fini
);
851 MODULE_DESCRIPTION("Generic ZFS support");
852 MODULE_AUTHOR(ZFS_META_AUTHOR
);
853 MODULE_LICENSE(ZFS_META_LICENSE
);
854 MODULE_VERSION(ZFS_META_VERSION
"-" ZFS_META_RELEASE
);
856 /* zfs dataset property functions */
857 EXPORT_SYMBOL(zfs_userquota_prop_prefixes
);
858 EXPORT_SYMBOL(zfs_prop_init
);
859 EXPORT_SYMBOL(zfs_prop_get_type
);
860 EXPORT_SYMBOL(zfs_prop_get_table
);
861 EXPORT_SYMBOL(zfs_prop_delegatable
);
863 /* Dataset property functions shared between libzfs and kernel. */
864 EXPORT_SYMBOL(zfs_prop_default_string
);
865 EXPORT_SYMBOL(zfs_prop_default_numeric
);
866 EXPORT_SYMBOL(zfs_prop_readonly
);
867 EXPORT_SYMBOL(zfs_prop_inheritable
);
868 EXPORT_SYMBOL(zfs_prop_encryption_key_param
);
869 EXPORT_SYMBOL(zfs_prop_valid_keylocation
);
870 EXPORT_SYMBOL(zfs_prop_setonce
);
871 EXPORT_SYMBOL(zfs_prop_to_name
);
872 EXPORT_SYMBOL(zfs_name_to_prop
);
873 EXPORT_SYMBOL(zfs_prop_user
);
874 EXPORT_SYMBOL(zfs_prop_userquota
);
875 EXPORT_SYMBOL(zfs_prop_index_to_string
);
876 EXPORT_SYMBOL(zfs_prop_string_to_index
);
877 EXPORT_SYMBOL(zfs_prop_valid_for_type
);