xref: /titanic_41/usr/src/common/zfs/zfs_prop.c (revision 68c47f65208790c466e5e484f2293d3baed71c6a)
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
9  * or http://www.opensolaris.org/os/licensing.
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 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/zio.h>
27 #include <sys/spa.h>
28 #include <sys/u8_textprep.h>
29 #include <sys/zfs_acl.h>
30 #include <sys/zfs_ioctl.h>
31 #include <sys/zfs_znode.h>
32 
33 #include "zfs_prop.h"
34 #include "zfs_deleg.h"
35 
36 #if defined(_KERNEL)
37 #include <sys/systm.h>
38 #else
39 #include <stdlib.h>
40 #include <string.h>
41 #include <ctype.h>
42 #endif
43 
44 static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
45 
46 /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
47 const char *zfs_userquota_prop_prefixes[] = {
48 	"userused@",
49 	"userquota@",
50 	"groupused@",
51 	"groupquota@"
52 };
53 
54 zprop_desc_t *
55 zfs_prop_get_table(void)
56 {
57 	return (zfs_prop_table);
58 }
59 
60 void
61 zfs_prop_init(void)
62 {
63 	static zprop_index_t checksum_table[] = {
64 		{ "on",		ZIO_CHECKSUM_ON },
65 		{ "off",	ZIO_CHECKSUM_OFF },
66 		{ "fletcher2",	ZIO_CHECKSUM_FLETCHER_2 },
67 		{ "fletcher4",	ZIO_CHECKSUM_FLETCHER_4 },
68 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
69 		{ NULL }
70 	};
71 
72 	static zprop_index_t dedup_table[] = {
73 		{ "on",		ZIO_CHECKSUM_ON },
74 		{ "off",	ZIO_CHECKSUM_OFF },
75 		{ "verify",	ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
76 		{ "sha256",	ZIO_CHECKSUM_SHA256 },
77 		{ "sha256,verify",
78 				ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
79 		{ NULL }
80 	};
81 
82 	static zprop_index_t compress_table[] = {
83 		{ "on",		ZIO_COMPRESS_ON },
84 		{ "off",	ZIO_COMPRESS_OFF },
85 		{ "lzjb",	ZIO_COMPRESS_LZJB },
86 		{ "gzip",	ZIO_COMPRESS_GZIP_6 },	/* gzip default */
87 		{ "gzip-1",	ZIO_COMPRESS_GZIP_1 },
88 		{ "gzip-2",	ZIO_COMPRESS_GZIP_2 },
89 		{ "gzip-3",	ZIO_COMPRESS_GZIP_3 },
90 		{ "gzip-4",	ZIO_COMPRESS_GZIP_4 },
91 		{ "gzip-5",	ZIO_COMPRESS_GZIP_5 },
92 		{ "gzip-6",	ZIO_COMPRESS_GZIP_6 },
93 		{ "gzip-7",	ZIO_COMPRESS_GZIP_7 },
94 		{ "gzip-8",	ZIO_COMPRESS_GZIP_8 },
95 		{ "gzip-9",	ZIO_COMPRESS_GZIP_9 },
96 		{ "zle",	ZIO_COMPRESS_ZLE },
97 		{ NULL }
98 	};
99 
100 	static zprop_index_t snapdir_table[] = {
101 		{ "hidden",	ZFS_SNAPDIR_HIDDEN },
102 		{ "visible",	ZFS_SNAPDIR_VISIBLE },
103 		{ NULL }
104 	};
105 
106 	static zprop_index_t acl_mode_table[] = {
107 		{ "discard",	ZFS_ACL_DISCARD },
108 		{ "groupmask",	ZFS_ACL_GROUPMASK },
109 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
110 		{ NULL }
111 	};
112 
113 	static zprop_index_t acl_inherit_table[] = {
114 		{ "discard",	ZFS_ACL_DISCARD },
115 		{ "noallow",	ZFS_ACL_NOALLOW },
116 		{ "restricted",	ZFS_ACL_RESTRICTED },
117 		{ "passthrough", ZFS_ACL_PASSTHROUGH },
118 		{ "secure",	ZFS_ACL_RESTRICTED }, /* bkwrd compatability */
119 		{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
120 		{ NULL }
121 	};
122 
123 	static zprop_index_t case_table[] = {
124 		{ "sensitive",		ZFS_CASE_SENSITIVE },
125 		{ "insensitive",	ZFS_CASE_INSENSITIVE },
126 		{ "mixed",		ZFS_CASE_MIXED },
127 		{ NULL }
128 	};
129 
130 	static zprop_index_t copies_table[] = {
131 		{ "1",		1 },
132 		{ "2",		2 },
133 		{ "3",		3 },
134 		{ NULL }
135 	};
136 
137 	/*
138 	 * Use the unique flags we have to send to u8_strcmp() and/or
139 	 * u8_textprep() to represent the various normalization property
140 	 * values.
141 	 */
142 	static zprop_index_t normalize_table[] = {
143 		{ "none",	0 },
144 		{ "formD",	U8_TEXTPREP_NFD },
145 		{ "formKC",	U8_TEXTPREP_NFKC },
146 		{ "formC",	U8_TEXTPREP_NFC },
147 		{ "formKD",	U8_TEXTPREP_NFKD },
148 		{ NULL }
149 	};
150 
151 	static zprop_index_t version_table[] = {
152 		{ "1",		1 },
153 		{ "2",		2 },
154 		{ "3",		3 },
155 		{ "4",		4 },
156 		{ "5",		5 },
157 		{ "current",	ZPL_VERSION },
158 		{ NULL }
159 	};
160 
161 	static zprop_index_t boolean_table[] = {
162 		{ "off",	0 },
163 		{ "on",		1 },
164 		{ NULL }
165 	};
166 
167 	static zprop_index_t logbias_table[] = {
168 		{ "latency",	ZFS_LOGBIAS_LATENCY },
169 		{ "throughput",	ZFS_LOGBIAS_THROUGHPUT },
170 		{ NULL }
171 	};
172 
173 	static zprop_index_t canmount_table[] = {
174 		{ "off",	ZFS_CANMOUNT_OFF },
175 		{ "on",		ZFS_CANMOUNT_ON },
176 		{ "noauto",	ZFS_CANMOUNT_NOAUTO },
177 		{ NULL }
178 	};
179 
180 	static zprop_index_t cache_table[] = {
181 		{ "none",	ZFS_CACHE_NONE },
182 		{ "metadata",	ZFS_CACHE_METADATA },
183 		{ "all",	ZFS_CACHE_ALL },
184 		{ NULL }
185 	};
186 
187 	/* inherit index properties */
188 	register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT,
189 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
190 	    "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
191 	    checksum_table);
192 	register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
193 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
194 	    "on | off | verify | sha256[,verify]", "DEDUP",
195 	    dedup_table);
196 	register_index(ZFS_PROP_COMPRESSION, "compression",
197 	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
198 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
199 	    "on | off | lzjb | gzip | gzip-[1-9] | zle", "COMPRESS",
200 	    compress_table);
201 	register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
202 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
203 	    "hidden | visible", "SNAPDIR", snapdir_table);
204 	register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_GROUPMASK,
205 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
206 	    "discard | groupmask | passthrough", "ACLMODE", acl_mode_table);
207 	register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_RESTRICTED,
208 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
209 	    "discard | noallow | restricted | passthrough | passthrough-x",
210 	    "ACLINHERIT", acl_inherit_table);
211 	register_index(ZFS_PROP_COPIES, "copies", 1,
212 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
213 	    "1 | 2 | 3", "COPIES", copies_table);
214 	register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
215 	    ZFS_CACHE_ALL, PROP_INHERIT,
216 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
217 	    "all | none | metadata", "PRIMARYCACHE", cache_table);
218 	register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
219 	    ZFS_CACHE_ALL, PROP_INHERIT,
220 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
221 	    "all | none | metadata", "SECONDARYCACHE", cache_table);
222 	register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
223 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
224 	    "latency | throughput", "LOGBIAS", logbias_table);
225 
226 	/* inherit index (boolean) properties */
227 	register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
228 	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
229 	register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
230 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
231 	    boolean_table);
232 	register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
233 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
234 	    boolean_table);
235 	register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
236 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
237 	    boolean_table);
238 	register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
239 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
240 	    boolean_table);
241 	register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
242 	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
243 	register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
244 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
245 	    boolean_table);
246 	register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
247 	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
248 	    boolean_table);
249 	register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
250 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
251 	    boolean_table);
252 
253 	/* default index properties */
254 	register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
255 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
256 	    "1 | 2 | 3 | 4 | current", "VERSION", version_table);
257 	register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
258 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
259 	    "CANMOUNT", canmount_table);
260 
261 	/* readonly index (boolean) properties */
262 	register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
263 	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
264 	register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
265 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
266 	    boolean_table);
267 
268 	/* set once index properties */
269 	register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
270 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
271 	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
272 	    normalize_table);
273 	register_index(ZFS_PROP_CASE, "casesensitivity", ZFS_CASE_SENSITIVE,
274 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
275 	    "sensitive | insensitive | mixed", "CASE", case_table);
276 
277 	/* set once index (boolean) properties */
278 	register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
279 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
280 	    "on | off", "UTF8ONLY", boolean_table);
281 
282 	/* string properties */
283 	register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
284 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
285 	register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT,
286 	    ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", "MOUNTPOINT");
287 	register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT,
288 	    ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", "SHARENFS");
289 	register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
290 	    ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE");
291 	register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", PROP_INHERIT,
292 	    ZFS_TYPE_FILESYSTEM, "on | off | sharemgr(1M) options", "SHARESMB");
293 	register_string(ZFS_PROP_MLSLABEL, "mlslabel", ZFS_MLSLABEL_DEFAULT,
294 	    PROP_INHERIT, ZFS_TYPE_DATASET, "<sensitivity label>", "MLSLABEL");
295 
296 	/* readonly number properties */
297 	register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
298 	    ZFS_TYPE_DATASET, "<size>", "USED");
299 	register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
300 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
301 	register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY,
302 	    ZFS_TYPE_DATASET, "<size>", "REFER");
303 	register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
304 	    PROP_READONLY, ZFS_TYPE_DATASET,
305 	    "<1.00x or higher if compressed>", "RATIO");
306 	register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
307 	    ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
308 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK");
309 	register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, PROP_READONLY,
310 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDSNAP");
311 	register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, PROP_READONLY,
312 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDDS");
313 	register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, PROP_READONLY,
314 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDCHILD");
315 	register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
316 	    PROP_READONLY,
317 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
318 	register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
319 	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
320 
321 	/* default number properties */
322 	register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
323 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
324 	register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT,
325 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size> | none", "RESERV");
326 	register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
327 	    ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
328 	register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
329 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
330 	register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
331 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
332 	    "<size> | none", "REFRESERV");
333 
334 	/* inherit number properties */
335 	register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_MAXBLOCKSIZE,
336 	    PROP_INHERIT,
337 	    ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE");
338 
339 	/* hidden properties */
340 	register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
341 	    PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG");
342 	register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
343 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
344 	register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
345 	    PROP_READONLY, ZFS_TYPE_DATASET, "NAME");
346 	register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING,
347 	    PROP_READONLY, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
348 	register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
349 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
350 	    "STMF_SBD_LU");
351 	register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY,
352 	    ZFS_TYPE_DATASET, "GUID");
353 	register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
354 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
355 	    "USERACCOUNTING");
356 	register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
357 	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
358 	register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
359 	    PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
360 
361 	/* oddball properties */
362 	register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL,
363 	    PROP_READONLY, ZFS_TYPE_DATASET,
364 	    "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
365 }
366 
367 boolean_t
368 zfs_prop_delegatable(zfs_prop_t prop)
369 {
370 	zprop_desc_t *pd = &zfs_prop_table[prop];
371 
372 	/* The mlslabel property is never delegatable. */
373 	if (prop == ZFS_PROP_MLSLABEL)
374 		return (B_FALSE);
375 
376 	return (pd->pd_attr != PROP_READONLY);
377 }
378 
379 /*
380  * Given a zfs dataset property name, returns the corresponding property ID.
381  */
382 zfs_prop_t
383 zfs_name_to_prop(const char *propname)
384 {
385 	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
386 }
387 
388 /*
389  * For user property names, we allow all lowercase alphanumeric characters, plus
390  * a few useful punctuation characters.
391  */
392 static int
393 valid_char(char c)
394 {
395 	return ((c >= 'a' && c <= 'z') ||
396 	    (c >= '0' && c <= '9') ||
397 	    c == '-' || c == '_' || c == '.' || c == ':');
398 }
399 
400 /*
401  * Returns true if this is a valid user-defined property (one with a ':').
402  */
403 boolean_t
404 zfs_prop_user(const char *name)
405 {
406 	int i;
407 	char c;
408 	boolean_t foundsep = B_FALSE;
409 
410 	for (i = 0; i < strlen(name); i++) {
411 		c = name[i];
412 		if (!valid_char(c))
413 			return (B_FALSE);
414 		if (c == ':')
415 			foundsep = B_TRUE;
416 	}
417 
418 	if (!foundsep)
419 		return (B_FALSE);
420 
421 	return (B_TRUE);
422 }
423 
424 /*
425  * Returns true if this is a valid userspace-type property (one with a '@').
426  * Note that after the @, any character is valid (eg, another @, for SID
427  * user@domain).
428  */
429 boolean_t
430 zfs_prop_userquota(const char *name)
431 {
432 	zfs_userquota_prop_t prop;
433 
434 	for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
435 		if (strncmp(name, zfs_userquota_prop_prefixes[prop],
436 		    strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
437 			return (B_TRUE);
438 		}
439 	}
440 
441 	return (B_FALSE);
442 }
443 
444 /*
445  * Tables of index types, plus functions to convert between the user view
446  * (strings) and internal representation (uint64_t).
447  */
448 int
449 zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
450 {
451 	return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
452 }
453 
454 int
455 zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
456 {
457 	return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
458 }
459 
460 uint64_t
461 zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
462 {
463 	return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
464 }
465 
466 /*
467  * Returns TRUE if the property applies to any of the given dataset types.
468  */
469 boolean_t
470 zfs_prop_valid_for_type(int prop, zfs_type_t types)
471 {
472 	return (zprop_valid_for_type(prop, types));
473 }
474 
475 zprop_type_t
476 zfs_prop_get_type(zfs_prop_t prop)
477 {
478 	return (zfs_prop_table[prop].pd_proptype);
479 }
480 
481 /*
482  * Returns TRUE if the property is readonly.
483  */
484 boolean_t
485 zfs_prop_readonly(zfs_prop_t prop)
486 {
487 	return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
488 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
489 }
490 
491 /*
492  * Returns TRUE if the property is only allowed to be set once.
493  */
494 boolean_t
495 zfs_prop_setonce(zfs_prop_t prop)
496 {
497 	return (zfs_prop_table[prop].pd_attr == PROP_ONETIME);
498 }
499 
500 const char *
501 zfs_prop_default_string(zfs_prop_t prop)
502 {
503 	return (zfs_prop_table[prop].pd_strdefault);
504 }
505 
506 uint64_t
507 zfs_prop_default_numeric(zfs_prop_t prop)
508 {
509 	return (zfs_prop_table[prop].pd_numdefault);
510 }
511 
512 /*
513  * Given a dataset property ID, returns the corresponding name.
514  * Assuming the zfs dataset property ID is valid.
515  */
516 const char *
517 zfs_prop_to_name(zfs_prop_t prop)
518 {
519 	return (zfs_prop_table[prop].pd_name);
520 }
521 
522 /*
523  * Returns TRUE if the property is inheritable.
524  */
525 boolean_t
526 zfs_prop_inheritable(zfs_prop_t prop)
527 {
528 	return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
529 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
530 }
531 
532 #ifndef _KERNEL
533 
534 /*
535  * Returns a string describing the set of acceptable values for the given
536  * zfs property, or NULL if it cannot be set.
537  */
538 const char *
539 zfs_prop_values(zfs_prop_t prop)
540 {
541 	return (zfs_prop_table[prop].pd_values);
542 }
543 
544 /*
545  * Returns TRUE if this property is a string type.  Note that index types
546  * (compression, checksum) are treated as strings in userland, even though they
547  * are stored numerically on disk.
548  */
549 int
550 zfs_prop_is_string(zfs_prop_t prop)
551 {
552 	return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
553 	    zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
554 }
555 
556 /*
557  * Returns the column header for the given property.  Used only in
558  * 'zfs list -o', but centralized here with the other property information.
559  */
560 const char *
561 zfs_prop_column_name(zfs_prop_t prop)
562 {
563 	return (zfs_prop_table[prop].pd_colname);
564 }
565 
566 /*
567  * Returns whether the given property should be displayed right-justified for
568  * 'zfs list'.
569  */
570 boolean_t
571 zfs_prop_align_right(zfs_prop_t prop)
572 {
573 	return (zfs_prop_table[prop].pd_rightalign);
574 }
575 
576 #endif
577