Deleted Added
full compact
zfs_prop.c (201143) zfs_prop.c (209962)
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

--- 5 unchanged lines hidden (view full) ---

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/*
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

--- 5 unchanged lines hidden (view full) ---

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 2008 Sun Microsystems, Inc. All rights reserved.
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>

--- 7 unchanged lines hidden (view full) ---

38#else
39#include <stdlib.h>
40#include <string.h>
41#include <ctype.h>
42#endif
43
44static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
45
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>

--- 7 unchanged lines hidden (view full) ---

38#else
39#include <stdlib.h>
40#include <string.h>
41#include <ctype.h>
42#endif
43
44static 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 */
47const char *zfs_userquota_prop_prefixes[] = {
48 "userused@",
49 "userquota@",
50 "groupused@",
51 "groupquota@"
52};
53
46zprop_desc_t *
47zfs_prop_get_table(void)
48{
49 return (zfs_prop_table);
50}
51
52void
53zfs_prop_init(void)

--- 74 unchanged lines hidden (view full) ---

128 { "formKD", U8_TEXTPREP_NFKD },
129 { NULL }
130 };
131
132 static zprop_index_t version_table[] = {
133 { "1", 1 },
134 { "2", 2 },
135 { "3", 3 },
54zprop_desc_t *
55zfs_prop_get_table(void)
56{
57 return (zfs_prop_table);
58}
59
60void
61zfs_prop_init(void)

--- 74 unchanged lines hidden (view full) ---

136 { "formKD", U8_TEXTPREP_NFKD },
137 { NULL }
138 };
139
140 static zprop_index_t version_table[] = {
141 { "1", 1 },
142 { "2", 2 },
143 { "3", 3 },
144 { "4", 4 },
136 { "current", ZPL_VERSION },
137 { NULL }
138 };
139
140 static zprop_index_t boolean_table[] = {
141 { "off", 0 },
142 { "on", 1 },
143 { NULL }

--- 69 unchanged lines hidden (view full) ---

213 boolean_table);
214 register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
215 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
216 boolean_table);
217
218 /* default index properties */
219 register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
220 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
145 { "current", ZPL_VERSION },
146 { NULL }
147 };
148
149 static zprop_index_t boolean_table[] = {
150 { "off", 0 },
151 { "on", 1 },
152 { NULL }

--- 69 unchanged lines hidden (view full) ---

222 boolean_table);
223 register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
224 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
225 boolean_table);
226
227 /* default index properties */
228 register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
229 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
221 "1 | 2 | 3 | current", "VERSION", version_table);
230 "1 | 2 | 3 | 4 | current", "VERSION", version_table);
222 register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
223 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
224 "CANMOUNT", canmount_table);
225
226 /* readonly index (boolean) properties */
227 register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
228 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
229

--- 72 unchanged lines hidden (view full) ---

302 register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
303 PROP_READONLY, ZFS_TYPE_SNAPSHOT, NULL);
304 register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
305 PROP_READONLY, ZFS_TYPE_DATASET, "NAME");
306 register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING,
307 PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
308 register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY,
309 ZFS_TYPE_DATASET, "GUID");
231 register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
232 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
233 "CANMOUNT", canmount_table);
234
235 /* readonly index (boolean) properties */
236 register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
237 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
238

--- 72 unchanged lines hidden (view full) ---

311 register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
312 PROP_READONLY, ZFS_TYPE_SNAPSHOT, NULL);
313 register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
314 PROP_READONLY, ZFS_TYPE_DATASET, "NAME");
315 register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING,
316 PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
317 register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY,
318 ZFS_TYPE_DATASET, "GUID");
319 register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
320 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, NULL);
310
311 /* oddball properties */
312 register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL,
313 PROP_READONLY, ZFS_TYPE_DATASET,
314 "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
315}
316
317boolean_t

--- 7 unchanged lines hidden (view full) ---

325 * Given a zfs dataset property name, returns the corresponding property ID.
326 */
327zfs_prop_t
328zfs_name_to_prop(const char *propname)
329{
330 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
331}
332
321
322 /* oddball properties */
323 register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL,
324 PROP_READONLY, ZFS_TYPE_DATASET,
325 "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
326}
327
328boolean_t

--- 7 unchanged lines hidden (view full) ---

336 * Given a zfs dataset property name, returns the corresponding property ID.
337 */
338zfs_prop_t
339zfs_name_to_prop(const char *propname)
340{
341 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
342}
343
333
334/*
335 * For user property names, we allow all lowercase alphanumeric characters, plus
336 * a few useful punctuation characters.
337 */
338static int
339valid_char(char c)
340{
341 return ((c >= 'a' && c <= 'z') ||

--- 21 unchanged lines hidden (view full) ---

363
364 if (!foundsep)
365 return (B_FALSE);
366
367 return (B_TRUE);
368}
369
370/*
344/*
345 * For user property names, we allow all lowercase alphanumeric characters, plus
346 * a few useful punctuation characters.
347 */
348static int
349valid_char(char c)
350{
351 return ((c >= 'a' && c <= 'z') ||

--- 21 unchanged lines hidden (view full) ---

373
374 if (!foundsep)
375 return (B_FALSE);
376
377 return (B_TRUE);
378}
379
380/*
381 * Returns true if this is a valid userspace-type property (one with a '@').
382 * Note that after the @, any character is valid (eg, another @, for SID
383 * user@domain).
384 */
385boolean_t
386zfs_prop_userquota(const char *name)
387{
388 zfs_userquota_prop_t prop;
389
390 for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
391 if (strncmp(name, zfs_userquota_prop_prefixes[prop],
392 strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
393 return (B_TRUE);
394 }
395 }
396
397 return (B_FALSE);
398}
399
400/*
371 * Tables of index types, plus functions to convert between the user view
372 * (strings) and internal representation (uint64_t).
373 */
374int
375zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
376{
377 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
378}

--- 118 unchanged lines hidden ---
401 * Tables of index types, plus functions to convert between the user view
402 * (strings) and internal representation (uint64_t).
403 */
404int
405zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
406{
407 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
408}

--- 118 unchanged lines hidden ---