author | Mark Shellenbaum <Mark.Shellenbaum@Sun.COM> |
Mon, 10 Nov 2008 08:00:08 -0700 | |
changeset 8053 | 271f44d3de11 |
parent 7390 | 6d408f0a5fbd |
child 9396 | f41cf682d0d3 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1638
52000886673f
6399899 change the default value of snapdir property to "hidden"
lling
parents:
1356
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
52000886673f
6399899 change the default value of snapdir property to "hidden"
lling
parents:
1356
diff
changeset
|
6 |
* You may not use this file except in compliance with the License. |
789 | 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 |
/* |
|
6168
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
22 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <sys/zio.h> |
|
27 |
#include <sys/spa.h> |
|
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
28 |
#include <sys/u8_textprep.h> |
789 | 29 |
#include <sys/zfs_acl.h> |
30 |
#include <sys/zfs_ioctl.h> |
|
4577 | 31 |
#include <sys/zfs_znode.h> |
789 | 32 |
|
33 |
#include "zfs_prop.h" |
|
4543 | 34 |
#include "zfs_deleg.h" |
789 | 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 |
||
5094 | 44 |
static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; |
4787 | 45 |
|
5094 | 46 |
zprop_desc_t * |
47 |
zfs_prop_get_table(void) |
|
4787 | 48 |
{ |
5094 | 49 |
return (zfs_prop_table); |
4787 | 50 |
} |
51 |
||
52 |
void |
|
53 |
zfs_prop_init(void) |
|
54 |
{ |
|
5094 | 55 |
static zprop_index_t checksum_table[] = { |
4787 | 56 |
{ "on", ZIO_CHECKSUM_ON }, |
57 |
{ "off", ZIO_CHECKSUM_OFF }, |
|
58 |
{ "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, |
|
59 |
{ "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, |
|
60 |
{ "sha256", ZIO_CHECKSUM_SHA256 }, |
|
61 |
{ NULL } |
|
62 |
}; |
|
63 |
||
5094 | 64 |
static zprop_index_t compress_table[] = { |
4787 | 65 |
{ "on", ZIO_COMPRESS_ON }, |
66 |
{ "off", ZIO_COMPRESS_OFF }, |
|
67 |
{ "lzjb", ZIO_COMPRESS_LZJB }, |
|
68 |
{ "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ |
|
69 |
{ "gzip-1", ZIO_COMPRESS_GZIP_1 }, |
|
70 |
{ "gzip-2", ZIO_COMPRESS_GZIP_2 }, |
|
71 |
{ "gzip-3", ZIO_COMPRESS_GZIP_3 }, |
|
72 |
{ "gzip-4", ZIO_COMPRESS_GZIP_4 }, |
|
73 |
{ "gzip-5", ZIO_COMPRESS_GZIP_5 }, |
|
74 |
{ "gzip-6", ZIO_COMPRESS_GZIP_6 }, |
|
75 |
{ "gzip-7", ZIO_COMPRESS_GZIP_7 }, |
|
76 |
{ "gzip-8", ZIO_COMPRESS_GZIP_8 }, |
|
77 |
{ "gzip-9", ZIO_COMPRESS_GZIP_9 }, |
|
78 |
{ NULL } |
|
79 |
}; |
|
80 |
||
5094 | 81 |
static zprop_index_t snapdir_table[] = { |
4787 | 82 |
{ "hidden", ZFS_SNAPDIR_HIDDEN }, |
83 |
{ "visible", ZFS_SNAPDIR_VISIBLE }, |
|
84 |
{ NULL } |
|
85 |
}; |
|
86 |
||
5094 | 87 |
static zprop_index_t acl_mode_table[] = { |
4787 | 88 |
{ "discard", ZFS_ACL_DISCARD }, |
89 |
{ "groupmask", ZFS_ACL_GROUPMASK }, |
|
90 |
{ "passthrough", ZFS_ACL_PASSTHROUGH }, |
|
91 |
{ NULL } |
|
92 |
}; |
|
93 |
||
5094 | 94 |
static zprop_index_t acl_inherit_table[] = { |
4787 | 95 |
{ "discard", ZFS_ACL_DISCARD }, |
96 |
{ "noallow", ZFS_ACL_NOALLOW }, |
|
6385
5437941ec5a1
PSARC/2008/231 New ZFS "passthrough" ACL inheritance rules
marks
parents:
6168
diff
changeset
|
97 |
{ "restricted", ZFS_ACL_RESTRICTED }, |
4787 | 98 |
{ "passthrough", ZFS_ACL_PASSTHROUGH }, |
6385
5437941ec5a1
PSARC/2008/231 New ZFS "passthrough" ACL inheritance rules
marks
parents:
6168
diff
changeset
|
99 |
{ "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatability */ |
8053
271f44d3de11
PSARC/2008/659 New ZFS "passthrough-x" ACL inheritance rules
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
7390
diff
changeset
|
100 |
{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X }, |
4787 | 101 |
{ NULL } |
102 |
}; |
|
103 |
||
5331 | 104 |
static zprop_index_t case_table[] = { |
105 |
{ "sensitive", ZFS_CASE_SENSITIVE }, |
|
106 |
{ "insensitive", ZFS_CASE_INSENSITIVE }, |
|
107 |
{ "mixed", ZFS_CASE_MIXED }, |
|
108 |
{ NULL } |
|
109 |
}; |
|
110 |
||
5094 | 111 |
static zprop_index_t copies_table[] = { |
4787 | 112 |
{ "1", 1 }, |
113 |
{ "2", 2 }, |
|
114 |
{ "3", 3 }, |
|
115 |
{ NULL } |
|
116 |
}; |
|
117 |
||
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
118 |
/* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
119 |
* Use the unique flags we have to send to u8_strcmp() and/or |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
120 |
* u8_textprep() to represent the various normalization property |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
121 |
* values. |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
122 |
*/ |
5331 | 123 |
static zprop_index_t normalize_table[] = { |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
124 |
{ "none", 0 }, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
125 |
{ "formD", U8_TEXTPREP_NFD }, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
126 |
{ "formKC", U8_TEXTPREP_NFKC }, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
127 |
{ "formC", U8_TEXTPREP_NFC }, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
128 |
{ "formKD", U8_TEXTPREP_NFKD }, |
5331 | 129 |
{ NULL } |
130 |
}; |
|
131 |
||
5094 | 132 |
static zprop_index_t version_table[] = { |
4787 | 133 |
{ "1", 1 }, |
134 |
{ "2", 2 }, |
|
5331 | 135 |
{ "3", 3 }, |
4787 | 136 |
{ "current", ZPL_VERSION }, |
137 |
{ NULL } |
|
138 |
}; |
|
139 |
||
5094 | 140 |
static zprop_index_t boolean_table[] = { |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
141 |
{ "off", 0 }, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
142 |
{ "on", 1 }, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
143 |
{ NULL } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
144 |
}; |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
145 |
|
6168
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
146 |
static zprop_index_t canmount_table[] = { |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
147 |
{ "off", ZFS_CANMOUNT_OFF }, |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
148 |
{ "on", ZFS_CANMOUNT_ON }, |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
149 |
{ "noauto", ZFS_CANMOUNT_NOAUTO }, |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
150 |
{ NULL } |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
151 |
}; |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
152 |
|
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
153 |
static zprop_index_t cache_table[] = { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
154 |
{ "none", ZFS_CACHE_NONE }, |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
155 |
{ "metadata", ZFS_CACHE_METADATA }, |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
156 |
{ "all", ZFS_CACHE_ALL }, |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
157 |
{ NULL } |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
158 |
}; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
159 |
|
4787 | 160 |
/* inherit index properties */ |
161 |
register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT, |
|
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
162 |
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, |
4787 | 163 |
"on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM", |
164 |
checksum_table); |
|
165 |
register_index(ZFS_PROP_COMPRESSION, "compression", |
|
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
166 |
ZIO_COMPRESS_DEFAULT, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
167 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, |
4787 | 168 |
"on | off | lzjb | gzip | gzip-[1-9]", "COMPRESS", compress_table); |
169 |
register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, |
|
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
170 |
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
171 |
"hidden | visible", "SNAPDIR", snapdir_table); |
4787 | 172 |
register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_GROUPMASK, |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
173 |
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, |
5094 | 174 |
"discard | groupmask | passthrough", "ACLMODE", acl_mode_table); |
6385
5437941ec5a1
PSARC/2008/231 New ZFS "passthrough" ACL inheritance rules
marks
parents:
6168
diff
changeset
|
175 |
register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_RESTRICTED, |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
176 |
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, |
8053
271f44d3de11
PSARC/2008/659 New ZFS "passthrough-x" ACL inheritance rules
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
7390
diff
changeset
|
177 |
"discard | noallow | restricted | passthrough | passthrough-x", |
6385
5437941ec5a1
PSARC/2008/231 New ZFS "passthrough" ACL inheritance rules
marks
parents:
6168
diff
changeset
|
178 |
"ACLINHERIT", acl_inherit_table); |
4787 | 179 |
register_index(ZFS_PROP_COPIES, "copies", 1, |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
180 |
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, |
4787 | 181 |
"1 | 2 | 3", "COPIES", copies_table); |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
182 |
register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
183 |
ZFS_CACHE_ALL, PROP_INHERIT, |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
184 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
185 |
"all | none | metadata", "PRIMARYCACHE", cache_table); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
186 |
register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
187 |
ZFS_CACHE_ALL, PROP_INHERIT, |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
188 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
6690
diff
changeset
|
189 |
"all | none | metadata", "SECONDARYCACHE", cache_table); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
190 |
|
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
191 |
/* inherit index (boolean) properties */ |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
192 |
register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
193 |
ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
194 |
register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
195 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
196 |
boolean_table); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
197 |
register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
198 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
199 |
boolean_table); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
200 |
register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
201 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
202 |
boolean_table); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
203 |
register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
204 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
205 |
boolean_table); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
206 |
register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
207 |
ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
208 |
register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT, |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
209 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR", |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
210 |
boolean_table); |
5331 | 211 |
register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, |
212 |
ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", |
|
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); |
|
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
217 |
|
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
218 |
/* default index properties */ |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
219 |
register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, |
2597 | 220 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, |
5331 | 221 |
"1 | 2 | 3 | current", "VERSION", version_table); |
6168
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
222 |
register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
223 |
PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", |
51c045dcc498
PSARC 2008/168 Support for ZFS property value canmount=noauto
hs24103
parents:
5498
diff
changeset
|
224 |
"CANMOUNT", canmount_table); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
225 |
|
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
226 |
/* readonly index (boolean) properties */ |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
227 |
register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, |
5094 | 228 |
ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4787
diff
changeset
|
229 |
|
5331 | 230 |
/* set once index properties */ |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5378
diff
changeset
|
231 |
register_index(ZFS_PROP_NORMALIZE, "normalization", 0, |
5331 | 232 |
PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, |
233 |
"none | formC | formD | formKC | formKD", "NORMALIZATION", |
|
234 |
normalize_table); |
|
235 |
register_index(ZFS_PROP_CASE, "casesensitivity", ZFS_CASE_SENSITIVE, |
|
236 |
PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, |
|
237 |
"sensitive | insensitive | mixed", "CASE", case_table); |
|
238 |
||
239 |
/* set once index (boolean) properties */ |
|
240 |
register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, |
|
241 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, |
|
242 |
"on | off", "UTF8ONLY", boolean_table); |
|
243 |
||
4787 | 244 |
/* string properties */ |
245 |
register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, |
|
246 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN"); |
|
247 |
register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT, |
|
248 |
ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", "MOUNTPOINT"); |
|
249 |
register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT, |
|
250 |
ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", "SHARENFS"); |
|
251 |
register_string(ZFS_PROP_SHAREISCSI, "shareiscsi", "off", PROP_INHERIT, |
|
5094 | 252 |
ZFS_TYPE_DATASET, "on | off | type=<type>", "SHAREISCSI"); |
4787 | 253 |
register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, |
5094 | 254 |
ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE"); |
5331 | 255 |
register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", PROP_INHERIT, |
256 |
ZFS_TYPE_FILESYSTEM, "on | off | sharemgr(1M) options", "SHARESMB"); |
|
4787 | 257 |
|
258 |
/* readonly number properties */ |
|
259 |
register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, |
|
5094 | 260 |
ZFS_TYPE_DATASET, "<size>", "USED"); |
4787 | 261 |
register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, |
5094 | 262 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL"); |
4787 | 263 |
register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY, |
5094 | 264 |
ZFS_TYPE_DATASET, "<size>", "REFER"); |
4787 | 265 |
register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, |
5094 | 266 |
PROP_READONLY, ZFS_TYPE_DATASET, |
4787 | 267 |
"<1.00x or higher if compressed>", "RATIO"); |
268 |
register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 8192, |
|
5331 | 269 |
PROP_ONETIME, |
270 |
ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK"); |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
271 |
register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, PROP_READONLY, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
272 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDSNAP"); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
273 |
register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, PROP_READONLY, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
274 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDDS"); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
275 |
register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, PROP_READONLY, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
276 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDCHILD"); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
277 |
register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
278 |
PROP_READONLY, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7237
diff
changeset
|
279 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV"); |
4787 | 280 |
|
281 |
/* default number properties */ |
|
282 |
register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, |
|
283 |
ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA"); |
|
284 |
register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT, |
|
285 |
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size> | none", "RESERV"); |
|
286 |
register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, |
|
287 |
ZFS_TYPE_VOLUME, "<size>", "VOLSIZE"); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5331
diff
changeset
|
288 |
register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5331
diff
changeset
|
289 |
ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA"); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5331
diff
changeset
|
290 |
register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5331
diff
changeset
|
291 |
PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5331
diff
changeset
|
292 |
"<size> | none", "REFRESERV"); |
4787 | 293 |
|
294 |
/* inherit number properties */ |
|
295 |
register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_MAXBLOCKSIZE, |
|
296 |
PROP_INHERIT, |
|
297 |
ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE"); |
|
298 |
||
299 |
/* hidden properties */ |
|
300 |
register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER, |
|
5094 | 301 |
PROP_READONLY, ZFS_TYPE_DATASET, NULL); |
4787 | 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, |
|
5094 | 305 |
PROP_READONLY, ZFS_TYPE_DATASET, "NAME"); |
4787 | 306 |
register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING, |
307 |
PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); |
|
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6385
diff
changeset
|
308 |
register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY, |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6385
diff
changeset
|
309 |
ZFS_TYPE_DATASET, "GUID"); |
4787 | 310 |
|
311 |
/* oddball properties */ |
|
312 |
register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL, |
|
5094 | 313 |
PROP_READONLY, ZFS_TYPE_DATASET, |
4787 | 314 |
"<date>", "CREATION", B_FALSE, B_TRUE, NULL); |
315 |
} |
|
316 |
||
3912 | 317 |
boolean_t |
5094 | 318 |
zfs_prop_delegatable(zfs_prop_t prop) |
3912 | 319 |
{ |
5094 | 320 |
zprop_desc_t *pd = &zfs_prop_table[prop]; |
321 |
return (pd->pd_attr != PROP_READONLY); |
|
3912 | 322 |
} |
323 |
||
324 |
/* |
|
325 |
* Given a zfs dataset property name, returns the corresponding property ID. |
|
789 | 326 |
*/ |
327 |
zfs_prop_t |
|
328 |
zfs_name_to_prop(const char *propname) |
|
329 |
{ |
|
5094 | 330 |
return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); |
3912 | 331 |
} |
789 | 332 |
|
4543 | 333 |
|
789 | 334 |
/* |
2676 | 335 |
* For user property names, we allow all lowercase alphanumeric characters, plus |
336 |
* a few useful punctuation characters. |
|
337 |
*/ |
|
338 |
static int |
|
339 |
valid_char(char c) |
|
340 |
{ |
|
341 |
return ((c >= 'a' && c <= 'z') || |
|
342 |
(c >= '0' && c <= '9') || |
|
343 |
c == '-' || c == '_' || c == '.' || c == ':'); |
|
344 |
} |
|
345 |
||
346 |
/* |
|
347 |
* Returns true if this is a valid user-defined property (one with a ':'). |
|
348 |
*/ |
|
349 |
boolean_t |
|
350 |
zfs_prop_user(const char *name) |
|
351 |
{ |
|
352 |
int i; |
|
353 |
char c; |
|
354 |
boolean_t foundsep = B_FALSE; |
|
355 |
||
356 |
for (i = 0; i < strlen(name); i++) { |
|
357 |
c = name[i]; |
|
358 |
if (!valid_char(c)) |
|
359 |
return (B_FALSE); |
|
360 |
if (c == ':') |
|
361 |
foundsep = B_TRUE; |
|
362 |
} |
|
363 |
||
364 |
if (!foundsep) |
|
365 |
return (B_FALSE); |
|
366 |
||
367 |
return (B_TRUE); |
|
368 |
} |
|
369 |
||
370 |
/* |
|
5094 | 371 |
* Tables of index types, plus functions to convert between the user view |
372 |
* (strings) and internal representation (uint64_t). |
|
373 |
*/ |
|
374 |
int |
|
375 |
zfs_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 |
} |
|
379 |
||
380 |
int |
|
381 |
zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) |
|
382 |
{ |
|
383 |
return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); |
|
384 |
} |
|
385 |
||
386 |
/* |
|
387 |
* Returns TRUE if the property applies to any of the given dataset types. |
|
789 | 388 |
*/ |
6690
19b5b95523e1
6695219 Running 'zfs get all' on a snapshot should not display the user properties
gw25295
parents:
6643
diff
changeset
|
389 |
boolean_t |
5094 | 390 |
zfs_prop_valid_for_type(int prop, zfs_type_t types) |
391 |
{ |
|
392 |
return (zprop_valid_for_type(prop, types)); |
|
393 |
} |
|
394 |
||
395 |
zprop_type_t |
|
396 |
zfs_prop_get_type(zfs_prop_t prop) |
|
789 | 397 |
{ |
5094 | 398 |
return (zfs_prop_table[prop].pd_proptype); |
399 |
} |
|
400 |
||
401 |
/* |
|
402 |
* Returns TRUE if the property is readonly. |
|
403 |
*/ |
|
404 |
boolean_t |
|
405 |
zfs_prop_readonly(zfs_prop_t prop) |
|
406 |
{ |
|
5331 | 407 |
return (zfs_prop_table[prop].pd_attr == PROP_READONLY || |
408 |
zfs_prop_table[prop].pd_attr == PROP_ONETIME); |
|
409 |
} |
|
410 |
||
411 |
/* |
|
412 |
* Returns TRUE if the property is only allowed to be set once. |
|
413 |
*/ |
|
414 |
boolean_t |
|
415 |
zfs_prop_setonce(zfs_prop_t prop) |
|
416 |
{ |
|
417 |
return (zfs_prop_table[prop].pd_attr == PROP_ONETIME); |
|
789 | 418 |
} |
419 |
||
4451 | 420 |
const char * |
5094 | 421 |
zfs_prop_default_string(zfs_prop_t prop) |
4451 | 422 |
{ |
423 |
return (zfs_prop_table[prop].pd_strdefault); |
|
424 |
} |
|
425 |
||
789 | 426 |
uint64_t |
427 |
zfs_prop_default_numeric(zfs_prop_t prop) |
|
428 |
{ |
|
429 |
return (zfs_prop_table[prop].pd_numdefault); |
|
430 |
} |
|
431 |
||
432 |
/* |
|
3912 | 433 |
* Given a dataset property ID, returns the corresponding name. |
4451 | 434 |
* Assuming the zfs dataset property ID is valid. |
789 | 435 |
*/ |
436 |
const char * |
|
437 |
zfs_prop_to_name(zfs_prop_t prop) |
|
438 |
{ |
|
439 |
return (zfs_prop_table[prop].pd_name); |
|
440 |
} |
|
441 |
||
442 |
/* |
|
443 |
* Returns TRUE if the property is inheritable. |
|
444 |
*/ |
|
5094 | 445 |
boolean_t |
789 | 446 |
zfs_prop_inheritable(zfs_prop_t prop) |
447 |
{ |
|
5331 | 448 |
return (zfs_prop_table[prop].pd_attr == PROP_INHERIT || |
449 |
zfs_prop_table[prop].pd_attr == PROP_ONETIME); |
|
2676 | 450 |
} |
451 |
||
2717
ed589a32259d
6469385 zfs_set_prop_nvlist range checking is busted
eschrock
parents:
2676
diff
changeset
|
452 |
#ifndef _KERNEL |
ed589a32259d
6469385 zfs_set_prop_nvlist range checking is busted
eschrock
parents:
2676
diff
changeset
|
453 |
|
789 | 454 |
/* |
3912 | 455 |
* Returns a string describing the set of acceptable values for the given |
456 |
* zfs property, or NULL if it cannot be set. |
|
789 | 457 |
*/ |
3912 | 458 |
const char * |
459 |
zfs_prop_values(zfs_prop_t prop) |
|
789 | 460 |
{ |
461 |
return (zfs_prop_table[prop].pd_values); |
|
462 |
} |
|
463 |
||
464 |
/* |
|
465 |
* Returns TRUE if this property is a string type. Note that index types |
|
466 |
* (compression, checksum) are treated as strings in userland, even though they |
|
467 |
* are stored numerically on disk. |
|
468 |
*/ |
|
469 |
int |
|
470 |
zfs_prop_is_string(zfs_prop_t prop) |
|
471 |
{ |
|
4787 | 472 |
return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || |
473 |
zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); |
|
789 | 474 |
} |
475 |
||
476 |
/* |
|
477 |
* Returns the column header for the given property. Used only in |
|
478 |
* 'zfs list -o', but centralized here with the other property information. |
|
479 |
*/ |
|
480 |
const char * |
|
481 |
zfs_prop_column_name(zfs_prop_t prop) |
|
482 |
{ |
|
483 |
return (zfs_prop_table[prop].pd_colname); |
|
484 |
} |
|
485 |
||
486 |
/* |
|
2676 | 487 |
* Returns whether the given property should be displayed right-justified for |
488 |
* 'zfs list'. |
|
789 | 489 |
*/ |
2676 | 490 |
boolean_t |
491 |
zfs_prop_align_right(zfs_prop_t prop) |
|
789 | 492 |
{ |
2676 | 493 |
return (zfs_prop_table[prop].pd_rightalign); |
789 | 494 |
} |
5331 | 495 |
|
789 | 496 |
#endif |