xref: /titanic_52/usr/src/common/zfs/zfs_prop.c (revision 07ba041951d9c8107e1fde609b578608d2f08e24)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5fa9e4066Sahrens  * Common Development and Distribution License, Version 1.0 only
6fa9e4066Sahrens  * (the "License").  You may not use this file except in compliance
7fa9e4066Sahrens  * with the License.
8fa9e4066Sahrens  *
9fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
11fa9e4066Sahrens  * See the License for the specific language governing permissions
12fa9e4066Sahrens  * and limitations under the License.
13fa9e4066Sahrens  *
14fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
15fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
17fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
18fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
19fa9e4066Sahrens  *
20fa9e4066Sahrens  * CDDL HEADER END
21fa9e4066Sahrens  */
22fa9e4066Sahrens /*
23fa9e4066Sahrens  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24fa9e4066Sahrens  * Use is subject to license terms.
25fa9e4066Sahrens  */
26fa9e4066Sahrens 
27fa9e4066Sahrens #pragma ident	"%Z%%M%	%I%	%E% SMI"
28fa9e4066Sahrens 
29fa9e4066Sahrens /*
30fa9e4066Sahrens  * Master property table.
31fa9e4066Sahrens  *
32fa9e4066Sahrens  * This table keeps track of all the properties supported by ZFS, and their
33fa9e4066Sahrens  * various attributes.  Not all of these are needed by the kernel, and several
34fa9e4066Sahrens  * are only used by a single libzfs client.  But having them here centralizes
35fa9e4066Sahrens  * all property information in one location.
36fa9e4066Sahrens  *
37fa9e4066Sahrens  * 	name		The human-readable string representing this property
38fa9e4066Sahrens  * 	proptype	Basic type (string, boolean, number)
39fa9e4066Sahrens  * 	default		Default value for the property.  Sadly, C only allows
40fa9e4066Sahrens  * 			you to initialize the first member of a union, so we
41fa9e4066Sahrens  * 			have two default members for each property.
42fa9e4066Sahrens  * 	attr		Attributes (readonly, inheritable) for the property
43fa9e4066Sahrens  * 	types		Valid dataset types to which this applies
44fa9e4066Sahrens  * 	values		String describing acceptable values for the property
45fa9e4066Sahrens  * 	colname		The column header for 'zfs list'
46fa9e4066Sahrens  *	colfmt		The column formatting for 'zfs list'
47fa9e4066Sahrens  *
48fa9e4066Sahrens  * This table must match the order of property types in libzfs.h.
49fa9e4066Sahrens  */
50fa9e4066Sahrens 
51fa9e4066Sahrens #include <sys/zio.h>
52fa9e4066Sahrens #include <sys/spa.h>
53fa9e4066Sahrens #include <sys/zfs_acl.h>
54fa9e4066Sahrens #include <sys/zfs_ioctl.h>
55fa9e4066Sahrens 
56fa9e4066Sahrens #include "zfs_prop.h"
57fa9e4066Sahrens 
58fa9e4066Sahrens #if defined(_KERNEL)
59fa9e4066Sahrens #include <sys/systm.h>
60fa9e4066Sahrens #else
61fa9e4066Sahrens #include <stdlib.h>
62fa9e4066Sahrens #include <string.h>
63fa9e4066Sahrens #include <ctype.h>
64fa9e4066Sahrens #endif
65fa9e4066Sahrens 
66fa9e4066Sahrens typedef enum {
67fa9e4066Sahrens 	prop_default,
68fa9e4066Sahrens 	prop_readonly,
69fa9e4066Sahrens 	prop_inherit
70fa9e4066Sahrens } prop_attr_t;
71fa9e4066Sahrens 
72fa9e4066Sahrens typedef struct {
73fa9e4066Sahrens 	const char	*pd_name;
74fa9e4066Sahrens 	zfs_proptype_t	pd_proptype;
75fa9e4066Sahrens 	uint64_t	pd_numdefault;
76fa9e4066Sahrens 	const char	*pd_strdefault;
77fa9e4066Sahrens 	prop_attr_t	pd_attr;
78fa9e4066Sahrens 	int		pd_types;
79fa9e4066Sahrens 	const char	*pd_values;
80fa9e4066Sahrens 	const char	*pd_colname;
81fa9e4066Sahrens 	const char	*pd_colfmt;
82fa9e4066Sahrens } prop_desc_t;
83fa9e4066Sahrens 
84fa9e4066Sahrens static prop_desc_t zfs_prop_table[ZFS_NPROP_ALL] = {
85fa9e4066Sahrens 	{ "type",	prop_type_string,	0,	NULL,	prop_readonly,
86fa9e4066Sahrens 	    ZFS_TYPE_ANY, "filesystem | volume | snapshot", "TYPE", "%10s" },
87fa9e4066Sahrens 	{ "creation",	prop_type_number,	0,	NULL,	prop_readonly,
88fa9e4066Sahrens 	    ZFS_TYPE_ANY, "<date>", "CREATION", "%-20s" },
89fa9e4066Sahrens 	{ "used",	prop_type_number,	0,	NULL,	prop_readonly,
90fa9e4066Sahrens 	    ZFS_TYPE_ANY, "<size>",	"USED", "%5s" },
91fa9e4066Sahrens 	{ "available",	prop_type_number,	0,	NULL,	prop_readonly,
92fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL", "%5s" },
93fa9e4066Sahrens 	{ "referenced",	prop_type_number,	0,	NULL,	prop_readonly,
94fa9e4066Sahrens 	    ZFS_TYPE_SNAPSHOT | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
95fa9e4066Sahrens 	    "<size>", "REFER", "%5s" },
96fa9e4066Sahrens 	{ "compressratio", prop_type_number,	0,	NULL,	prop_readonly,
97fa9e4066Sahrens 	    ZFS_TYPE_ANY, "<1.00x or higher if compressed>", "RATIO", "%5s" },
98fa9e4066Sahrens 	{ "mounted",	prop_type_boolean,	0,	NULL,	prop_readonly,
99fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM, "yes | no | -", "MOUNTED", "%7s" },
100fa9e4066Sahrens 	{ "origin",	prop_type_string,	0,	NULL,	prop_readonly,
101fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM, "<snapshot>", "ORIGIN", "%-20s" },
102fa9e4066Sahrens 	{ "quota",	prop_type_number,	0,	NULL,	prop_default,
103fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA", "%5s" },
104fa9e4066Sahrens 	{ "reservation", prop_type_number,	0,	NULL,	prop_default,
105fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
106fa9e4066Sahrens 	    "<size> | none", "RESERV", "%6s" },
107fa9e4066Sahrens 	{ "volsize",	prop_type_number,	0,	NULL,	prop_default,
108fa9e4066Sahrens 	    ZFS_TYPE_VOLUME, "<size>", "VOLSIZE", "%7s" },
109fa9e4066Sahrens 	{ "volblocksize", prop_type_number,	8192,	NULL,	prop_default,
110fa9e4066Sahrens 	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK", "%8s" },
111fa9e4066Sahrens 	{ "recordsize",	prop_type_number,	SPA_MAXBLOCKSIZE,	NULL,
112fa9e4066Sahrens 	    prop_inherit,
113fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
114fa9e4066Sahrens 	    "512 to 128k, power of 2", "RECSIZE", "%7s" },
115fa9e4066Sahrens 	{ "mountpoint",	prop_type_string,	0,	"/",	prop_inherit,
116fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
117fa9e4066Sahrens 	    "<path> | legacy | none", "MOUNTPOINT", "%-20s" },
118fa9e4066Sahrens 	{ "sharenfs",	prop_type_string,	0,	"off",	prop_inherit,
119fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
120fa9e4066Sahrens 	    "on | off | share(1M) options", "SHARENFS", "%-15s" },
121fa9e4066Sahrens 	{ "checksum",	prop_type_index,	ZIO_CHECKSUM_DEFAULT,	NULL,
122fa9e4066Sahrens 	    prop_inherit,	ZFS_TYPE_ANY,
123fa9e4066Sahrens 	    "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM", "%10s" },
124fa9e4066Sahrens 	{ "compression", prop_type_index,	ZIO_COMPRESS_DEFAULT,	NULL,
125fa9e4066Sahrens 	    prop_inherit,	ZFS_TYPE_ANY,
126fa9e4066Sahrens 	    "on | off | lzjb", "COMPRESS", "%8s" },
127fa9e4066Sahrens 	{ "atime",	prop_type_boolean,	1,	NULL,	prop_inherit,
128fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
129fa9e4066Sahrens 	    "on | off", "ATIME", "%5s" },
130fa9e4066Sahrens 	{ "devices",	prop_type_boolean,	1,	NULL,	prop_inherit,
131fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
132fa9e4066Sahrens 	    "on | off", "DEVICES", "%7s" },
133fa9e4066Sahrens 	{ "exec",	prop_type_boolean,	1,	NULL,	prop_inherit,
134fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
135fa9e4066Sahrens 	    "on | off", "EXEC", "%4s" },
136fa9e4066Sahrens 	{ "setuid",	prop_type_boolean,	1,	NULL,	prop_inherit,
137fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM, "on | off", "SETUID", "%6s" },
138fa9e4066Sahrens 	{ "readonly",	prop_type_boolean,	0,	NULL,	prop_inherit,
139fa9e4066Sahrens 	    ZFS_TYPE_ANY, "on | off", "RDONLY", "%6s" },
140fa9e4066Sahrens 	{ "zoned",	prop_type_boolean,	0,	NULL,	prop_inherit,
141fa9e4066Sahrens 	    ZFS_TYPE_ANY,
142fa9e4066Sahrens 	    "on | off", "ZONED", "%5s" },
143a0965f35Sbonwick 	{ "snapdir",	prop_type_index,	ZFS_SNAPDIR_VISIBLE,	NULL,
144a0965f35Sbonwick 	    prop_inherit,
145fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
146fa9e4066Sahrens 	    "hidden | visible", "SNAPDIR", "%7s" },
147fa9e4066Sahrens 	{ "aclmode", prop_type_index,	GROUPMASK,	 NULL,	prop_inherit,
148fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
149fa9e4066Sahrens 	    "discard | groupmask | passthrough", "ACLMODE", "%11s" },
150fa9e4066Sahrens 	{ "aclinherit", prop_type_index,	SECURE,	NULL, 	prop_inherit,
151fa9e4066Sahrens 	    ZFS_TYPE_FILESYSTEM,
152fa9e4066Sahrens 	    "discard | noallow | secure | passthrough", "ACLINHERIT", "%11s" },
153fa9e4066Sahrens 	{ "createtxg",	prop_type_number,	0,	NULL,	prop_readonly,
154fa9e4066Sahrens 	    ZFS_TYPE_ANY, NULL, NULL, NULL},
155fa9e4066Sahrens 	{ "name",	prop_type_string,	0,	NULL,	prop_readonly,
156fa9e4066Sahrens 	    ZFS_TYPE_ANY,
157fa9e4066Sahrens 	    NULL, "NAME", "%-20s" },
158fa9e4066Sahrens };
159fa9e4066Sahrens 
160fa9e4066Sahrens zfs_proptype_t
161fa9e4066Sahrens zfs_prop_get_type(zfs_prop_t prop)
162fa9e4066Sahrens {
163fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_proptype);
164fa9e4066Sahrens }
165fa9e4066Sahrens 
166fa9e4066Sahrens /*
167fa9e4066Sahrens  * Given a property name, returns the corresponding property ID.
168fa9e4066Sahrens  */
169fa9e4066Sahrens zfs_prop_t
170fa9e4066Sahrens zfs_name_to_prop(const char *propname)
171fa9e4066Sahrens {
172fa9e4066Sahrens 	int i;
173fa9e4066Sahrens 
174fa9e4066Sahrens 	for (i = 0; i < ZFS_NPROP_ALL; i++) {
175fa9e4066Sahrens 		if (strcmp(zfs_prop_table[i].pd_name, propname) == 0)
176fa9e4066Sahrens 			return (i);
177fa9e4066Sahrens #ifndef _KERNEL
178fa9e4066Sahrens 		if (zfs_prop_table[i].pd_colname != NULL &&
179fa9e4066Sahrens 		    strcasecmp(zfs_prop_table[i].pd_colname, propname) == 0)
180fa9e4066Sahrens 			return (i);
181fa9e4066Sahrens #endif
182fa9e4066Sahrens 	}
183fa9e4066Sahrens 
184fa9e4066Sahrens 	return (ZFS_PROP_INVAL);
185fa9e4066Sahrens }
186fa9e4066Sahrens 
187fa9e4066Sahrens /*
188fa9e4066Sahrens  * Return the default value for the given property.
189fa9e4066Sahrens  */
190fa9e4066Sahrens void
191fa9e4066Sahrens zfs_prop_default_string(zfs_prop_t prop, char *buf, size_t buflen)
192fa9e4066Sahrens {
193fa9e4066Sahrens 	/*
194fa9e4066Sahrens 	 * For index types (compression and checksum), we want the numeric value
195fa9e4066Sahrens 	 * in the kernel, but the string value in userland.  The kernel will
196fa9e4066Sahrens 	 * call zfs_prop_default_numeric() based on the property type.  In
197fa9e4066Sahrens 	 * userland, the zfs_prop_is_string() will return TRUE for index types,
198fa9e4066Sahrens 	 * and we'll return "on" from this function.
199fa9e4066Sahrens 	 */
200fa9e4066Sahrens 	if (zfs_prop_table[prop].pd_proptype == prop_type_index)
201fa9e4066Sahrens 		(void) strncpy(buf, "on", buflen);
202fa9e4066Sahrens 	else
203fa9e4066Sahrens 		(void) strncpy(buf, zfs_prop_table[prop].pd_strdefault, buflen);
204fa9e4066Sahrens }
205fa9e4066Sahrens 
206fa9e4066Sahrens uint64_t
207fa9e4066Sahrens zfs_prop_default_numeric(zfs_prop_t prop)
208fa9e4066Sahrens {
209fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_numdefault);
210fa9e4066Sahrens }
211fa9e4066Sahrens 
212fa9e4066Sahrens /*
213fa9e4066Sahrens  * Returns TRUE if the property is readonly.
214fa9e4066Sahrens  */
215fa9e4066Sahrens int
216fa9e4066Sahrens zfs_prop_readonly(zfs_prop_t prop)
217fa9e4066Sahrens {
218fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_attr == prop_readonly);
219fa9e4066Sahrens }
220fa9e4066Sahrens 
221fa9e4066Sahrens #ifndef _KERNEL
222fa9e4066Sahrens /*
223fa9e4066Sahrens  * Given a property ID, returns the corresponding name.
224fa9e4066Sahrens  */
225fa9e4066Sahrens const char *
226fa9e4066Sahrens zfs_prop_to_name(zfs_prop_t prop)
227fa9e4066Sahrens {
228fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_name);
229fa9e4066Sahrens }
230fa9e4066Sahrens 
231fa9e4066Sahrens /*
232fa9e4066Sahrens  * Returns TRUE if the property is inheritable.
233fa9e4066Sahrens  */
234fa9e4066Sahrens int
235fa9e4066Sahrens zfs_prop_inheritable(zfs_prop_t prop)
236fa9e4066Sahrens {
237fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_attr == prop_inherit);
238fa9e4066Sahrens }
239fa9e4066Sahrens 
240fa9e4066Sahrens /*
241fa9e4066Sahrens  * Returns TRUE if the property applies to the given dataset types.
242fa9e4066Sahrens  */
243fa9e4066Sahrens int
244fa9e4066Sahrens zfs_prop_valid_for_type(zfs_prop_t prop, int types)
245fa9e4066Sahrens {
246fa9e4066Sahrens 	return ((zfs_prop_table[prop].pd_types & types) != 0);
247fa9e4066Sahrens }
248fa9e4066Sahrens 
249fa9e4066Sahrens /*
250fa9e4066Sahrens  * Returns a string describing the set of acceptable values for the given
251fa9e4066Sahrens  * property, or NULL if it cannot be set.
252fa9e4066Sahrens  */
253fa9e4066Sahrens const char *
254fa9e4066Sahrens zfs_prop_values(zfs_prop_t prop)
255fa9e4066Sahrens {
256fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_values);
257fa9e4066Sahrens }
258fa9e4066Sahrens 
259fa9e4066Sahrens /*
260fa9e4066Sahrens  * Returns TRUE if this property is a string type.  Note that index types
261fa9e4066Sahrens  * (compression, checksum) are treated as strings in userland, even though they
262fa9e4066Sahrens  * are stored numerically on disk.
263fa9e4066Sahrens  */
264fa9e4066Sahrens int
265fa9e4066Sahrens zfs_prop_is_string(zfs_prop_t prop)
266fa9e4066Sahrens {
267fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_proptype == prop_type_string ||
268fa9e4066Sahrens 	    zfs_prop_table[prop].pd_proptype == prop_type_index);
269fa9e4066Sahrens }
270fa9e4066Sahrens 
271fa9e4066Sahrens /*
272fa9e4066Sahrens  * Returns the column header for the given property.  Used only in
273fa9e4066Sahrens  * 'zfs list -o', but centralized here with the other property information.
274fa9e4066Sahrens  */
275fa9e4066Sahrens const char *
276fa9e4066Sahrens zfs_prop_column_name(zfs_prop_t prop)
277fa9e4066Sahrens {
278fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_colname);
279fa9e4066Sahrens }
280fa9e4066Sahrens 
281fa9e4066Sahrens /*
282fa9e4066Sahrens  * Returns the column formatting for the given property.  Used only in
283fa9e4066Sahrens  * 'zfs list -o', but centralized here with the other property information.
284fa9e4066Sahrens  */
285fa9e4066Sahrens const char *
286fa9e4066Sahrens zfs_prop_column_format(zfs_prop_t prop)
287fa9e4066Sahrens {
288fa9e4066Sahrens 	return (zfs_prop_table[prop].pd_colfmt);
289fa9e4066Sahrens }
290fa9e4066Sahrens 
291fa9e4066Sahrens /*
292*07ba0419Seschrock  * Given a comma-separated list of fields, fills in the specified array with a
293*07ba0419Seschrock  * list of properties.  The keyword "all" can be used to specify all properties.
294*07ba0419Seschrock  * The 'count' parameter returns the number of matching properties placed into
295*07ba0419Seschrock  * the list.  The 'props' parameter must point to an array of at least
296*07ba0419Seschrock  * ZFS_NPROP_ALL elements.
297fa9e4066Sahrens  */
298*07ba0419Seschrock int
299*07ba0419Seschrock zfs_get_proplist(char *fields, zfs_prop_t *props, int max,
300*07ba0419Seschrock     int *count, char **badopt)
301fa9e4066Sahrens {
302fa9e4066Sahrens 	int i;
303*07ba0419Seschrock 	size_t len;
304*07ba0419Seschrock 	char *s, *p;
305fa9e4066Sahrens 
306*07ba0419Seschrock 	*count = 0;
307fa9e4066Sahrens 
308*07ba0419Seschrock 	/*
309*07ba0419Seschrock 	 * Check for the special value "all", which indicates all properties
310*07ba0419Seschrock 	 * should be displayed.
311*07ba0419Seschrock 	 */
312*07ba0419Seschrock 	if (strcmp(fields, "all") == 0) {
313*07ba0419Seschrock 		if (max < ZFS_NPROP_VISIBLE)
314*07ba0419Seschrock 			return (EOVERFLOW);
315fa9e4066Sahrens 
316*07ba0419Seschrock 		for (i = 0; i < ZFS_NPROP_VISIBLE; i++)
317*07ba0419Seschrock 			props[i] = i;
318*07ba0419Seschrock 		*count = ZFS_NPROP_VISIBLE;
319*07ba0419Seschrock 		return (0);
320fa9e4066Sahrens 	}
321fa9e4066Sahrens 
322fa9e4066Sahrens 	/*
323*07ba0419Seschrock 	 * It would be nice to use getsubopt() here, but the inclusion of column
324*07ba0419Seschrock 	 * aliases makes this more effort than it's worth.
325fa9e4066Sahrens 	 */
326*07ba0419Seschrock 	s = fields;
327*07ba0419Seschrock 	while (*s != '\0') {
328*07ba0419Seschrock 		if ((p = strchr(s, ',')) == NULL) {
329*07ba0419Seschrock 			len = strlen(s);
330*07ba0419Seschrock 			p = s + len;
331fa9e4066Sahrens 		} else {
332*07ba0419Seschrock 			len = p - s;
333*07ba0419Seschrock 		}
334*07ba0419Seschrock 
335*07ba0419Seschrock 		/*
336*07ba0419Seschrock 		 * Check for empty options.
337*07ba0419Seschrock 		 */
338*07ba0419Seschrock 		if (len == 0) {
339*07ba0419Seschrock 			*badopt = "";
340*07ba0419Seschrock 			return (EINVAL);
341*07ba0419Seschrock 		}
342*07ba0419Seschrock 
343*07ba0419Seschrock 		/*
344*07ba0419Seschrock 		 * Check all regular property names.
345*07ba0419Seschrock 		 */
346*07ba0419Seschrock 		for (i = 0; i < ZFS_NPROP_ALL; i++) {
347*07ba0419Seschrock 			if (zfs_prop_table[i].pd_colname == NULL)
348*07ba0419Seschrock 				continue;
349*07ba0419Seschrock 
350*07ba0419Seschrock 			if (len == strlen(zfs_prop_table[i].pd_name) &&
351*07ba0419Seschrock 			    strncmp(s, zfs_prop_table[i].pd_name, len) == 0)
352*07ba0419Seschrock 				break;
353*07ba0419Seschrock 		}
354*07ba0419Seschrock 
355*07ba0419Seschrock 		/*
356*07ba0419Seschrock 		 * Check all abbreviated column names.
357*07ba0419Seschrock 		 */
358*07ba0419Seschrock 		if (i == ZFS_NPROP_ALL) {
359*07ba0419Seschrock 			for (i = 0; i < ZFS_NPROP_ALL; i++) {
360*07ba0419Seschrock 				if (zfs_prop_table[i].pd_colname == NULL)
361*07ba0419Seschrock 					continue;
362*07ba0419Seschrock 
363*07ba0419Seschrock 				if (len ==
364*07ba0419Seschrock 				    strlen(zfs_prop_table[i].pd_colname) &&
365*07ba0419Seschrock 				    strncasecmp(s, zfs_prop_table[i].pd_colname,
366*07ba0419Seschrock 				    len) == 0)
367*07ba0419Seschrock 					break;
368fa9e4066Sahrens 			}
369fa9e4066Sahrens 		}
370fa9e4066Sahrens 
371*07ba0419Seschrock 		/*
372*07ba0419Seschrock 		 * If no column is specified, then return failure, setting
373*07ba0419Seschrock 		 * 'badopt' to point to the invalid option.
374*07ba0419Seschrock 		 */
375*07ba0419Seschrock 		if (i == ZFS_NPROP_ALL) {
376*07ba0419Seschrock 			s[len] = '\0';
377*07ba0419Seschrock 			*badopt = s;
378*07ba0419Seschrock 			return (EINVAL);
379*07ba0419Seschrock 		}
380fa9e4066Sahrens 
381*07ba0419Seschrock 		/*
382*07ba0419Seschrock 		 * If the user specified too many options (by using the same one
383*07ba0419Seschrock 		 * multiple times). return an error with 'badopt' set to NULL to
384*07ba0419Seschrock 		 * indicate this condition.
385*07ba0419Seschrock 		 */
386*07ba0419Seschrock 		if (*count == max)
387*07ba0419Seschrock 			return (EOVERFLOW);
388fa9e4066Sahrens 
389*07ba0419Seschrock 		props[*count] = i;
390*07ba0419Seschrock 		*count += 1;
391*07ba0419Seschrock 
392*07ba0419Seschrock 		s = p;
393*07ba0419Seschrock 		if (*s == ',')
394*07ba0419Seschrock 			s++;
395*07ba0419Seschrock 	}
396*07ba0419Seschrock 
397*07ba0419Seschrock 	/*
398*07ba0419Seschrock 	 * If no fields were specified, return an error.
399*07ba0419Seschrock 	 */
400*07ba0419Seschrock 	if (*count == 0) {
401*07ba0419Seschrock 		*badopt = "";
402*07ba0419Seschrock 		return (EINVAL);
403*07ba0419Seschrock 	}
404*07ba0419Seschrock 
405*07ba0419Seschrock 	return (0);
406fa9e4066Sahrens }
407fa9e4066Sahrens 
408fa9e4066Sahrens #endif
409