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 by Delphix. All rights reserved.
26 /* Portions Copyright 2010 Robert Milkowski */
30 #include <sys/u8_textprep.h>
31 #include <sys/zfs_acl.h>
32 #include <sys/zfs_ioctl.h>
33 #include <sys/zfs_znode.h>
36 #include "zfs_deleg.h"
39 #include <sys/systm.h>
46 static zprop_desc_t zfs_prop_table
[ZFS_NUM_PROPS
];
48 /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
49 const char *zfs_userquota_prop_prefixes
[] = {
57 zfs_prop_get_table(void)
59 return (zfs_prop_table
);
65 static zprop_index_t checksum_table
[] = {
66 { "on", ZIO_CHECKSUM_ON
},
67 { "off", ZIO_CHECKSUM_OFF
},
68 { "fletcher2", ZIO_CHECKSUM_FLETCHER_2
},
69 { "fletcher4", ZIO_CHECKSUM_FLETCHER_4
},
70 { "sha256", ZIO_CHECKSUM_SHA256
},
74 static zprop_index_t dedup_table
[] = {
75 { "on", ZIO_CHECKSUM_ON
},
76 { "off", ZIO_CHECKSUM_OFF
},
77 { "verify", ZIO_CHECKSUM_ON
| ZIO_CHECKSUM_VERIFY
},
78 { "sha256", ZIO_CHECKSUM_SHA256
},
80 ZIO_CHECKSUM_SHA256
| ZIO_CHECKSUM_VERIFY
},
84 static zprop_index_t compress_table
[] = {
85 { "on", ZIO_COMPRESS_ON
},
86 { "off", ZIO_COMPRESS_OFF
},
87 { "lzjb", ZIO_COMPRESS_LZJB
},
88 { "gzip", ZIO_COMPRESS_GZIP_6
}, /* gzip default */
89 { "gzip-1", ZIO_COMPRESS_GZIP_1
},
90 { "gzip-2", ZIO_COMPRESS_GZIP_2
},
91 { "gzip-3", ZIO_COMPRESS_GZIP_3
},
92 { "gzip-4", ZIO_COMPRESS_GZIP_4
},
93 { "gzip-5", ZIO_COMPRESS_GZIP_5
},
94 { "gzip-6", ZIO_COMPRESS_GZIP_6
},
95 { "gzip-7", ZIO_COMPRESS_GZIP_7
},
96 { "gzip-8", ZIO_COMPRESS_GZIP_8
},
97 { "gzip-9", ZIO_COMPRESS_GZIP_9
},
98 { "zle", ZIO_COMPRESS_ZLE
},
99 { "lz4", ZIO_COMPRESS_LZ4
},
103 static zprop_index_t snapdir_table
[] = {
104 { "hidden", ZFS_SNAPDIR_HIDDEN
},
105 { "visible", ZFS_SNAPDIR_VISIBLE
},
109 static zprop_index_t snapdev_table
[] = {
110 { "hidden", ZFS_SNAPDEV_HIDDEN
},
111 { "visible", ZFS_SNAPDEV_VISIBLE
},
115 static zprop_index_t acl_inherit_table
[] = {
116 { "discard", ZFS_ACL_DISCARD
},
117 { "noallow", ZFS_ACL_NOALLOW
},
118 { "restricted", ZFS_ACL_RESTRICTED
},
119 { "passthrough", ZFS_ACL_PASSTHROUGH
},
120 { "secure", ZFS_ACL_RESTRICTED
}, /* bkwrd compatability */
121 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X
},
125 static zprop_index_t case_table
[] = {
126 { "sensitive", ZFS_CASE_SENSITIVE
},
127 { "insensitive", ZFS_CASE_INSENSITIVE
},
128 { "mixed", ZFS_CASE_MIXED
},
132 static zprop_index_t copies_table
[] = {
140 * Use the unique flags we have to send to u8_strcmp() and/or
141 * u8_textprep() to represent the various normalization property
144 static zprop_index_t normalize_table
[] = {
146 { "formD", U8_TEXTPREP_NFD
},
147 { "formKC", U8_TEXTPREP_NFKC
},
148 { "formC", U8_TEXTPREP_NFC
},
149 { "formKD", U8_TEXTPREP_NFKD
},
153 static zprop_index_t version_table
[] = {
159 { "current", ZPL_VERSION
},
163 static zprop_index_t boolean_table
[] = {
169 static zprop_index_t logbias_table
[] = {
170 { "latency", ZFS_LOGBIAS_LATENCY
},
171 { "throughput", ZFS_LOGBIAS_THROUGHPUT
},
175 static zprop_index_t canmount_table
[] = {
176 { "off", ZFS_CANMOUNT_OFF
},
177 { "on", ZFS_CANMOUNT_ON
},
178 { "noauto", ZFS_CANMOUNT_NOAUTO
},
182 static zprop_index_t cache_table
[] = {
183 { "none", ZFS_CACHE_NONE
},
184 { "metadata", ZFS_CACHE_METADATA
},
185 { "all", ZFS_CACHE_ALL
},
189 static zprop_index_t sync_table
[] = {
190 { "standard", ZFS_SYNC_STANDARD
},
191 { "always", ZFS_SYNC_ALWAYS
},
192 { "disabled", ZFS_SYNC_DISABLED
},
196 static zprop_index_t xattr_table
[] = {
197 { "off", ZFS_XATTR_OFF
},
198 { "on", ZFS_XATTR_DIR
},
199 { "sa", ZFS_XATTR_SA
},
200 { "dir", ZFS_XATTR_DIR
},
204 /* inherit index properties */
205 zprop_register_index(ZFS_PROP_SYNC
, "sync", ZFS_SYNC_STANDARD
,
206 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
207 "standard | always | disabled", "SYNC",
209 zprop_register_index(ZFS_PROP_CHECKSUM
, "checksum",
210 ZIO_CHECKSUM_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
|
212 "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
214 zprop_register_index(ZFS_PROP_DEDUP
, "dedup", ZIO_CHECKSUM_OFF
,
215 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
216 "on | off | verify | sha256[,verify]", "DEDUP",
218 zprop_register_index(ZFS_PROP_COMPRESSION
, "compression",
219 ZIO_COMPRESS_DEFAULT
, PROP_INHERIT
,
220 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
221 "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", "COMPRESS",
223 zprop_register_index(ZFS_PROP_SNAPDIR
, "snapdir", ZFS_SNAPDIR_HIDDEN
,
224 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
225 "hidden | visible", "SNAPDIR", snapdir_table
);
226 zprop_register_index(ZFS_PROP_SNAPDEV
, "snapdev", ZFS_SNAPDEV_HIDDEN
,
227 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
228 "hidden | visible", "SNAPDEV", snapdev_table
);
229 zprop_register_index(ZFS_PROP_ACLINHERIT
, "aclinherit",
230 ZFS_ACL_RESTRICTED
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
231 "discard | noallow | restricted | passthrough | passthrough-x",
232 "ACLINHERIT", acl_inherit_table
);
233 zprop_register_index(ZFS_PROP_COPIES
, "copies", 1, PROP_INHERIT
,
234 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
235 "1 | 2 | 3", "COPIES", copies_table
);
236 zprop_register_index(ZFS_PROP_PRIMARYCACHE
, "primarycache",
237 ZFS_CACHE_ALL
, PROP_INHERIT
,
238 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
239 "all | none | metadata", "PRIMARYCACHE", cache_table
);
240 zprop_register_index(ZFS_PROP_SECONDARYCACHE
, "secondarycache",
241 ZFS_CACHE_ALL
, PROP_INHERIT
,
242 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
243 "all | none | metadata", "SECONDARYCACHE", cache_table
);
244 zprop_register_index(ZFS_PROP_LOGBIAS
, "logbias", ZFS_LOGBIAS_LATENCY
,
245 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
246 "latency | throughput", "LOGBIAS", logbias_table
);
247 zprop_register_index(ZFS_PROP_XATTR
, "xattr", ZFS_XATTR_DIR
,
248 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
249 "on | off | dir | sa", "XATTR", xattr_table
);
251 /* inherit index (boolean) properties */
252 zprop_register_index(ZFS_PROP_ATIME
, "atime", 1, PROP_INHERIT
,
253 ZFS_TYPE_FILESYSTEM
, "on | off", "ATIME", boolean_table
);
254 zprop_register_index(ZFS_PROP_DEVICES
, "devices", 1, PROP_INHERIT
,
255 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "DEVICES",
257 zprop_register_index(ZFS_PROP_EXEC
, "exec", 1, PROP_INHERIT
,
258 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "EXEC",
260 zprop_register_index(ZFS_PROP_SETUID
, "setuid", 1, PROP_INHERIT
,
261 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "SETUID",
263 zprop_register_index(ZFS_PROP_READONLY
, "readonly", 0, PROP_INHERIT
,
264 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "on | off", "RDONLY",
266 zprop_register_index(ZFS_PROP_ZONED
, "zoned", 0, PROP_INHERIT
,
267 ZFS_TYPE_FILESYSTEM
, "on | off", "ZONED", boolean_table
);
268 zprop_register_index(ZFS_PROP_VSCAN
, "vscan", 0, PROP_INHERIT
,
269 ZFS_TYPE_FILESYSTEM
, "on | off", "VSCAN", boolean_table
);
270 zprop_register_index(ZFS_PROP_NBMAND
, "nbmand", 0, PROP_INHERIT
,
271 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "NBMAND",
274 /* default index properties */
275 zprop_register_index(ZFS_PROP_VERSION
, "version", 0, PROP_DEFAULT
,
276 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
277 "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table
);
278 zprop_register_index(ZFS_PROP_CANMOUNT
, "canmount", ZFS_CANMOUNT_ON
,
279 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
, "on | off | noauto",
280 "CANMOUNT", canmount_table
);
282 /* readonly index (boolean) properties */
283 zprop_register_index(ZFS_PROP_MOUNTED
, "mounted", 0, PROP_READONLY
,
284 ZFS_TYPE_FILESYSTEM
, "yes | no", "MOUNTED", boolean_table
);
285 zprop_register_index(ZFS_PROP_DEFER_DESTROY
, "defer_destroy", 0,
286 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "yes | no", "DEFER_DESTROY",
289 /* set once index properties */
290 zprop_register_index(ZFS_PROP_NORMALIZE
, "normalization", 0,
291 PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
292 "none | formC | formD | formKC | formKD", "NORMALIZATION",
294 zprop_register_index(ZFS_PROP_CASE
, "casesensitivity",
295 ZFS_CASE_SENSITIVE
, PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
|
297 "sensitive | insensitive | mixed", "CASE", case_table
);
299 /* set once index (boolean) properties */
300 zprop_register_index(ZFS_PROP_UTF8ONLY
, "utf8only", 0, PROP_ONETIME
,
301 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
302 "on | off", "UTF8ONLY", boolean_table
);
304 /* string properties */
305 zprop_register_string(ZFS_PROP_ORIGIN
, "origin", NULL
, PROP_READONLY
,
306 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<snapshot>", "ORIGIN");
307 zprop_register_string(ZFS_PROP_CLONES
, "clones", NULL
, PROP_READONLY
,
308 ZFS_TYPE_SNAPSHOT
, "<dataset>[,...]", "CLONES");
309 zprop_register_string(ZFS_PROP_MOUNTPOINT
, "mountpoint", "/",
310 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "<path> | legacy | none",
312 zprop_register_string(ZFS_PROP_SHARENFS
, "sharenfs", "off",
313 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "on | off | share(1M) options",
315 zprop_register_string(ZFS_PROP_TYPE
, "type", NULL
, PROP_READONLY
,
316 ZFS_TYPE_DATASET
, "filesystem | volume | snapshot", "TYPE");
317 zprop_register_string(ZFS_PROP_SHARESMB
, "sharesmb", "off",
318 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
319 "on | off | sharemgr(1M) options", "SHARESMB");
320 zprop_register_string(ZFS_PROP_MLSLABEL
, "mlslabel",
321 ZFS_MLSLABEL_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_DATASET
,
322 "<sensitivity label>", "MLSLABEL");
324 /* readonly number properties */
325 zprop_register_number(ZFS_PROP_USED
, "used", 0, PROP_READONLY
,
326 ZFS_TYPE_DATASET
, "<size>", "USED");
327 zprop_register_number(ZFS_PROP_AVAILABLE
, "available", 0, PROP_READONLY
,
328 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "AVAIL");
329 zprop_register_number(ZFS_PROP_REFERENCED
, "referenced", 0,
330 PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "REFER");
331 zprop_register_number(ZFS_PROP_COMPRESSRATIO
, "compressratio", 0,
332 PROP_READONLY
, ZFS_TYPE_DATASET
,
333 "<1.00x or higher if compressed>", "RATIO");
334 zprop_register_number(ZFS_PROP_REFRATIO
, "refcompressratio", 0,
335 PROP_READONLY
, ZFS_TYPE_DATASET
,
336 "<1.00x or higher if compressed>", "REFRATIO");
337 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE
, "volblocksize",
338 ZVOL_DEFAULT_BLOCKSIZE
, PROP_ONETIME
,
339 ZFS_TYPE_VOLUME
, "512 to 128k, power of 2", "VOLBLOCK");
340 zprop_register_number(ZFS_PROP_USEDSNAP
, "usedbysnapshots", 0,
341 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
343 zprop_register_number(ZFS_PROP_USEDDS
, "usedbydataset", 0,
344 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
346 zprop_register_number(ZFS_PROP_USEDCHILD
, "usedbychildren", 0,
347 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
349 zprop_register_number(ZFS_PROP_USEDREFRESERV
, "usedbyrefreservation", 0,
351 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "USEDREFRESERV");
352 zprop_register_number(ZFS_PROP_USERREFS
, "userrefs", 0, PROP_READONLY
,
353 ZFS_TYPE_SNAPSHOT
, "<count>", "USERREFS");
354 zprop_register_number(ZFS_PROP_WRITTEN
, "written", 0, PROP_READONLY
,
355 ZFS_TYPE_DATASET
, "<size>", "WRITTEN");
357 /* default number properties */
358 zprop_register_number(ZFS_PROP_QUOTA
, "quota", 0, PROP_DEFAULT
,
359 ZFS_TYPE_FILESYSTEM
, "<size> | none", "QUOTA");
360 zprop_register_number(ZFS_PROP_RESERVATION
, "reservation", 0,
361 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
362 "<size> | none", "RESERV");
363 zprop_register_number(ZFS_PROP_VOLSIZE
, "volsize", 0, PROP_DEFAULT
,
364 ZFS_TYPE_VOLUME
, "<size>", "VOLSIZE");
365 zprop_register_number(ZFS_PROP_REFQUOTA
, "refquota", 0, PROP_DEFAULT
,
366 ZFS_TYPE_FILESYSTEM
, "<size> | none", "REFQUOTA");
367 zprop_register_number(ZFS_PROP_REFRESERVATION
, "refreservation", 0,
368 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
369 "<size> | none", "REFRESERV");
371 /* inherit number properties */
372 zprop_register_number(ZFS_PROP_RECORDSIZE
, "recordsize",
373 SPA_MAXBLOCKSIZE
, PROP_INHERIT
,
374 ZFS_TYPE_FILESYSTEM
, "512 to 128k, power of 2", "RECSIZE");
376 /* hidden properties */
377 zprop_register_hidden(ZFS_PROP_CREATETXG
, "createtxg", PROP_TYPE_NUMBER
,
378 PROP_READONLY
, ZFS_TYPE_DATASET
, "CREATETXG");
379 zprop_register_hidden(ZFS_PROP_NUMCLONES
, "numclones", PROP_TYPE_NUMBER
,
380 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "NUMCLONES");
381 zprop_register_hidden(ZFS_PROP_NAME
, "name", PROP_TYPE_STRING
,
382 PROP_READONLY
, ZFS_TYPE_DATASET
, "NAME");
383 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS
, "iscsioptions",
384 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
, "ISCSIOPTIONS");
385 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO
, "stmf_sbd_lu",
386 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
,
388 zprop_register_hidden(ZFS_PROP_GUID
, "guid", PROP_TYPE_NUMBER
,
389 PROP_READONLY
, ZFS_TYPE_DATASET
, "GUID");
390 zprop_register_hidden(ZFS_PROP_USERACCOUNTING
, "useraccounting",
391 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_DATASET
,
393 zprop_register_hidden(ZFS_PROP_UNIQUE
, "unique", PROP_TYPE_NUMBER
,
394 PROP_READONLY
, ZFS_TYPE_DATASET
, "UNIQUE");
395 zprop_register_hidden(ZFS_PROP_OBJSETID
, "objsetid", PROP_TYPE_NUMBER
,
396 PROP_READONLY
, ZFS_TYPE_DATASET
, "OBJSETID");
399 * Property to be removed once libbe is integrated
401 zprop_register_hidden(ZFS_PROP_PRIVATE
, "priv_prop",
402 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_FILESYSTEM
,
405 /* oddball properties */
406 zprop_register_impl(ZFS_PROP_CREATION
, "creation", PROP_TYPE_NUMBER
, 0,
407 NULL
, PROP_READONLY
, ZFS_TYPE_DATASET
,
408 "<date>", "CREATION", B_FALSE
, B_TRUE
, NULL
);
412 zfs_prop_delegatable(zfs_prop_t prop
)
414 zprop_desc_t
*pd
= &zfs_prop_table
[prop
];
416 /* The mlslabel property is never delegatable. */
417 if (prop
== ZFS_PROP_MLSLABEL
)
420 return (pd
->pd_attr
!= PROP_READONLY
);
424 * Given a zfs dataset property name, returns the corresponding property ID.
427 zfs_name_to_prop(const char *propname
)
429 return (zprop_name_to_prop(propname
, ZFS_TYPE_DATASET
));
433 * For user property names, we allow all lowercase alphanumeric characters, plus
434 * a few useful punctuation characters.
439 return ((c
>= 'a' && c
<= 'z') ||
440 (c
>= '0' && c
<= '9') ||
441 c
== '-' || c
== '_' || c
== '.' || c
== ':');
445 * Returns true if this is a valid user-defined property (one with a ':').
448 zfs_prop_user(const char *name
)
452 boolean_t foundsep
= B_FALSE
;
454 for (i
= 0; i
< strlen(name
); i
++) {
469 * Returns true if this is a valid userspace-type property (one with a '@').
470 * Note that after the @, any character is valid (eg, another @, for SID
474 zfs_prop_userquota(const char *name
)
476 zfs_userquota_prop_t prop
;
478 for (prop
= 0; prop
< ZFS_NUM_USERQUOTA_PROPS
; prop
++) {
479 if (strncmp(name
, zfs_userquota_prop_prefixes
[prop
],
480 strlen(zfs_userquota_prop_prefixes
[prop
])) == 0) {
489 * Returns true if this is a valid written@ property.
490 * Note that after the @, any character is valid (eg, another @, for
491 * written@pool/fs@origin).
494 zfs_prop_written(const char *name
)
496 static const char *prefix
= "written@";
497 return (strncmp(name
, prefix
, strlen(prefix
)) == 0);
501 * Tables of index types, plus functions to convert between the user view
502 * (strings) and internal representation (uint64_t).
505 zfs_prop_string_to_index(zfs_prop_t prop
, const char *string
, uint64_t *index
)
507 return (zprop_string_to_index(prop
, string
, index
, ZFS_TYPE_DATASET
));
511 zfs_prop_index_to_string(zfs_prop_t prop
, uint64_t index
, const char **string
)
513 return (zprop_index_to_string(prop
, index
, string
, ZFS_TYPE_DATASET
));
517 zfs_prop_random_value(zfs_prop_t prop
, uint64_t seed
)
519 return (zprop_random_value(prop
, seed
, ZFS_TYPE_DATASET
));
523 * Returns TRUE if the property applies to any of the given dataset types.
526 zfs_prop_valid_for_type(int prop
, zfs_type_t types
)
528 return (zprop_valid_for_type(prop
, types
));
532 zfs_prop_get_type(zfs_prop_t prop
)
534 return (zfs_prop_table
[prop
].pd_proptype
);
538 * Returns TRUE if the property is readonly.
541 zfs_prop_readonly(zfs_prop_t prop
)
543 return (zfs_prop_table
[prop
].pd_attr
== PROP_READONLY
||
544 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
548 * Returns TRUE if the property is only allowed to be set once.
551 zfs_prop_setonce(zfs_prop_t prop
)
553 return (zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
557 zfs_prop_default_string(zfs_prop_t prop
)
559 return (zfs_prop_table
[prop
].pd_strdefault
);
563 zfs_prop_default_numeric(zfs_prop_t prop
)
565 return (zfs_prop_table
[prop
].pd_numdefault
);
569 * Given a dataset property ID, returns the corresponding name.
570 * Assuming the zfs dataset property ID is valid.
573 zfs_prop_to_name(zfs_prop_t prop
)
575 return (zfs_prop_table
[prop
].pd_name
);
579 * Returns TRUE if the property is inheritable.
582 zfs_prop_inheritable(zfs_prop_t prop
)
584 return (zfs_prop_table
[prop
].pd_attr
== PROP_INHERIT
||
585 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
591 * Returns a string describing the set of acceptable values for the given
592 * zfs property, or NULL if it cannot be set.
595 zfs_prop_values(zfs_prop_t prop
)
597 return (zfs_prop_table
[prop
].pd_values
);
601 * Returns TRUE if this property is a string type. Note that index types
602 * (compression, checksum) are treated as strings in userland, even though they
603 * are stored numerically on disk.
606 zfs_prop_is_string(zfs_prop_t prop
)
608 return (zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_STRING
||
609 zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_INDEX
);
613 * Returns the column header for the given property. Used only in
614 * 'zfs list -o', but centralized here with the other property information.
617 zfs_prop_column_name(zfs_prop_t prop
)
619 return (zfs_prop_table
[prop
].pd_colname
);
623 * Returns whether the given property should be displayed right-justified for
627 zfs_prop_align_right(zfs_prop_t prop
)
629 return (zfs_prop_table
[prop
].pd_rightalign
);
634 #if defined(_KERNEL) && defined(HAVE_SPL)
636 static int zcommon_init(void) { return 0; }
637 static int zcommon_fini(void) { return 0; }
639 spl_module_init(zcommon_init
);
640 spl_module_exit(zcommon_fini
);
642 MODULE_DESCRIPTION("Generic ZFS support");
643 MODULE_AUTHOR(ZFS_META_AUTHOR
);
644 MODULE_LICENSE(ZFS_META_LICENSE
);
646 /* zfs dataset property functions */
647 EXPORT_SYMBOL(zfs_userquota_prop_prefixes
);
648 EXPORT_SYMBOL(zfs_prop_init
);
649 EXPORT_SYMBOL(zfs_prop_get_type
);
650 EXPORT_SYMBOL(zfs_prop_get_table
);
651 EXPORT_SYMBOL(zfs_prop_delegatable
);
653 /* Dataset property functions shared between libzfs and kernel. */
654 EXPORT_SYMBOL(zfs_prop_default_string
);
655 EXPORT_SYMBOL(zfs_prop_default_numeric
);
656 EXPORT_SYMBOL(zfs_prop_readonly
);
657 EXPORT_SYMBOL(zfs_prop_inheritable
);
658 EXPORT_SYMBOL(zfs_prop_setonce
);
659 EXPORT_SYMBOL(zfs_prop_to_name
);
660 EXPORT_SYMBOL(zfs_name_to_prop
);
661 EXPORT_SYMBOL(zfs_prop_user
);
662 EXPORT_SYMBOL(zfs_prop_userquota
);
663 EXPORT_SYMBOL(zfs_prop_index_to_string
);
664 EXPORT_SYMBOL(zfs_prop_string_to_index
);
665 EXPORT_SYMBOL(zfs_prop_valid_for_type
);