xref: /titanic_50/usr/src/common/zfs/zfs_prop.c (revision 42cac157f878fbb7ae190eb0339c6932f3192b87)
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 2009 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 		{ "current",	ZPL_VERSION },
157 		{ NULL }
158 	};
159 
160 	static zprop_index_t boolean_table[] = {
161 		{ "off",	0 },
162 		{ "on",		1 },
163 		{ NULL }
164 	};
165 
166 	static zprop_index_t logbias_table[] = {
167 		{ "latency",	ZFS_LOGBIAS_LATENCY },
168 		{ "throughput",	ZFS_LOGBIAS_THROUGHPUT },
169 		{ NULL }
170 	};
171 
172 	static zprop_index_t canmount_table[] = {
173 		{ "off",	ZFS_CANMOUNT_OFF },
174 		{ "on",		ZFS_CANMOUNT_ON },
175 		{ "noauto",	ZFS_CANMOUNT_NOAUTO },
176 		{ NULL }
177 	};
178 
179 	static zprop_index_t cache_table[] = {
180 		{ "none",	ZFS_CACHE_NONE },
181 		{ "metadata",	ZFS_CACHE_METADATA },
182 		{ "all",	ZFS_CACHE_ALL },
183 		{ NULL }
184 	};
185 
186 	/* inherit index properties */
187 	register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT,
188 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
189 	    "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
190 	    checksum_table);
191 	register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
192 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
193 	    "on | off | verify | sha256[,verify]", "DEDUP",
194 	    dedup_table);
195 	register_index(ZFS_PROP_COMPRESSION, "compression",
196 	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
197 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
198 	    "on | off | lzjb | gzip | gzip-[1-9] | zle", "COMPRESS",
199 	    compress_table);
200 	register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
201 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
202 	    "hidden | visible", "SNAPDIR", snapdir_table);
203 	register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_GROUPMASK,
204 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
205 	    "discard | groupmask | passthrough", "ACLMODE", acl_mode_table);
206 	register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_RESTRICTED,
207 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
208 	    "discard | noallow | restricted | passthrough | passthrough-x",
209 	    "ACLINHERIT", acl_inherit_table);
210 	register_index(ZFS_PROP_COPIES, "copies", 1,
211 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
212 	    "1 | 2 | 3", "COPIES", copies_table);
213 	register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
214 	    ZFS_CACHE_ALL, PROP_INHERIT,
215 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
216 	    "all | none | metadata", "PRIMARYCACHE", cache_table);
217 	register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
218 	    ZFS_CACHE_ALL, PROP_INHERIT,
219 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
220 	    "all | none | metadata", "SECONDARYCACHE", cache_table);
221 	register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
222 	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
223 	    "latency | throughput", "LOGBIAS", logbias_table);
224 
225 	/* inherit index (boolean) properties */
226 	register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
227 	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
228 	register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
229 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
230 	    boolean_table);
231 	register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
232 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
233 	    boolean_table);
234 	register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
235 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
236 	    boolean_table);
237 	register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
238 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
239 	    boolean_table);
240 	register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
241 	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
242 	register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
243 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
244 	    boolean_table);
245 	register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
246 	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
247 	    boolean_table);
248 	register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
249 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
250 	    boolean_table);
251 
252 	/* default index properties */
253 	register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
254 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
255 	    "1 | 2 | 3 | 4 | current", "VERSION", version_table);
256 	register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
257 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
258 	    "CANMOUNT", canmount_table);
259 
260 	/* readonly index (boolean) properties */
261 	register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
262 	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
263 	register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
264 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
265 	    boolean_table);
266 
267 	/* set once index properties */
268 	register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
269 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
270 	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
271 	    normalize_table);
272 	register_index(ZFS_PROP_CASE, "casesensitivity", ZFS_CASE_SENSITIVE,
273 	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
274 	    "sensitive | insensitive | mixed", "CASE", case_table);
275 
276 	/* set once index (boolean) properties */
277 	register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
278 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
279 	    "on | off", "UTF8ONLY", boolean_table);
280 
281 	/* string properties */
282 	register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
283 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
284 	register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT,
285 	    ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", "MOUNTPOINT");
286 	register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT,
287 	    ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", "SHARENFS");
288 	register_string(ZFS_PROP_SHAREISCSI, "shareiscsi", "off", PROP_INHERIT,
289 	    ZFS_TYPE_DATASET, "on | off | type=<type>", "SHAREISCSI");
290 	register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
291 	    ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE");
292 	register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", PROP_INHERIT,
293 	    ZFS_TYPE_FILESYSTEM, "on | off | sharemgr(1M) options", "SHARESMB");
294 	register_string(ZFS_PROP_MLSLABEL, "mlslabel", ZFS_MLSLABEL_DEFAULT,
295 	    PROP_INHERIT, ZFS_TYPE_DATASET, "<sensitivity label>", "MLSLABEL");
296 
297 	/* readonly number properties */
298 	register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
299 	    ZFS_TYPE_DATASET, "<size>", "USED");
300 	register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
301 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
302 	register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY,
303 	    ZFS_TYPE_DATASET, "<size>", "REFER");
304 	register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
305 	    PROP_READONLY, ZFS_TYPE_DATASET,
306 	    "<1.00x or higher if compressed>", "RATIO");
307 	register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 8192,
308 	    PROP_ONETIME,
309 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK");
310 	register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, PROP_READONLY,
311 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDSNAP");
312 	register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, PROP_READONLY,
313 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDDS");
314 	register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, PROP_READONLY,
315 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDCHILD");
316 	register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
317 	    PROP_READONLY,
318 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
319 	register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
320 	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
321 
322 	/* default number properties */
323 	register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
324 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
325 	register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT,
326 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size> | none", "RESERV");
327 	register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
328 	    ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
329 	register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
330 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
331 	register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
332 	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
333 	    "<size> | none", "REFRESERV");
334 
335 	/* inherit number properties */
336 	register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_MAXBLOCKSIZE,
337 	    PROP_INHERIT,
338 	    ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE");
339 
340 	/* hidden properties */
341 	register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
342 	    PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG");
343 	register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
344 	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
345 	register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
346 	    PROP_READONLY, ZFS_TYPE_DATASET, "NAME");
347 	register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING,
348 	    PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
349 	register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
350 	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
351 	    "STMF_SBD_LU");
352 	register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY,
353 	    ZFS_TYPE_DATASET, "GUID");
354 	register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
355 	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
356 	    "USERACCOUNTING");
357 	register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
358 	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
359 	register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
360 	    PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
361 
362 	/* oddball properties */
363 	register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL,
364 	    PROP_READONLY, ZFS_TYPE_DATASET,
365 	    "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
366 }
367 
368 boolean_t
369 zfs_prop_delegatable(zfs_prop_t prop)
370 {
371 	zprop_desc_t *pd = &zfs_prop_table[prop];
372 
373 	/* The mlslabel property is never delegatable. */
374 	if (prop == ZFS_PROP_MLSLABEL)
375 		return (B_FALSE);
376 
377 	return (pd->pd_attr != PROP_READONLY);
378 }
379 
380 /*
381  * Given a zfs dataset property name, returns the corresponding property ID.
382  */
383 zfs_prop_t
384 zfs_name_to_prop(const char *propname)
385 {
386 	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
387 }
388 
389 /*
390  * For user property names, we allow all lowercase alphanumeric characters, plus
391  * a few useful punctuation characters.
392  */
393 static int
394 valid_char(char c)
395 {
396 	return ((c >= 'a' && c <= 'z') ||
397 	    (c >= '0' && c <= '9') ||
398 	    c == '-' || c == '_' || c == '.' || c == ':');
399 }
400 
401 /*
402  * Returns true if this is a valid user-defined property (one with a ':').
403  */
404 boolean_t
405 zfs_prop_user(const char *name)
406 {
407 	int i;
408 	char c;
409 	boolean_t foundsep = B_FALSE;
410 
411 	for (i = 0; i < strlen(name); i++) {
412 		c = name[i];
413 		if (!valid_char(c))
414 			return (B_FALSE);
415 		if (c == ':')
416 			foundsep = B_TRUE;
417 	}
418 
419 	if (!foundsep)
420 		return (B_FALSE);
421 
422 	return (B_TRUE);
423 }
424 
425 /*
426  * Returns true if this is a valid userspace-type property (one with a '@').
427  * Note that after the @, any character is valid (eg, another @, for SID
428  * user@domain).
429  */
430 boolean_t
431 zfs_prop_userquota(const char *name)
432 {
433 	zfs_userquota_prop_t prop;
434 
435 	for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
436 		if (strncmp(name, zfs_userquota_prop_prefixes[prop],
437 		    strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
438 			return (B_TRUE);
439 		}
440 	}
441 
442 	return (B_FALSE);
443 }
444 
445 /*
446  * Tables of index types, plus functions to convert between the user view
447  * (strings) and internal representation (uint64_t).
448  */
449 int
450 zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
451 {
452 	return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
453 }
454 
455 int
456 zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
457 {
458 	return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
459 }
460 
461 uint64_t
462 zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
463 {
464 	return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
465 }
466 
467 /*
468  * Returns TRUE if the property applies to any of the given dataset types.
469  */
470 boolean_t
471 zfs_prop_valid_for_type(int prop, zfs_type_t types)
472 {
473 	return (zprop_valid_for_type(prop, types));
474 }
475 
476 zprop_type_t
477 zfs_prop_get_type(zfs_prop_t prop)
478 {
479 	return (zfs_prop_table[prop].pd_proptype);
480 }
481 
482 /*
483  * Returns TRUE if the property is readonly.
484  */
485 boolean_t
486 zfs_prop_readonly(zfs_prop_t prop)
487 {
488 	return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
489 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
490 }
491 
492 /*
493  * Returns TRUE if the property is only allowed to be set once.
494  */
495 boolean_t
496 zfs_prop_setonce(zfs_prop_t prop)
497 {
498 	return (zfs_prop_table[prop].pd_attr == PROP_ONETIME);
499 }
500 
501 const char *
502 zfs_prop_default_string(zfs_prop_t prop)
503 {
504 	return (zfs_prop_table[prop].pd_strdefault);
505 }
506 
507 uint64_t
508 zfs_prop_default_numeric(zfs_prop_t prop)
509 {
510 	return (zfs_prop_table[prop].pd_numdefault);
511 }
512 
513 /*
514  * Given a dataset property ID, returns the corresponding name.
515  * Assuming the zfs dataset property ID is valid.
516  */
517 const char *
518 zfs_prop_to_name(zfs_prop_t prop)
519 {
520 	return (zfs_prop_table[prop].pd_name);
521 }
522 
523 /*
524  * Returns TRUE if the property is inheritable.
525  */
526 boolean_t
527 zfs_prop_inheritable(zfs_prop_t prop)
528 {
529 	return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
530 	    zfs_prop_table[prop].pd_attr == PROP_ONETIME);
531 }
532 
533 #ifndef _KERNEL
534 
535 /*
536  * Returns a string describing the set of acceptable values for the given
537  * zfs property, or NULL if it cannot be set.
538  */
539 const char *
540 zfs_prop_values(zfs_prop_t prop)
541 {
542 	return (zfs_prop_table[prop].pd_values);
543 }
544 
545 /*
546  * Returns TRUE if this property is a string type.  Note that index types
547  * (compression, checksum) are treated as strings in userland, even though they
548  * are stored numerically on disk.
549  */
550 int
551 zfs_prop_is_string(zfs_prop_t prop)
552 {
553 	return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
554 	    zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
555 }
556 
557 /*
558  * Returns the column header for the given property.  Used only in
559  * 'zfs list -o', but centralized here with the other property information.
560  */
561 const char *
562 zfs_prop_column_name(zfs_prop_t prop)
563 {
564 	return (zfs_prop_table[prop].pd_colname);
565 }
566 
567 /*
568  * Returns whether the given property should be displayed right-justified for
569  * 'zfs list'.
570  */
571 boolean_t
572 zfs_prop_align_right(zfs_prop_t prop)
573 {
574 	return (zfs_prop_table[prop].pd_rightalign);
575 }
576 
577 #endif
578