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 /*
27 * Common routines used by zfs and zpool property management.
28 */
29
30 #include <sys/zio.h>
31 #include <sys/spa.h>
32 #include <sys/zfs_acl.h>
33 #include <sys/zfs_ioctl.h>
34 #include <sys/zfs_znode.h>
35 #include <sys/fs/zfs.h>
36
37 #include "zfs_prop.h"
38 #include "zfs_deleg.h"
39
40 #if defined(_KERNEL)
41 #include <sys/systm.h>
42 #include <util/qsort.h>
43 #else
44 #include <stdlib.h>
112 const char *colname)
113 {
114 zprop_register_impl(prop, name, PROP_TYPE_NUMBER, def, NULL, attr,
115 objset_types, values, colname, B_TRUE, B_TRUE, NULL);
116 }
117
118 void
119 zprop_register_index(int prop, const char *name, uint64_t def,
120 zprop_attr_t attr, int objset_types, const char *values,
121 const char *colname, const zprop_index_t *idx_tbl)
122 {
123 zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr,
124 objset_types, values, colname, B_TRUE, B_TRUE, idx_tbl);
125 }
126
127 void
128 zprop_register_hidden(int prop, const char *name, zprop_type_t type,
129 zprop_attr_t attr, int objset_types, const char *colname)
130 {
131 zprop_register_impl(prop, name, type, 0, NULL, attr,
132 objset_types, NULL, colname, B_FALSE, B_FALSE, NULL);
133 }
134
135
136 /*
137 * A comparison function we can use to order indexes into property tables.
138 */
139 static int
140 zprop_compare(const void *arg1, const void *arg2)
141 {
142 const zprop_desc_t *p1 = *((zprop_desc_t **)arg1);
143 const zprop_desc_t *p2 = *((zprop_desc_t **)arg2);
144 boolean_t p1ro, p2ro;
145
146 p1ro = (p1->pd_attr == PROP_READONLY);
147 p2ro = (p2->pd_attr == PROP_READONLY);
148
149 if (p1ro == p2ro)
150 return (strcmp(p1->pd_name, p2->pd_name));
151
152 return (p1ro ? -1 : 1);
|
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 * Copyright (c) 2012 by Delphix. All rights reserved.
27 */
28
29 /*
30 * Common routines used by zfs and zpool property management.
31 */
32
33 #include <sys/zio.h>
34 #include <sys/spa.h>
35 #include <sys/zfs_acl.h>
36 #include <sys/zfs_ioctl.h>
37 #include <sys/zfs_znode.h>
38 #include <sys/fs/zfs.h>
39
40 #include "zfs_prop.h"
41 #include "zfs_deleg.h"
42
43 #if defined(_KERNEL)
44 #include <sys/systm.h>
45 #include <util/qsort.h>
46 #else
47 #include <stdlib.h>
115 const char *colname)
116 {
117 zprop_register_impl(prop, name, PROP_TYPE_NUMBER, def, NULL, attr,
118 objset_types, values, colname, B_TRUE, B_TRUE, NULL);
119 }
120
121 void
122 zprop_register_index(int prop, const char *name, uint64_t def,
123 zprop_attr_t attr, int objset_types, const char *values,
124 const char *colname, const zprop_index_t *idx_tbl)
125 {
126 zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr,
127 objset_types, values, colname, B_TRUE, B_TRUE, idx_tbl);
128 }
129
130 void
131 zprop_register_hidden(int prop, const char *name, zprop_type_t type,
132 zprop_attr_t attr, int objset_types, const char *colname)
133 {
134 zprop_register_impl(prop, name, type, 0, NULL, attr,
135 objset_types, NULL, colname,
136 type == PROP_TYPE_NUMBER, B_FALSE, NULL);
137 }
138
139
140 /*
141 * A comparison function we can use to order indexes into property tables.
142 */
143 static int
144 zprop_compare(const void *arg1, const void *arg2)
145 {
146 const zprop_desc_t *p1 = *((zprop_desc_t **)arg1);
147 const zprop_desc_t *p2 = *((zprop_desc_t **)arg2);
148 boolean_t p1ro, p2ro;
149
150 p1ro = (p1->pd_attr == PROP_READONLY);
151 p2ro = (p2->pd_attr == PROP_READONLY);
152
153 if (p1ro == p2ro)
154 return (strcmp(p1->pd_name, p2->pd_name));
155
156 return (p1ro ? -1 : 1);
|