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.
27 /* Portions Copyright 2010 Robert Milkowski */
31 #include <sys/u8_textprep.h>
32 #include <sys/zfs_acl.h>
33 #include <sys/zfs_ioctl.h>
34 #include <sys/zfs_znode.h>
37 #include "zfs_deleg.h"
40 #include <sys/systm.h>
47 static zprop_desc_t zfs_prop_table
[ZFS_NUM_PROPS
];
49 /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
50 const char *zfs_userquota_prop_prefixes
[] = {
58 zfs_prop_get_table(void)
60 return (zfs_prop_table
);
66 static zprop_index_t checksum_table
[] = {
67 { "on", ZIO_CHECKSUM_ON
},
68 { "off", ZIO_CHECKSUM_OFF
},
69 { "fletcher2", ZIO_CHECKSUM_FLETCHER_2
},
70 { "fletcher4", ZIO_CHECKSUM_FLETCHER_4
},
71 { "sha256", ZIO_CHECKSUM_SHA256
},
75 static zprop_index_t dedup_table
[] = {
76 { "on", ZIO_CHECKSUM_ON
},
77 { "off", ZIO_CHECKSUM_OFF
},
78 { "verify", ZIO_CHECKSUM_ON
| ZIO_CHECKSUM_VERIFY
},
79 { "sha256", ZIO_CHECKSUM_SHA256
},
81 ZIO_CHECKSUM_SHA256
| ZIO_CHECKSUM_VERIFY
},
85 static zprop_index_t compress_table
[] = {
86 { "on", ZIO_COMPRESS_ON
},
87 { "off", ZIO_COMPRESS_OFF
},
88 { "lzjb", ZIO_COMPRESS_LZJB
},
89 { "gzip", ZIO_COMPRESS_GZIP_6
}, /* gzip default */
90 { "gzip-1", ZIO_COMPRESS_GZIP_1
},
91 { "gzip-2", ZIO_COMPRESS_GZIP_2
},
92 { "gzip-3", ZIO_COMPRESS_GZIP_3
},
93 { "gzip-4", ZIO_COMPRESS_GZIP_4
},
94 { "gzip-5", ZIO_COMPRESS_GZIP_5
},
95 { "gzip-6", ZIO_COMPRESS_GZIP_6
},
96 { "gzip-7", ZIO_COMPRESS_GZIP_7
},
97 { "gzip-8", ZIO_COMPRESS_GZIP_8
},
98 { "gzip-9", ZIO_COMPRESS_GZIP_9
},
99 { "zle", ZIO_COMPRESS_ZLE
},
100 { "lz4", ZIO_COMPRESS_LZ4
},
104 static zprop_index_t snapdir_table
[] = {
105 { "hidden", ZFS_SNAPDIR_HIDDEN
},
106 { "visible", ZFS_SNAPDIR_VISIBLE
},
110 static zprop_index_t snapdev_table
[] = {
111 { "hidden", ZFS_SNAPDEV_HIDDEN
},
112 { "visible", ZFS_SNAPDEV_VISIBLE
},
116 static zprop_index_t acltype_table
[] = {
117 { "off", ZFS_ACLTYPE_OFF
},
118 { "disabled", ZFS_ACLTYPE_OFF
},
119 { "noacl", ZFS_ACLTYPE_OFF
},
120 { "posixacl", ZFS_ACLTYPE_POSIXACL
},
124 static zprop_index_t acl_inherit_table
[] = {
125 { "discard", ZFS_ACL_DISCARD
},
126 { "noallow", ZFS_ACL_NOALLOW
},
127 { "restricted", ZFS_ACL_RESTRICTED
},
128 { "passthrough", ZFS_ACL_PASSTHROUGH
},
129 { "secure", ZFS_ACL_RESTRICTED
}, /* bkwrd compatability */
130 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X
},
134 static zprop_index_t case_table
[] = {
135 { "sensitive", ZFS_CASE_SENSITIVE
},
136 { "insensitive", ZFS_CASE_INSENSITIVE
},
137 { "mixed", ZFS_CASE_MIXED
},
141 static zprop_index_t copies_table
[] = {
149 * Use the unique flags we have to send to u8_strcmp() and/or
150 * u8_textprep() to represent the various normalization property
153 static zprop_index_t normalize_table
[] = {
155 { "formD", U8_TEXTPREP_NFD
},
156 { "formKC", U8_TEXTPREP_NFKC
},
157 { "formC", U8_TEXTPREP_NFC
},
158 { "formKD", U8_TEXTPREP_NFKD
},
162 static zprop_index_t version_table
[] = {
168 { "current", ZPL_VERSION
},
172 static zprop_index_t boolean_table
[] = {
178 static zprop_index_t logbias_table
[] = {
179 { "latency", ZFS_LOGBIAS_LATENCY
},
180 { "throughput", ZFS_LOGBIAS_THROUGHPUT
},
184 static zprop_index_t canmount_table
[] = {
185 { "off", ZFS_CANMOUNT_OFF
},
186 { "on", ZFS_CANMOUNT_ON
},
187 { "noauto", ZFS_CANMOUNT_NOAUTO
},
191 static zprop_index_t cache_table
[] = {
192 { "none", ZFS_CACHE_NONE
},
193 { "metadata", ZFS_CACHE_METADATA
},
194 { "all", ZFS_CACHE_ALL
},
198 static zprop_index_t sync_table
[] = {
199 { "standard", ZFS_SYNC_STANDARD
},
200 { "always", ZFS_SYNC_ALWAYS
},
201 { "disabled", ZFS_SYNC_DISABLED
},
205 static zprop_index_t xattr_table
[] = {
206 { "off", ZFS_XATTR_OFF
},
207 { "on", ZFS_XATTR_DIR
},
208 { "sa", ZFS_XATTR_SA
},
209 { "dir", ZFS_XATTR_DIR
},
213 static zprop_index_t redundant_metadata_table
[] = {
214 { "all", ZFS_REDUNDANT_METADATA_ALL
},
215 { "most", ZFS_REDUNDANT_METADATA_MOST
},
219 /* inherit index properties */
220 zprop_register_index(ZFS_PROP_REDUNDANT_METADATA
, "redundant_metadata",
221 ZFS_REDUNDANT_METADATA_ALL
,
222 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
223 "all | most", "REDUND_MD",
224 redundant_metadata_table
);
225 zprop_register_index(ZFS_PROP_SYNC
, "sync", ZFS_SYNC_STANDARD
,
226 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
227 "standard | always | disabled", "SYNC",
229 zprop_register_index(ZFS_PROP_CHECKSUM
, "checksum",
230 ZIO_CHECKSUM_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
|
232 "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
234 zprop_register_index(ZFS_PROP_DEDUP
, "dedup", ZIO_CHECKSUM_OFF
,
235 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
236 "on | off | verify | sha256[,verify]", "DEDUP",
238 zprop_register_index(ZFS_PROP_COMPRESSION
, "compression",
239 ZIO_COMPRESS_DEFAULT
, PROP_INHERIT
,
240 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
241 "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", "COMPRESS",
243 zprop_register_index(ZFS_PROP_SNAPDIR
, "snapdir", ZFS_SNAPDIR_HIDDEN
,
244 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
245 "hidden | visible", "SNAPDIR", snapdir_table
);
246 zprop_register_index(ZFS_PROP_SNAPDEV
, "snapdev", ZFS_SNAPDEV_HIDDEN
,
247 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
248 "hidden | visible", "SNAPDEV", snapdev_table
);
249 zprop_register_index(ZFS_PROP_ACLTYPE
, "acltype", ZFS_ACLTYPE_OFF
,
250 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
251 "noacl | posixacl", "ACLTYPE", acltype_table
);
252 zprop_register_index(ZFS_PROP_ACLINHERIT
, "aclinherit",
253 ZFS_ACL_RESTRICTED
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
254 "discard | noallow | restricted | passthrough | passthrough-x",
255 "ACLINHERIT", acl_inherit_table
);
256 zprop_register_index(ZFS_PROP_COPIES
, "copies", 1, PROP_INHERIT
,
257 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
258 "1 | 2 | 3", "COPIES", copies_table
);
259 zprop_register_index(ZFS_PROP_PRIMARYCACHE
, "primarycache",
260 ZFS_CACHE_ALL
, PROP_INHERIT
,
261 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
262 "all | none | metadata", "PRIMARYCACHE", cache_table
);
263 zprop_register_index(ZFS_PROP_SECONDARYCACHE
, "secondarycache",
264 ZFS_CACHE_ALL
, PROP_INHERIT
,
265 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
266 "all | none | metadata", "SECONDARYCACHE", cache_table
);
267 zprop_register_index(ZFS_PROP_LOGBIAS
, "logbias", ZFS_LOGBIAS_LATENCY
,
268 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
269 "latency | throughput", "LOGBIAS", logbias_table
);
270 zprop_register_index(ZFS_PROP_XATTR
, "xattr", ZFS_XATTR_DIR
,
271 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
272 "on | off | dir | sa", "XATTR", xattr_table
);
274 /* inherit index (boolean) properties */
275 zprop_register_index(ZFS_PROP_ATIME
, "atime", 1, PROP_INHERIT
,
276 ZFS_TYPE_FILESYSTEM
, "on | off", "ATIME", boolean_table
);
277 zprop_register_index(ZFS_PROP_RELATIME
, "relatime", 0, PROP_INHERIT
,
278 ZFS_TYPE_FILESYSTEM
, "on | off", "RELATIME", boolean_table
);
279 zprop_register_index(ZFS_PROP_DEVICES
, "devices", 1, PROP_INHERIT
,
280 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "DEVICES",
282 zprop_register_index(ZFS_PROP_EXEC
, "exec", 1, PROP_INHERIT
,
283 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "EXEC",
285 zprop_register_index(ZFS_PROP_SETUID
, "setuid", 1, PROP_INHERIT
,
286 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "SETUID",
288 zprop_register_index(ZFS_PROP_READONLY
, "readonly", 0, PROP_INHERIT
,
289 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "on | off", "RDONLY",
291 zprop_register_index(ZFS_PROP_ZONED
, "zoned", 0, PROP_INHERIT
,
292 ZFS_TYPE_FILESYSTEM
, "on | off", "ZONED", boolean_table
);
293 zprop_register_index(ZFS_PROP_VSCAN
, "vscan", 0, PROP_INHERIT
,
294 ZFS_TYPE_FILESYSTEM
, "on | off", "VSCAN", boolean_table
);
295 zprop_register_index(ZFS_PROP_NBMAND
, "nbmand", 0, PROP_INHERIT
,
296 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "NBMAND",
298 zprop_register_index(ZFS_PROP_OVERLAY
, "overlay", 0, PROP_INHERIT
,
299 ZFS_TYPE_FILESYSTEM
, "on | off", "OVERLAY", boolean_table
);
301 /* default index properties */
302 zprop_register_index(ZFS_PROP_VERSION
, "version", 0, PROP_DEFAULT
,
303 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
304 "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table
);
305 zprop_register_index(ZFS_PROP_CANMOUNT
, "canmount", ZFS_CANMOUNT_ON
,
306 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
, "on | off | noauto",
307 "CANMOUNT", canmount_table
);
309 /* readonly index (boolean) properties */
310 zprop_register_index(ZFS_PROP_MOUNTED
, "mounted", 0, PROP_READONLY
,
311 ZFS_TYPE_FILESYSTEM
, "yes | no", "MOUNTED", boolean_table
);
312 zprop_register_index(ZFS_PROP_DEFER_DESTROY
, "defer_destroy", 0,
313 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "yes | no", "DEFER_DESTROY",
316 /* set once index properties */
317 zprop_register_index(ZFS_PROP_NORMALIZE
, "normalization", 0,
318 PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
319 "none | formC | formD | formKC | formKD", "NORMALIZATION",
321 zprop_register_index(ZFS_PROP_CASE
, "casesensitivity",
322 ZFS_CASE_SENSITIVE
, PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
|
324 "sensitive | insensitive | mixed", "CASE", case_table
);
326 /* set once index (boolean) properties */
327 zprop_register_index(ZFS_PROP_UTF8ONLY
, "utf8only", 0, PROP_ONETIME
,
328 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
329 "on | off", "UTF8ONLY", boolean_table
);
331 /* string properties */
332 zprop_register_string(ZFS_PROP_ORIGIN
, "origin", NULL
, PROP_READONLY
,
333 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<snapshot>", "ORIGIN");
334 zprop_register_string(ZFS_PROP_CLONES
, "clones", NULL
, PROP_READONLY
,
335 ZFS_TYPE_SNAPSHOT
, "<dataset>[,...]", "CLONES");
336 zprop_register_string(ZFS_PROP_MOUNTPOINT
, "mountpoint", "/",
337 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "<path> | legacy | none",
339 zprop_register_string(ZFS_PROP_SHARENFS
, "sharenfs", "off",
340 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "on | off | share(1M) options",
342 zprop_register_string(ZFS_PROP_TYPE
, "type", NULL
, PROP_READONLY
,
343 ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
,
344 "filesystem | volume | snapshot | bookmark", "TYPE");
345 zprop_register_string(ZFS_PROP_SHARESMB
, "sharesmb", "off",
346 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
347 "on | off | sharemgr(1M) options", "SHARESMB");
348 zprop_register_string(ZFS_PROP_MLSLABEL
, "mlslabel",
349 ZFS_MLSLABEL_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_DATASET
,
350 "<sensitivity label>", "MLSLABEL");
351 zprop_register_string(ZFS_PROP_SELINUX_CONTEXT
, "context",
352 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux context>",
354 zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT
, "fscontext",
355 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux fscontext>",
357 zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT
, "defcontext",
358 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux defcontext>",
360 zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT
, "rootcontext",
361 "none", PROP_DEFAULT
, ZFS_TYPE_DATASET
, "<selinux rootcontext>",
364 /* readonly number properties */
365 zprop_register_number(ZFS_PROP_USED
, "used", 0, PROP_READONLY
,
366 ZFS_TYPE_DATASET
, "<size>", "USED");
367 zprop_register_number(ZFS_PROP_AVAILABLE
, "available", 0, PROP_READONLY
,
368 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "AVAIL");
369 zprop_register_number(ZFS_PROP_REFERENCED
, "referenced", 0,
370 PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "REFER");
371 zprop_register_number(ZFS_PROP_COMPRESSRATIO
, "compressratio", 0,
372 PROP_READONLY
, ZFS_TYPE_DATASET
,
373 "<1.00x or higher if compressed>", "RATIO");
374 zprop_register_number(ZFS_PROP_REFRATIO
, "refcompressratio", 0,
375 PROP_READONLY
, ZFS_TYPE_DATASET
,
376 "<1.00x or higher if compressed>", "REFRATIO");
377 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE
, "volblocksize",
378 ZVOL_DEFAULT_BLOCKSIZE
, PROP_ONETIME
,
379 ZFS_TYPE_VOLUME
, "512 to 128k, power of 2", "VOLBLOCK");
380 zprop_register_number(ZFS_PROP_USEDSNAP
, "usedbysnapshots", 0,
381 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
383 zprop_register_number(ZFS_PROP_USEDDS
, "usedbydataset", 0,
384 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
386 zprop_register_number(ZFS_PROP_USEDCHILD
, "usedbychildren", 0,
387 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
389 zprop_register_number(ZFS_PROP_USEDREFRESERV
, "usedbyrefreservation", 0,
391 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "USEDREFRESERV");
392 zprop_register_number(ZFS_PROP_USERREFS
, "userrefs", 0, PROP_READONLY
,
393 ZFS_TYPE_SNAPSHOT
, "<count>", "USERREFS");
394 zprop_register_number(ZFS_PROP_WRITTEN
, "written", 0, PROP_READONLY
,
395 ZFS_TYPE_DATASET
, "<size>", "WRITTEN");
396 zprop_register_number(ZFS_PROP_LOGICALUSED
, "logicalused", 0,
397 PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "LUSED");
398 zprop_register_number(ZFS_PROP_LOGICALREFERENCED
, "logicalreferenced",
399 0, PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "LREFER");
401 /* default number properties */
402 zprop_register_number(ZFS_PROP_QUOTA
, "quota", 0, PROP_DEFAULT
,
403 ZFS_TYPE_FILESYSTEM
, "<size> | none", "QUOTA");
404 zprop_register_number(ZFS_PROP_RESERVATION
, "reservation", 0,
405 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
406 "<size> | none", "RESERV");
407 zprop_register_number(ZFS_PROP_VOLSIZE
, "volsize", 0, PROP_DEFAULT
,
408 ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
, "<size>", "VOLSIZE");
409 zprop_register_number(ZFS_PROP_REFQUOTA
, "refquota", 0, PROP_DEFAULT
,
410 ZFS_TYPE_FILESYSTEM
, "<size> | none", "REFQUOTA");
411 zprop_register_number(ZFS_PROP_REFRESERVATION
, "refreservation", 0,
412 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
413 "<size> | none", "REFRESERV");
415 /* inherit number properties */
416 zprop_register_number(ZFS_PROP_RECORDSIZE
, "recordsize",
417 SPA_MAXBLOCKSIZE
, PROP_INHERIT
,
418 ZFS_TYPE_FILESYSTEM
, "512 to 128k, power of 2", "RECSIZE");
420 /* hidden properties */
421 zprop_register_hidden(ZFS_PROP_CREATETXG
, "createtxg", PROP_TYPE_NUMBER
,
422 PROP_READONLY
, ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
, "CREATETXG");
423 zprop_register_hidden(ZFS_PROP_NUMCLONES
, "numclones", PROP_TYPE_NUMBER
,
424 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "NUMCLONES");
425 zprop_register_hidden(ZFS_PROP_NAME
, "name", PROP_TYPE_STRING
,
426 PROP_READONLY
, ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
, "NAME");
427 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS
, "iscsioptions",
428 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
, "ISCSIOPTIONS");
429 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO
, "stmf_sbd_lu",
430 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
,
432 zprop_register_hidden(ZFS_PROP_GUID
, "guid", PROP_TYPE_NUMBER
,
433 PROP_READONLY
, ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
, "GUID");
434 zprop_register_hidden(ZFS_PROP_USERACCOUNTING
, "useraccounting",
435 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_DATASET
,
437 zprop_register_hidden(ZFS_PROP_UNIQUE
, "unique", PROP_TYPE_NUMBER
,
438 PROP_READONLY
, ZFS_TYPE_DATASET
, "UNIQUE");
439 zprop_register_hidden(ZFS_PROP_OBJSETID
, "objsetid", PROP_TYPE_NUMBER
,
440 PROP_READONLY
, ZFS_TYPE_DATASET
, "OBJSETID");
441 zprop_register_hidden(ZFS_PROP_INCONSISTENT
, "inconsistent",
442 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_DATASET
, "INCONSISTENT");
445 * Property to be removed once libbe is integrated
447 zprop_register_hidden(ZFS_PROP_PRIVATE
, "priv_prop",
448 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_FILESYSTEM
,
451 /* oddball properties */
452 zprop_register_impl(ZFS_PROP_CREATION
, "creation", PROP_TYPE_NUMBER
, 0,
453 NULL
, PROP_READONLY
, ZFS_TYPE_DATASET
| ZFS_TYPE_BOOKMARK
,
454 "<date>", "CREATION", B_FALSE
, B_TRUE
, NULL
);
458 zfs_prop_delegatable(zfs_prop_t prop
)
460 zprop_desc_t
*pd
= &zfs_prop_table
[prop
];
462 /* The mlslabel property is never delegatable. */
463 if (prop
== ZFS_PROP_MLSLABEL
)
466 return (pd
->pd_attr
!= PROP_READONLY
);
470 * Given a zfs dataset property name, returns the corresponding property ID.
473 zfs_name_to_prop(const char *propname
)
475 return (zprop_name_to_prop(propname
, ZFS_TYPE_DATASET
));
479 * For user property names, we allow all lowercase alphanumeric characters, plus
480 * a few useful punctuation characters.
485 return ((c
>= 'a' && c
<= 'z') ||
486 (c
>= '0' && c
<= '9') ||
487 c
== '-' || c
== '_' || c
== '.' || c
== ':');
491 * Returns true if this is a valid user-defined property (one with a ':').
494 zfs_prop_user(const char *name
)
498 boolean_t foundsep
= B_FALSE
;
500 for (i
= 0; i
< strlen(name
); i
++) {
515 * Returns true if this is a valid userspace-type property (one with a '@').
516 * Note that after the @, any character is valid (eg, another @, for SID
520 zfs_prop_userquota(const char *name
)
522 zfs_userquota_prop_t prop
;
524 for (prop
= 0; prop
< ZFS_NUM_USERQUOTA_PROPS
; prop
++) {
525 if (strncmp(name
, zfs_userquota_prop_prefixes
[prop
],
526 strlen(zfs_userquota_prop_prefixes
[prop
])) == 0) {
535 * Returns true if this is a valid written@ property.
536 * Note that after the @, any character is valid (eg, another @, for
537 * written@pool/fs@origin).
540 zfs_prop_written(const char *name
)
542 static const char *prefix
= "written@";
543 return (strncmp(name
, prefix
, strlen(prefix
)) == 0);
547 * Tables of index types, plus functions to convert between the user view
548 * (strings) and internal representation (uint64_t).
551 zfs_prop_string_to_index(zfs_prop_t prop
, const char *string
, uint64_t *index
)
553 return (zprop_string_to_index(prop
, string
, index
, ZFS_TYPE_DATASET
));
557 zfs_prop_index_to_string(zfs_prop_t prop
, uint64_t index
, const char **string
)
559 return (zprop_index_to_string(prop
, index
, string
, ZFS_TYPE_DATASET
));
563 zfs_prop_random_value(zfs_prop_t prop
, uint64_t seed
)
565 return (zprop_random_value(prop
, seed
, ZFS_TYPE_DATASET
));
569 * Returns TRUE if the property applies to any of the given dataset types.
572 zfs_prop_valid_for_type(int prop
, zfs_type_t types
, boolean_t headcheck
)
574 return (zprop_valid_for_type(prop
, types
, headcheck
));
578 zfs_prop_get_type(zfs_prop_t prop
)
580 return (zfs_prop_table
[prop
].pd_proptype
);
584 * Returns TRUE if the property is readonly.
587 zfs_prop_readonly(zfs_prop_t prop
)
589 return (zfs_prop_table
[prop
].pd_attr
== PROP_READONLY
||
590 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
594 * Returns TRUE if the property is only allowed to be set once.
597 zfs_prop_setonce(zfs_prop_t prop
)
599 return (zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
603 zfs_prop_default_string(zfs_prop_t prop
)
605 return (zfs_prop_table
[prop
].pd_strdefault
);
609 zfs_prop_default_numeric(zfs_prop_t prop
)
611 return (zfs_prop_table
[prop
].pd_numdefault
);
615 * Given a dataset property ID, returns the corresponding name.
616 * Assuming the zfs dataset property ID is valid.
619 zfs_prop_to_name(zfs_prop_t prop
)
621 return (zfs_prop_table
[prop
].pd_name
);
625 * Returns TRUE if the property is inheritable.
628 zfs_prop_inheritable(zfs_prop_t prop
)
630 return (zfs_prop_table
[prop
].pd_attr
== PROP_INHERIT
||
631 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
637 * Returns a string describing the set of acceptable values for the given
638 * zfs property, or NULL if it cannot be set.
641 zfs_prop_values(zfs_prop_t prop
)
643 return (zfs_prop_table
[prop
].pd_values
);
647 * Returns TRUE if this property is a string type. Note that index types
648 * (compression, checksum) are treated as strings in userland, even though they
649 * are stored numerically on disk.
652 zfs_prop_is_string(zfs_prop_t prop
)
654 return (zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_STRING
||
655 zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_INDEX
);
659 * Returns the column header for the given property. Used only in
660 * 'zfs list -o', but centralized here with the other property information.
663 zfs_prop_column_name(zfs_prop_t prop
)
665 return (zfs_prop_table
[prop
].pd_colname
);
669 * Returns whether the given property should be displayed right-justified for
673 zfs_prop_align_right(zfs_prop_t prop
)
675 return (zfs_prop_table
[prop
].pd_rightalign
);
680 #if defined(_KERNEL) && defined(HAVE_SPL)
692 module_init(zcommon_init
);
693 module_exit(zcommon_fini
);
695 MODULE_DESCRIPTION("Generic ZFS support");
696 MODULE_AUTHOR(ZFS_META_AUTHOR
);
697 MODULE_LICENSE(ZFS_META_LICENSE
);
698 MODULE_VERSION(ZFS_META_VERSION
"-" ZFS_META_RELEASE
);
700 /* zfs dataset property functions */
701 EXPORT_SYMBOL(zfs_userquota_prop_prefixes
);
702 EXPORT_SYMBOL(zfs_prop_init
);
703 EXPORT_SYMBOL(zfs_prop_get_type
);
704 EXPORT_SYMBOL(zfs_prop_get_table
);
705 EXPORT_SYMBOL(zfs_prop_delegatable
);
707 /* Dataset property functions shared between libzfs and kernel. */
708 EXPORT_SYMBOL(zfs_prop_default_string
);
709 EXPORT_SYMBOL(zfs_prop_default_numeric
);
710 EXPORT_SYMBOL(zfs_prop_readonly
);
711 EXPORT_SYMBOL(zfs_prop_inheritable
);
712 EXPORT_SYMBOL(zfs_prop_setonce
);
713 EXPORT_SYMBOL(zfs_prop_to_name
);
714 EXPORT_SYMBOL(zfs_name_to_prop
);
715 EXPORT_SYMBOL(zfs_prop_user
);
716 EXPORT_SYMBOL(zfs_prop_userquota
);
717 EXPORT_SYMBOL(zfs_prop_index_to_string
);
718 EXPORT_SYMBOL(zfs_prop_string_to_index
);
719 EXPORT_SYMBOL(zfs_prop_valid_for_type
);