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
},
102 static zprop_index_t snapdir_table
[] = {
103 { "hidden", ZFS_SNAPDIR_HIDDEN
},
104 { "visible", ZFS_SNAPDIR_VISIBLE
},
108 static zprop_index_t acl_inherit_table
[] = {
109 { "discard", ZFS_ACL_DISCARD
},
110 { "noallow", ZFS_ACL_NOALLOW
},
111 { "restricted", ZFS_ACL_RESTRICTED
},
112 { "passthrough", ZFS_ACL_PASSTHROUGH
},
113 { "secure", ZFS_ACL_RESTRICTED
}, /* bkwrd compatability */
114 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X
},
118 static zprop_index_t case_table
[] = {
119 { "sensitive", ZFS_CASE_SENSITIVE
},
120 { "insensitive", ZFS_CASE_INSENSITIVE
},
121 { "mixed", ZFS_CASE_MIXED
},
125 static zprop_index_t copies_table
[] = {
133 * Use the unique flags we have to send to u8_strcmp() and/or
134 * u8_textprep() to represent the various normalization property
137 static zprop_index_t normalize_table
[] = {
139 { "formD", U8_TEXTPREP_NFD
},
140 { "formKC", U8_TEXTPREP_NFKC
},
141 { "formC", U8_TEXTPREP_NFC
},
142 { "formKD", U8_TEXTPREP_NFKD
},
146 static zprop_index_t version_table
[] = {
152 { "current", ZPL_VERSION
},
156 static zprop_index_t boolean_table
[] = {
162 static zprop_index_t logbias_table
[] = {
163 { "latency", ZFS_LOGBIAS_LATENCY
},
164 { "throughput", ZFS_LOGBIAS_THROUGHPUT
},
168 static zprop_index_t canmount_table
[] = {
169 { "off", ZFS_CANMOUNT_OFF
},
170 { "on", ZFS_CANMOUNT_ON
},
171 { "noauto", ZFS_CANMOUNT_NOAUTO
},
175 static zprop_index_t cache_table
[] = {
176 { "none", ZFS_CACHE_NONE
},
177 { "metadata", ZFS_CACHE_METADATA
},
178 { "all", ZFS_CACHE_ALL
},
182 static zprop_index_t sync_table
[] = {
183 { "standard", ZFS_SYNC_STANDARD
},
184 { "always", ZFS_SYNC_ALWAYS
},
185 { "disabled", ZFS_SYNC_DISABLED
},
189 static zprop_index_t xattr_table
[] = {
190 { "off", ZFS_XATTR_OFF
},
191 { "on", ZFS_XATTR_DIR
},
192 { "sa", ZFS_XATTR_SA
},
193 { "dir", ZFS_XATTR_DIR
},
197 /* inherit index properties */
198 zprop_register_index(ZFS_PROP_SYNC
, "sync", ZFS_SYNC_STANDARD
,
199 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
200 "standard | always | disabled", "SYNC",
202 zprop_register_index(ZFS_PROP_CHECKSUM
, "checksum",
203 ZIO_CHECKSUM_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
|
205 "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
207 zprop_register_index(ZFS_PROP_DEDUP
, "dedup", ZIO_CHECKSUM_OFF
,
208 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
209 "on | off | verify | sha256[,verify]", "DEDUP",
211 zprop_register_index(ZFS_PROP_COMPRESSION
, "compression",
212 ZIO_COMPRESS_DEFAULT
, PROP_INHERIT
,
213 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
214 "on | off | lzjb | gzip | gzip-[1-9] | zle", "COMPRESS",
216 zprop_register_index(ZFS_PROP_SNAPDIR
, "snapdir", ZFS_SNAPDIR_HIDDEN
,
217 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
218 "hidden | visible", "SNAPDIR", snapdir_table
);
219 zprop_register_index(ZFS_PROP_ACLINHERIT
, "aclinherit",
220 ZFS_ACL_RESTRICTED
, PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
221 "discard | noallow | restricted | passthrough | passthrough-x",
222 "ACLINHERIT", acl_inherit_table
);
223 zprop_register_index(ZFS_PROP_COPIES
, "copies", 1, PROP_INHERIT
,
224 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
225 "1 | 2 | 3", "COPIES", copies_table
);
226 zprop_register_index(ZFS_PROP_PRIMARYCACHE
, "primarycache",
227 ZFS_CACHE_ALL
, PROP_INHERIT
,
228 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
229 "all | none | metadata", "PRIMARYCACHE", cache_table
);
230 zprop_register_index(ZFS_PROP_SECONDARYCACHE
, "secondarycache",
231 ZFS_CACHE_ALL
, PROP_INHERIT
,
232 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
| ZFS_TYPE_VOLUME
,
233 "all | none | metadata", "SECONDARYCACHE", cache_table
);
234 zprop_register_index(ZFS_PROP_LOGBIAS
, "logbias", ZFS_LOGBIAS_LATENCY
,
235 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
236 "latency | throughput", "LOGBIAS", logbias_table
);
237 zprop_register_index(ZFS_PROP_XATTR
, "xattr", ZFS_XATTR_DIR
,
238 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
239 "on | off | dir | sa", "XATTR", xattr_table
);
241 /* inherit index (boolean) properties */
242 zprop_register_index(ZFS_PROP_ATIME
, "atime", 1, PROP_INHERIT
,
243 ZFS_TYPE_FILESYSTEM
, "on | off", "ATIME", boolean_table
);
244 zprop_register_index(ZFS_PROP_DEVICES
, "devices", 1, PROP_INHERIT
,
245 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "DEVICES",
247 zprop_register_index(ZFS_PROP_EXEC
, "exec", 1, PROP_INHERIT
,
248 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "EXEC",
250 zprop_register_index(ZFS_PROP_SETUID
, "setuid", 1, PROP_INHERIT
,
251 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "SETUID",
253 zprop_register_index(ZFS_PROP_READONLY
, "readonly", 0, PROP_INHERIT
,
254 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "on | off", "RDONLY",
256 zprop_register_index(ZFS_PROP_ZONED
, "zoned", 0, PROP_INHERIT
,
257 ZFS_TYPE_FILESYSTEM
, "on | off", "ZONED", boolean_table
);
258 zprop_register_index(ZFS_PROP_VSCAN
, "vscan", 0, PROP_INHERIT
,
259 ZFS_TYPE_FILESYSTEM
, "on | off", "VSCAN", boolean_table
);
260 zprop_register_index(ZFS_PROP_NBMAND
, "nbmand", 0, PROP_INHERIT
,
261 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
, "on | off", "NBMAND",
264 /* default index properties */
265 zprop_register_index(ZFS_PROP_VERSION
, "version", 0, PROP_DEFAULT
,
266 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
267 "1 | 2 | 3 | 4 | current", "VERSION", version_table
);
268 zprop_register_index(ZFS_PROP_CANMOUNT
, "canmount", ZFS_CANMOUNT_ON
,
269 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
, "on | off | noauto",
270 "CANMOUNT", canmount_table
);
272 /* readonly index (boolean) properties */
273 zprop_register_index(ZFS_PROP_MOUNTED
, "mounted", 0, PROP_READONLY
,
274 ZFS_TYPE_FILESYSTEM
, "yes | no", "MOUNTED", boolean_table
);
275 zprop_register_index(ZFS_PROP_DEFER_DESTROY
, "defer_destroy", 0,
276 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "yes | no", "DEFER_DESTROY",
279 /* set once index properties */
280 zprop_register_index(ZFS_PROP_NORMALIZE
, "normalization", 0,
281 PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
282 "none | formC | formD | formKC | formKD", "NORMALIZATION",
284 zprop_register_index(ZFS_PROP_CASE
, "casesensitivity",
285 ZFS_CASE_SENSITIVE
, PROP_ONETIME
, ZFS_TYPE_FILESYSTEM
|
287 "sensitive | insensitive | mixed", "CASE", case_table
);
289 /* set once index (boolean) properties */
290 zprop_register_index(ZFS_PROP_UTF8ONLY
, "utf8only", 0, PROP_ONETIME
,
291 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_SNAPSHOT
,
292 "on | off", "UTF8ONLY", boolean_table
);
294 /* string properties */
295 zprop_register_string(ZFS_PROP_ORIGIN
, "origin", NULL
, PROP_READONLY
,
296 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<snapshot>", "ORIGIN");
297 zprop_register_string(ZFS_PROP_MOUNTPOINT
, "mountpoint", "/",
298 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "<path> | legacy | none",
300 zprop_register_string(ZFS_PROP_SHARENFS
, "sharenfs", "off",
301 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
, "on | off | share(1M) options",
303 zprop_register_string(ZFS_PROP_TYPE
, "type", NULL
, PROP_READONLY
,
304 ZFS_TYPE_DATASET
, "filesystem | volume | snapshot", "TYPE");
305 zprop_register_string(ZFS_PROP_SHARESMB
, "sharesmb", "off",
306 PROP_INHERIT
, ZFS_TYPE_FILESYSTEM
,
307 "on | off | sharemgr(1M) options", "SHARESMB");
308 zprop_register_string(ZFS_PROP_MLSLABEL
, "mlslabel",
309 ZFS_MLSLABEL_DEFAULT
, PROP_INHERIT
, ZFS_TYPE_DATASET
,
310 "<sensitivity label>", "MLSLABEL");
312 /* readonly number properties */
313 zprop_register_number(ZFS_PROP_USED
, "used", 0, PROP_READONLY
,
314 ZFS_TYPE_DATASET
, "<size>", "USED");
315 zprop_register_number(ZFS_PROP_AVAILABLE
, "available", 0, PROP_READONLY
,
316 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "AVAIL");
317 zprop_register_number(ZFS_PROP_REFERENCED
, "referenced", 0,
318 PROP_READONLY
, ZFS_TYPE_DATASET
, "<size>", "REFER");
319 zprop_register_number(ZFS_PROP_COMPRESSRATIO
, "compressratio", 0,
320 PROP_READONLY
, ZFS_TYPE_DATASET
,
321 "<1.00x or higher if compressed>", "RATIO");
322 zprop_register_number(ZFS_PROP_REFRATIO
, "refcompressratio", 0,
323 PROP_READONLY
, ZFS_TYPE_DATASET
,
324 "<1.00x or higher if compressed>", "REFRATIO");
325 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE
, "volblocksize",
326 ZVOL_DEFAULT_BLOCKSIZE
, PROP_ONETIME
,
327 ZFS_TYPE_VOLUME
, "512 to 128k, power of 2", "VOLBLOCK");
328 zprop_register_number(ZFS_PROP_USEDSNAP
, "usedbysnapshots", 0,
329 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
331 zprop_register_number(ZFS_PROP_USEDDS
, "usedbydataset", 0,
332 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
334 zprop_register_number(ZFS_PROP_USEDCHILD
, "usedbychildren", 0,
335 PROP_READONLY
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>",
337 zprop_register_number(ZFS_PROP_USEDREFRESERV
, "usedbyrefreservation", 0,
339 ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
, "<size>", "USEDREFRESERV");
340 zprop_register_number(ZFS_PROP_USERREFS
, "userrefs", 0, PROP_READONLY
,
341 ZFS_TYPE_SNAPSHOT
, "<count>", "USERREFS");
343 /* default number properties */
344 zprop_register_number(ZFS_PROP_QUOTA
, "quota", 0, PROP_DEFAULT
,
345 ZFS_TYPE_FILESYSTEM
, "<size> | none", "QUOTA");
346 zprop_register_number(ZFS_PROP_RESERVATION
, "reservation", 0,
347 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
348 "<size> | none", "RESERV");
349 zprop_register_number(ZFS_PROP_VOLSIZE
, "volsize", 0, PROP_DEFAULT
,
350 ZFS_TYPE_VOLUME
, "<size>", "VOLSIZE");
351 zprop_register_number(ZFS_PROP_REFQUOTA
, "refquota", 0, PROP_DEFAULT
,
352 ZFS_TYPE_FILESYSTEM
, "<size> | none", "REFQUOTA");
353 zprop_register_number(ZFS_PROP_REFRESERVATION
, "refreservation", 0,
354 PROP_DEFAULT
, ZFS_TYPE_FILESYSTEM
| ZFS_TYPE_VOLUME
,
355 "<size> | none", "REFRESERV");
357 /* inherit number properties */
358 zprop_register_number(ZFS_PROP_RECORDSIZE
, "recordsize",
359 SPA_MAXBLOCKSIZE
, PROP_INHERIT
,
360 ZFS_TYPE_FILESYSTEM
, "512 to 128k, power of 2", "RECSIZE");
362 /* hidden properties */
363 zprop_register_hidden(ZFS_PROP_CREATETXG
, "createtxg", PROP_TYPE_NUMBER
,
364 PROP_READONLY
, ZFS_TYPE_DATASET
, "CREATETXG");
365 zprop_register_hidden(ZFS_PROP_NUMCLONES
, "numclones", PROP_TYPE_NUMBER
,
366 PROP_READONLY
, ZFS_TYPE_SNAPSHOT
, "NUMCLONES");
367 zprop_register_hidden(ZFS_PROP_NAME
, "name", PROP_TYPE_STRING
,
368 PROP_READONLY
, ZFS_TYPE_DATASET
, "NAME");
369 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS
, "iscsioptions",
370 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
, "ISCSIOPTIONS");
371 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO
, "stmf_sbd_lu",
372 PROP_TYPE_STRING
, PROP_INHERIT
, ZFS_TYPE_VOLUME
,
374 zprop_register_hidden(ZFS_PROP_GUID
, "guid", PROP_TYPE_NUMBER
,
375 PROP_READONLY
, ZFS_TYPE_DATASET
, "GUID");
376 zprop_register_hidden(ZFS_PROP_USERACCOUNTING
, "useraccounting",
377 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_DATASET
,
379 zprop_register_hidden(ZFS_PROP_UNIQUE
, "unique", PROP_TYPE_NUMBER
,
380 PROP_READONLY
, ZFS_TYPE_DATASET
, "UNIQUE");
381 zprop_register_hidden(ZFS_PROP_OBJSETID
, "objsetid", PROP_TYPE_NUMBER
,
382 PROP_READONLY
, ZFS_TYPE_DATASET
, "OBJSETID");
385 * Property to be removed once libbe is integrated
387 zprop_register_hidden(ZFS_PROP_PRIVATE
, "priv_prop",
388 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_FILESYSTEM
,
391 /* oddball properties */
392 zprop_register_impl(ZFS_PROP_CREATION
, "creation", PROP_TYPE_NUMBER
, 0,
393 NULL
, PROP_READONLY
, ZFS_TYPE_DATASET
,
394 "<date>", "CREATION", B_FALSE
, B_TRUE
, NULL
);
398 zfs_prop_delegatable(zfs_prop_t prop
)
400 zprop_desc_t
*pd
= &zfs_prop_table
[prop
];
402 /* The mlslabel property is never delegatable. */
403 if (prop
== ZFS_PROP_MLSLABEL
)
406 return (pd
->pd_attr
!= PROP_READONLY
);
410 * Given a zfs dataset property name, returns the corresponding property ID.
413 zfs_name_to_prop(const char *propname
)
415 return (zprop_name_to_prop(propname
, ZFS_TYPE_DATASET
));
419 * For user property names, we allow all lowercase alphanumeric characters, plus
420 * a few useful punctuation characters.
425 return ((c
>= 'a' && c
<= 'z') ||
426 (c
>= '0' && c
<= '9') ||
427 c
== '-' || c
== '_' || c
== '.' || c
== ':');
431 * Returns true if this is a valid user-defined property (one with a ':').
434 zfs_prop_user(const char *name
)
438 boolean_t foundsep
= B_FALSE
;
440 for (i
= 0; i
< strlen(name
); i
++) {
455 * Returns true if this is a valid userspace-type property (one with a '@').
456 * Note that after the @, any character is valid (eg, another @, for SID
460 zfs_prop_userquota(const char *name
)
462 zfs_userquota_prop_t prop
;
464 for (prop
= 0; prop
< ZFS_NUM_USERQUOTA_PROPS
; prop
++) {
465 if (strncmp(name
, zfs_userquota_prop_prefixes
[prop
],
466 strlen(zfs_userquota_prop_prefixes
[prop
])) == 0) {
475 * Tables of index types, plus functions to convert between the user view
476 * (strings) and internal representation (uint64_t).
479 zfs_prop_string_to_index(zfs_prop_t prop
, const char *string
, uint64_t *index
)
481 return (zprop_string_to_index(prop
, string
, index
, ZFS_TYPE_DATASET
));
485 zfs_prop_index_to_string(zfs_prop_t prop
, uint64_t index
, const char **string
)
487 return (zprop_index_to_string(prop
, index
, string
, ZFS_TYPE_DATASET
));
491 zfs_prop_random_value(zfs_prop_t prop
, uint64_t seed
)
493 return (zprop_random_value(prop
, seed
, ZFS_TYPE_DATASET
));
497 * Returns TRUE if the property applies to any of the given dataset types.
500 zfs_prop_valid_for_type(int prop
, zfs_type_t types
)
502 return (zprop_valid_for_type(prop
, types
));
506 zfs_prop_get_type(zfs_prop_t prop
)
508 return (zfs_prop_table
[prop
].pd_proptype
);
512 * Returns TRUE if the property is readonly.
515 zfs_prop_readonly(zfs_prop_t prop
)
517 return (zfs_prop_table
[prop
].pd_attr
== PROP_READONLY
||
518 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
522 * Returns TRUE if the property is only allowed to be set once.
525 zfs_prop_setonce(zfs_prop_t prop
)
527 return (zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
531 zfs_prop_default_string(zfs_prop_t prop
)
533 return (zfs_prop_table
[prop
].pd_strdefault
);
537 zfs_prop_default_numeric(zfs_prop_t prop
)
539 return (zfs_prop_table
[prop
].pd_numdefault
);
543 * Given a dataset property ID, returns the corresponding name.
544 * Assuming the zfs dataset property ID is valid.
547 zfs_prop_to_name(zfs_prop_t prop
)
549 return (zfs_prop_table
[prop
].pd_name
);
553 * Returns TRUE if the property is inheritable.
556 zfs_prop_inheritable(zfs_prop_t prop
)
558 return (zfs_prop_table
[prop
].pd_attr
== PROP_INHERIT
||
559 zfs_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
565 * Returns a string describing the set of acceptable values for the given
566 * zfs property, or NULL if it cannot be set.
569 zfs_prop_values(zfs_prop_t prop
)
571 return (zfs_prop_table
[prop
].pd_values
);
575 * Returns TRUE if this property is a string type. Note that index types
576 * (compression, checksum) are treated as strings in userland, even though they
577 * are stored numerically on disk.
580 zfs_prop_is_string(zfs_prop_t prop
)
582 return (zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_STRING
||
583 zfs_prop_table
[prop
].pd_proptype
== PROP_TYPE_INDEX
);
587 * Returns the column header for the given property. Used only in
588 * 'zfs list -o', but centralized here with the other property information.
591 zfs_prop_column_name(zfs_prop_t prop
)
593 return (zfs_prop_table
[prop
].pd_colname
);
597 * Returns whether the given property should be displayed right-justified for
601 zfs_prop_align_right(zfs_prop_t prop
)
603 return (zfs_prop_table
[prop
].pd_rightalign
);
608 #if defined(_KERNEL) && defined(HAVE_SPL)
610 static int zcommon_init(void) { return 0; }
611 static int zcommon_fini(void) { return 0; }
613 spl_module_init(zcommon_init
);
614 spl_module_exit(zcommon_fini
);
616 MODULE_DESCRIPTION("Generic ZFS support");
617 MODULE_AUTHOR(ZFS_META_AUTHOR
);
618 MODULE_LICENSE(ZFS_META_LICENSE
);
620 /* zfs dataset property functions */
621 EXPORT_SYMBOL(zfs_userquota_prop_prefixes
);
622 EXPORT_SYMBOL(zfs_prop_init
);
623 EXPORT_SYMBOL(zfs_prop_get_type
);
624 EXPORT_SYMBOL(zfs_prop_get_table
);
625 EXPORT_SYMBOL(zfs_prop_delegatable
);
627 /* Dataset property functions shared between libzfs and kernel. */
628 EXPORT_SYMBOL(zfs_prop_default_string
);
629 EXPORT_SYMBOL(zfs_prop_default_numeric
);
630 EXPORT_SYMBOL(zfs_prop_readonly
);
631 EXPORT_SYMBOL(zfs_prop_inheritable
);
632 EXPORT_SYMBOL(zfs_prop_setonce
);
633 EXPORT_SYMBOL(zfs_prop_to_name
);
634 EXPORT_SYMBOL(zfs_name_to_prop
);
635 EXPORT_SYMBOL(zfs_prop_user
);
636 EXPORT_SYMBOL(zfs_prop_userquota
);
637 EXPORT_SYMBOL(zfs_prop_index_to_string
);
638 EXPORT_SYMBOL(zfs_prop_string_to_index
);
639 EXPORT_SYMBOL(zfs_prop_valid_for_type
);