]>
Commit | Line | Data |
---|---|---|
34dc7c2f BB |
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 | /* | |
428870ff | 22 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
d99a0153 | 23 | * Copyright (c) 2011, 2016 by Delphix. All rights reserved. |
632a242e | 24 | * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. |
911c41af | 25 | * Copyright 2016, Joyent, Inc. |
34dc7c2f BB |
26 | */ |
27 | ||
428870ff BB |
28 | /* Portions Copyright 2010 Robert Milkowski */ |
29 | ||
34dc7c2f BB |
30 | #include <sys/zio.h> |
31 | #include <sys/spa.h> | |
32 | #include <sys/u8_textprep.h> | |
33 | #include <sys/zfs_acl.h> | |
34 | #include <sys/zfs_ioctl.h> | |
35 | #include <sys/zfs_znode.h> | |
b5256303 | 36 | #include <sys/dsl_crypt.h> |
34dc7c2f BB |
37 | |
38 | #include "zfs_prop.h" | |
39 | #include "zfs_deleg.h" | |
1eeb4562 | 40 | #include "zfs_fletcher.h" |
34dc7c2f BB |
41 | |
42 | #if defined(_KERNEL) | |
43 | #include <sys/systm.h> | |
44 | #else | |
45 | #include <stdlib.h> | |
46 | #include <string.h> | |
47 | #include <ctype.h> | |
48 | #endif | |
49 | ||
50 | static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; | |
51 | ||
9babb374 BB |
52 | /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */ |
53 | const char *zfs_userquota_prop_prefixes[] = { | |
54 | "userused@", | |
55 | "userquota@", | |
56 | "groupused@", | |
1de321e6 JX |
57 | "groupquota@", |
58 | "userobjused@", | |
59 | "userobjquota@", | |
60 | "groupobjused@", | |
9c5167d1 NF |
61 | "groupobjquota@", |
62 | "projectused@", | |
63 | "projectquota@", | |
64 | "projectobjused@", | |
65 | "projectobjquota@" | |
9babb374 BB |
66 | }; |
67 | ||
34dc7c2f BB |
68 | zprop_desc_t * |
69 | zfs_prop_get_table(void) | |
70 | { | |
71 | return (zfs_prop_table); | |
72 | } | |
73 | ||
74 | void | |
75 | zfs_prop_init(void) | |
76 | { | |
77 | static zprop_index_t checksum_table[] = { | |
78 | { "on", ZIO_CHECKSUM_ON }, | |
79 | { "off", ZIO_CHECKSUM_OFF }, | |
80 | { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, | |
81 | { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, | |
82 | { "sha256", ZIO_CHECKSUM_SHA256 }, | |
3c67d83a TH |
83 | { "noparity", ZIO_CHECKSUM_NOPARITY }, |
84 | { "sha512", ZIO_CHECKSUM_SHA512 }, | |
85 | { "skein", ZIO_CHECKSUM_SKEIN }, | |
86 | { "edonr", ZIO_CHECKSUM_EDONR }, | |
34dc7c2f BB |
87 | { NULL } |
88 | }; | |
89 | ||
428870ff BB |
90 | static zprop_index_t dedup_table[] = { |
91 | { "on", ZIO_CHECKSUM_ON }, | |
92 | { "off", ZIO_CHECKSUM_OFF }, | |
93 | { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY }, | |
94 | { "sha256", ZIO_CHECKSUM_SHA256 }, | |
95 | { "sha256,verify", | |
96 | ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY }, | |
3c67d83a TH |
97 | { "sha512", ZIO_CHECKSUM_SHA512 }, |
98 | { "sha512,verify", | |
99 | ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY }, | |
100 | { "skein", ZIO_CHECKSUM_SKEIN }, | |
101 | { "skein,verify", | |
102 | ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY }, | |
103 | { "edonr,verify", | |
104 | ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY }, | |
428870ff BB |
105 | { NULL } |
106 | }; | |
107 | ||
34dc7c2f BB |
108 | static zprop_index_t compress_table[] = { |
109 | { "on", ZIO_COMPRESS_ON }, | |
110 | { "off", ZIO_COMPRESS_OFF }, | |
111 | { "lzjb", ZIO_COMPRESS_LZJB }, | |
112 | { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ | |
113 | { "gzip-1", ZIO_COMPRESS_GZIP_1 }, | |
114 | { "gzip-2", ZIO_COMPRESS_GZIP_2 }, | |
115 | { "gzip-3", ZIO_COMPRESS_GZIP_3 }, | |
116 | { "gzip-4", ZIO_COMPRESS_GZIP_4 }, | |
117 | { "gzip-5", ZIO_COMPRESS_GZIP_5 }, | |
118 | { "gzip-6", ZIO_COMPRESS_GZIP_6 }, | |
119 | { "gzip-7", ZIO_COMPRESS_GZIP_7 }, | |
120 | { "gzip-8", ZIO_COMPRESS_GZIP_8 }, | |
121 | { "gzip-9", ZIO_COMPRESS_GZIP_9 }, | |
428870ff | 122 | { "zle", ZIO_COMPRESS_ZLE }, |
9759c60f | 123 | { "lz4", ZIO_COMPRESS_LZ4 }, |
34dc7c2f BB |
124 | { NULL } |
125 | }; | |
126 | ||
b5256303 TC |
127 | static zprop_index_t crypto_table[] = { |
128 | { "on", ZIO_CRYPT_ON }, | |
129 | { "off", ZIO_CRYPT_OFF }, | |
130 | { "aes-128-ccm", ZIO_CRYPT_AES_128_CCM }, | |
131 | { "aes-192-ccm", ZIO_CRYPT_AES_192_CCM }, | |
132 | { "aes-256-ccm", ZIO_CRYPT_AES_256_CCM }, | |
133 | { "aes-128-gcm", ZIO_CRYPT_AES_128_GCM }, | |
134 | { "aes-192-gcm", ZIO_CRYPT_AES_192_GCM }, | |
135 | { "aes-256-gcm", ZIO_CRYPT_AES_256_GCM }, | |
136 | { NULL } | |
137 | }; | |
138 | ||
139 | static zprop_index_t keyformat_table[] = { | |
140 | { "none", ZFS_KEYFORMAT_NONE }, | |
141 | { "raw", ZFS_KEYFORMAT_RAW }, | |
142 | { "hex", ZFS_KEYFORMAT_HEX }, | |
143 | { "passphrase", ZFS_KEYFORMAT_PASSPHRASE }, | |
144 | { NULL } | |
145 | }; | |
146 | ||
34dc7c2f BB |
147 | static zprop_index_t snapdir_table[] = { |
148 | { "hidden", ZFS_SNAPDIR_HIDDEN }, | |
149 | { "visible", ZFS_SNAPDIR_VISIBLE }, | |
150 | { NULL } | |
151 | }; | |
152 | ||
0b4d1b58 ED |
153 | static zprop_index_t snapdev_table[] = { |
154 | { "hidden", ZFS_SNAPDEV_HIDDEN }, | |
155 | { "visible", ZFS_SNAPDEV_VISIBLE }, | |
156 | { NULL } | |
157 | }; | |
158 | ||
023699cd MM |
159 | static zprop_index_t acltype_table[] = { |
160 | { "off", ZFS_ACLTYPE_OFF }, | |
161 | { "disabled", ZFS_ACLTYPE_OFF }, | |
162 | { "noacl", ZFS_ACLTYPE_OFF }, | |
163 | { "posixacl", ZFS_ACLTYPE_POSIXACL }, | |
164 | { NULL } | |
165 | }; | |
166 | ||
34dc7c2f BB |
167 | static zprop_index_t acl_inherit_table[] = { |
168 | { "discard", ZFS_ACL_DISCARD }, | |
169 | { "noallow", ZFS_ACL_NOALLOW }, | |
170 | { "restricted", ZFS_ACL_RESTRICTED }, | |
171 | { "passthrough", ZFS_ACL_PASSTHROUGH }, | |
4e33ba4c | 172 | { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatibility */ |
b128c09f | 173 | { "passthrough-x", ZFS_ACL_PASSTHROUGH_X }, |
34dc7c2f BB |
174 | { NULL } |
175 | }; | |
176 | ||
177 | static zprop_index_t case_table[] = { | |
178 | { "sensitive", ZFS_CASE_SENSITIVE }, | |
179 | { "insensitive", ZFS_CASE_INSENSITIVE }, | |
180 | { "mixed", ZFS_CASE_MIXED }, | |
181 | { NULL } | |
182 | }; | |
183 | ||
184 | static zprop_index_t copies_table[] = { | |
185 | { "1", 1 }, | |
186 | { "2", 2 }, | |
187 | { "3", 3 }, | |
188 | { NULL } | |
189 | }; | |
190 | ||
191 | /* | |
192 | * Use the unique flags we have to send to u8_strcmp() and/or | |
193 | * u8_textprep() to represent the various normalization property | |
194 | * values. | |
195 | */ | |
196 | static zprop_index_t normalize_table[] = { | |
197 | { "none", 0 }, | |
198 | { "formD", U8_TEXTPREP_NFD }, | |
199 | { "formKC", U8_TEXTPREP_NFKC }, | |
200 | { "formC", U8_TEXTPREP_NFC }, | |
201 | { "formKD", U8_TEXTPREP_NFKD }, | |
202 | { NULL } | |
203 | }; | |
204 | ||
205 | static zprop_index_t version_table[] = { | |
206 | { "1", 1 }, | |
207 | { "2", 2 }, | |
208 | { "3", 3 }, | |
9babb374 | 209 | { "4", 4 }, |
428870ff | 210 | { "5", 5 }, |
34dc7c2f BB |
211 | { "current", ZPL_VERSION }, |
212 | { NULL } | |
213 | }; | |
214 | ||
215 | static zprop_index_t boolean_table[] = { | |
216 | { "off", 0 }, | |
217 | { "on", 1 }, | |
218 | { NULL } | |
219 | }; | |
220 | ||
b5256303 TC |
221 | static zprop_index_t keystatus_table[] = { |
222 | { "none", ZFS_KEYSTATUS_NONE}, | |
223 | { "unavailable", ZFS_KEYSTATUS_UNAVAILABLE}, | |
224 | { "available", ZFS_KEYSTATUS_AVAILABLE}, | |
225 | { NULL } | |
226 | }; | |
227 | ||
428870ff BB |
228 | static zprop_index_t logbias_table[] = { |
229 | { "latency", ZFS_LOGBIAS_LATENCY }, | |
230 | { "throughput", ZFS_LOGBIAS_THROUGHPUT }, | |
231 | { NULL } | |
232 | }; | |
233 | ||
34dc7c2f BB |
234 | static zprop_index_t canmount_table[] = { |
235 | { "off", ZFS_CANMOUNT_OFF }, | |
236 | { "on", ZFS_CANMOUNT_ON }, | |
237 | { "noauto", ZFS_CANMOUNT_NOAUTO }, | |
238 | { NULL } | |
239 | }; | |
240 | ||
b128c09f BB |
241 | static zprop_index_t cache_table[] = { |
242 | { "none", ZFS_CACHE_NONE }, | |
243 | { "metadata", ZFS_CACHE_METADATA }, | |
244 | { "all", ZFS_CACHE_ALL }, | |
245 | { NULL } | |
246 | }; | |
247 | ||
428870ff BB |
248 | static zprop_index_t sync_table[] = { |
249 | { "standard", ZFS_SYNC_STANDARD }, | |
250 | { "always", ZFS_SYNC_ALWAYS }, | |
251 | { "disabled", ZFS_SYNC_DISABLED }, | |
252 | { NULL } | |
253 | }; | |
254 | ||
82a37189 BB |
255 | static zprop_index_t xattr_table[] = { |
256 | { "off", ZFS_XATTR_OFF }, | |
257 | { "on", ZFS_XATTR_DIR }, | |
258 | { "sa", ZFS_XATTR_SA }, | |
259 | { "dir", ZFS_XATTR_DIR }, | |
260 | { NULL } | |
261 | }; | |
262 | ||
50c957f7 NB |
263 | static zprop_index_t dnsize_table[] = { |
264 | { "legacy", ZFS_DNSIZE_LEGACY }, | |
265 | { "auto", ZFS_DNSIZE_AUTO }, | |
266 | { "1k", ZFS_DNSIZE_1K }, | |
267 | { "2k", ZFS_DNSIZE_2K }, | |
268 | { "4k", ZFS_DNSIZE_4K }, | |
269 | { "8k", ZFS_DNSIZE_8K }, | |
270 | { "16k", ZFS_DNSIZE_16K }, | |
271 | { NULL } | |
272 | }; | |
273 | ||
faf0f58c MA |
274 | static zprop_index_t redundant_metadata_table[] = { |
275 | { "all", ZFS_REDUNDANT_METADATA_ALL }, | |
276 | { "most", ZFS_REDUNDANT_METADATA_MOST }, | |
277 | { NULL } | |
278 | }; | |
279 | ||
cf8738d8 | 280 | static zprop_index_t volmode_table[] = { |
281 | { "default", ZFS_VOLMODE_DEFAULT }, | |
282 | { "full", ZFS_VOLMODE_GEOM }, | |
283 | { "geom", ZFS_VOLMODE_GEOM }, | |
284 | { "dev", ZFS_VOLMODE_DEV }, | |
285 | { "none", ZFS_VOLMODE_NONE }, | |
286 | { NULL } | |
287 | }; | |
288 | ||
34dc7c2f | 289 | /* inherit index properties */ |
faf0f58c MA |
290 | zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata", |
291 | ZFS_REDUNDANT_METADATA_ALL, | |
292 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
293 | "all | most", "REDUND_MD", | |
294 | redundant_metadata_table); | |
428870ff | 295 | zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD, |
34dc7c2f | 296 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, |
428870ff BB |
297 | "standard | always | disabled", "SYNC", |
298 | sync_table); | |
299 | zprop_register_index(ZFS_PROP_CHECKSUM, "checksum", | |
300 | ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | | |
301 | ZFS_TYPE_VOLUME, | |
3c67d83a TH |
302 | "on | off | fletcher2 | fletcher4 | sha256 | sha512 | " |
303 | "skein | edonr", "CHECKSUM", checksum_table); | |
428870ff BB |
304 | zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF, |
305 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
3c67d83a TH |
306 | "on | off | verify | sha256[,verify], sha512[,verify], " |
307 | "skein[,verify], edonr,verify", "DEDUP", dedup_table); | |
428870ff | 308 | zprop_register_index(ZFS_PROP_COMPRESSION, "compression", |
34dc7c2f BB |
309 | ZIO_COMPRESS_DEFAULT, PROP_INHERIT, |
310 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
9759c60f | 311 | "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", "COMPRESS", |
428870ff BB |
312 | compress_table); |
313 | zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, | |
34dc7c2f BB |
314 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM, |
315 | "hidden | visible", "SNAPDIR", snapdir_table); | |
0b4d1b58 ED |
316 | zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN, |
317 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
318 | "hidden | visible", "SNAPDEV", snapdev_table); | |
023699cd MM |
319 | zprop_register_index(ZFS_PROP_ACLTYPE, "acltype", ZFS_ACLTYPE_OFF, |
320 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, | |
321 | "noacl | posixacl", "ACLTYPE", acltype_table); | |
428870ff BB |
322 | zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit", |
323 | ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, | |
b128c09f | 324 | "discard | noallow | restricted | passthrough | passthrough-x", |
34dc7c2f | 325 | "ACLINHERIT", acl_inherit_table); |
428870ff BB |
326 | zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT, |
327 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
34dc7c2f | 328 | "1 | 2 | 3", "COPIES", copies_table); |
428870ff | 329 | zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", |
b128c09f BB |
330 | ZFS_CACHE_ALL, PROP_INHERIT, |
331 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, | |
332 | "all | none | metadata", "PRIMARYCACHE", cache_table); | |
428870ff | 333 | zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", |
b128c09f BB |
334 | ZFS_CACHE_ALL, PROP_INHERIT, |
335 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, | |
336 | "all | none | metadata", "SECONDARYCACHE", cache_table); | |
428870ff BB |
337 | zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY, |
338 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
339 | "latency | throughput", "LOGBIAS", logbias_table); | |
82a37189 BB |
340 | zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR, |
341 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, | |
342 | "on | off | dir | sa", "XATTR", xattr_table); | |
50c957f7 NB |
343 | zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize", |
344 | ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, | |
345 | "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table); | |
cf8738d8 | 346 | zprop_register_index(ZFS_PROP_VOLMODE, "volmode", |
347 | ZFS_VOLMODE_DEFAULT, PROP_INHERIT, | |
348 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
349 | "default | full | geom | dev | none", "VOLMODE", volmode_table); | |
34dc7c2f BB |
350 | |
351 | /* inherit index (boolean) properties */ | |
428870ff | 352 | zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, |
34dc7c2f | 353 | ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); |
6d111134 TC |
354 | zprop_register_index(ZFS_PROP_RELATIME, "relatime", 0, PROP_INHERIT, |
355 | ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table); | |
428870ff | 356 | zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, |
34dc7c2f BB |
357 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", |
358 | boolean_table); | |
428870ff | 359 | zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, |
34dc7c2f BB |
360 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", |
361 | boolean_table); | |
428870ff | 362 | zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, |
34dc7c2f BB |
363 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", |
364 | boolean_table); | |
428870ff | 365 | zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, |
34dc7c2f BB |
366 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", |
367 | boolean_table); | |
428870ff | 368 | zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT, |
34dc7c2f | 369 | ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table); |
428870ff | 370 | zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, |
82a37189 | 371 | ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table); |
428870ff | 372 | zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT, |
34dc7c2f BB |
373 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND", |
374 | boolean_table); | |
f67d7090 TF |
375 | zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 0, PROP_INHERIT, |
376 | ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table); | |
34dc7c2f BB |
377 | |
378 | /* default index properties */ | |
428870ff | 379 | zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, |
34dc7c2f | 380 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, |
330d06f9 | 381 | "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table); |
428870ff | 382 | zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, |
34dc7c2f BB |
383 | PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", |
384 | "CANMOUNT", canmount_table); | |
385 | ||
b5256303 | 386 | /* readonly index properties */ |
428870ff | 387 | zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, |
34dc7c2f | 388 | ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); |
428870ff | 389 | zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0, |
45d1cae3 BB |
390 | PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY", |
391 | boolean_table); | |
b5256303 TC |
392 | zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus", |
393 | ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET, | |
394 | "none | unavailable | available", | |
395 | "KEYSTATUS", keystatus_table); | |
34dc7c2f BB |
396 | |
397 | /* set once index properties */ | |
428870ff | 398 | zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0, |
34dc7c2f BB |
399 | PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, |
400 | "none | formC | formD | formKC | formKD", "NORMALIZATION", | |
401 | normalize_table); | |
428870ff BB |
402 | zprop_register_index(ZFS_PROP_CASE, "casesensitivity", |
403 | ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM | | |
404 | ZFS_TYPE_SNAPSHOT, | |
34dc7c2f | 405 | "sensitive | insensitive | mixed", "CASE", case_table); |
b5256303 TC |
406 | zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat", |
407 | ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT, | |
408 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
409 | "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table); | |
410 | zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption", | |
411 | ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET, | |
412 | "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | " | |
413 | "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION", | |
414 | crypto_table); | |
34dc7c2f BB |
415 | |
416 | /* set once index (boolean) properties */ | |
428870ff | 417 | zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, |
34dc7c2f BB |
418 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, |
419 | "on | off", "UTF8ONLY", boolean_table); | |
420 | ||
421 | /* string properties */ | |
428870ff | 422 | zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, |
34dc7c2f | 423 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN"); |
330d06f9 MA |
424 | zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY, |
425 | ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES"); | |
428870ff BB |
426 | zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", |
427 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", | |
428 | "MOUNTPOINT"); | |
429 | zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", | |
430 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", | |
431 | "SHARENFS"); | |
432 | zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, | |
da536844 MA |
433 | ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, |
434 | "filesystem | volume | snapshot | bookmark", "TYPE"); | |
428870ff BB |
435 | zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", |
436 | PROP_INHERIT, ZFS_TYPE_FILESYSTEM, | |
437 | "on | off | sharemgr(1M) options", "SHARESMB"); | |
438 | zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel", | |
439 | ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET, | |
440 | "<sensitivity label>", "MLSLABEL"); | |
11b9ec23 MT |
441 | zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context", |
442 | "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux context>", | |
443 | "CONTEXT"); | |
444 | zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext", | |
445 | "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux fscontext>", | |
446 | "FSCONTEXT"); | |
447 | zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext", | |
448 | "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux defcontext>", | |
449 | "DEFCONTEXT"); | |
450 | zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext", | |
451 | "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux rootcontext>", | |
452 | "ROOTCONTEXT"); | |
47dfff3b MA |
453 | zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN, |
454 | "receive_resume_token", | |
455 | NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
456 | "<string token>", "RESUMETOK"); | |
b5256303 TC |
457 | zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL, |
458 | PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>", | |
459 | "ENCROOT"); | |
460 | zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation", | |
461 | "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
462 | "prompt | <file URI>", "KEYLOCATION"); | |
34dc7c2f BB |
463 | |
464 | /* readonly number properties */ | |
428870ff | 465 | zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, |
34dc7c2f | 466 | ZFS_TYPE_DATASET, "<size>", "USED"); |
428870ff | 467 | zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, |
34dc7c2f | 468 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL"); |
428870ff BB |
469 | zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0, |
470 | PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER"); | |
471 | zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, | |
34dc7c2f BB |
472 | PROP_READONLY, ZFS_TYPE_DATASET, |
473 | "<1.00x or higher if compressed>", "RATIO"); | |
f5fc4aca MA |
474 | zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0, |
475 | PROP_READONLY, ZFS_TYPE_DATASET, | |
476 | "<1.00x or higher if compressed>", "REFRATIO"); | |
428870ff BB |
477 | zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", |
478 | ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME, | |
34dc7c2f | 479 | ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK"); |
428870ff BB |
480 | zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, |
481 | PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", | |
482 | "USEDSNAP"); | |
483 | zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, | |
484 | PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", | |
485 | "USEDDS"); | |
486 | zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, | |
487 | PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", | |
488 | "USEDCHILD"); | |
489 | zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, | |
b128c09f BB |
490 | PROP_READONLY, |
491 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV"); | |
428870ff | 492 | zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY, |
45d1cae3 | 493 | ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS"); |
330d06f9 MA |
494 | zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY, |
495 | ZFS_TYPE_DATASET, "<size>", "WRITTEN"); | |
24a64651 | 496 | zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0, |
d99a0153 CW |
497 | PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", |
498 | "LUSED"); | |
24a64651 MA |
499 | zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced", |
500 | 0, PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LREFER"); | |
911c41af GM |
501 | zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count", |
502 | UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM, | |
503 | "<count>", "FSCOUNT"); | |
504 | zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count", | |
505 | UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
506 | "<count>", "SSCOUNT"); | |
305bc4b3 CS |
507 | zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY, |
508 | ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID"); | |
509 | zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY, | |
510 | ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG"); | |
b5256303 TC |
511 | zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters", |
512 | 0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
513 | "<iters>", "PBKDF2ITERS"); | |
34dc7c2f BB |
514 | |
515 | /* default number properties */ | |
428870ff | 516 | zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, |
34dc7c2f | 517 | ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA"); |
428870ff BB |
518 | zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0, |
519 | PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
520 | "<size> | none", "RESERV"); | |
521 | zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, | |
962d5242 | 522 | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE"); |
428870ff | 523 | zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, |
34dc7c2f | 524 | ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA"); |
428870ff | 525 | zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, |
34dc7c2f BB |
526 | PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, |
527 | "<size> | none", "REFRESERV"); | |
788eb90c JJ |
528 | zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit", |
529 | UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, | |
530 | "<count> | none", "FSLIMIT"); | |
531 | zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit", | |
532 | UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, | |
533 | "<count> | none", "SSLIMIT"); | |
34dc7c2f BB |
534 | |
535 | /* inherit number properties */ | |
428870ff | 536 | zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize", |
f1512ee6 MA |
537 | SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT, |
538 | ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE"); | |
34dc7c2f BB |
539 | |
540 | /* hidden properties */ | |
428870ff BB |
541 | zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, |
542 | PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES"); | |
543 | zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, | |
da536844 | 544 | PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME"); |
428870ff BB |
545 | zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", |
546 | PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); | |
547 | zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu", | |
9babb374 BB |
548 | PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, |
549 | "STMF_SBD_LU"); | |
428870ff BB |
550 | zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting", |
551 | PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, | |
552 | "USERACCOUNTING"); | |
553 | zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER, | |
554 | PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE"); | |
555 | zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER, | |
556 | PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID"); | |
96c2e961 KW |
557 | zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent", |
558 | PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT"); | |
1715493f MA |
559 | zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING, |
560 | PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP"); | |
b5256303 TC |
561 | zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt", |
562 | PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT, | |
563 | ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT"); | |
564 | zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER, | |
565 | PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID"); | |
428870ff BB |
566 | |
567 | /* | |
568 | * Property to be removed once libbe is integrated | |
569 | */ | |
570 | zprop_register_hidden(ZFS_PROP_PRIVATE, "priv_prop", | |
571 | PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_FILESYSTEM, | |
572 | "PRIV_PROP"); | |
34dc7c2f BB |
573 | |
574 | /* oddball properties */ | |
428870ff | 575 | zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, |
da536844 | 576 | NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, |
34dc7c2f BB |
577 | "<date>", "CREATION", B_FALSE, B_TRUE, NULL); |
578 | } | |
579 | ||
580 | boolean_t | |
581 | zfs_prop_delegatable(zfs_prop_t prop) | |
582 | { | |
583 | zprop_desc_t *pd = &zfs_prop_table[prop]; | |
428870ff BB |
584 | |
585 | /* The mlslabel property is never delegatable. */ | |
586 | if (prop == ZFS_PROP_MLSLABEL) | |
587 | return (B_FALSE); | |
588 | ||
34dc7c2f BB |
589 | return (pd->pd_attr != PROP_READONLY); |
590 | } | |
591 | ||
592 | /* | |
593 | * Given a zfs dataset property name, returns the corresponding property ID. | |
594 | */ | |
595 | zfs_prop_t | |
596 | zfs_name_to_prop(const char *propname) | |
597 | { | |
598 | return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); | |
599 | } | |
600 | ||
34dc7c2f BB |
601 | /* |
602 | * For user property names, we allow all lowercase alphanumeric characters, plus | |
603 | * a few useful punctuation characters. | |
604 | */ | |
605 | static int | |
606 | valid_char(char c) | |
607 | { | |
608 | return ((c >= 'a' && c <= 'z') || | |
609 | (c >= '0' && c <= '9') || | |
610 | c == '-' || c == '_' || c == '.' || c == ':'); | |
611 | } | |
612 | ||
613 | /* | |
614 | * Returns true if this is a valid user-defined property (one with a ':'). | |
615 | */ | |
616 | boolean_t | |
617 | zfs_prop_user(const char *name) | |
618 | { | |
619 | int i; | |
620 | char c; | |
621 | boolean_t foundsep = B_FALSE; | |
622 | ||
623 | for (i = 0; i < strlen(name); i++) { | |
624 | c = name[i]; | |
625 | if (!valid_char(c)) | |
626 | return (B_FALSE); | |
627 | if (c == ':') | |
628 | foundsep = B_TRUE; | |
629 | } | |
630 | ||
631 | if (!foundsep) | |
632 | return (B_FALSE); | |
633 | ||
634 | return (B_TRUE); | |
635 | } | |
636 | ||
9babb374 BB |
637 | /* |
638 | * Returns true if this is a valid userspace-type property (one with a '@'). | |
639 | * Note that after the @, any character is valid (eg, another @, for SID | |
640 | * user@domain). | |
641 | */ | |
642 | boolean_t | |
643 | zfs_prop_userquota(const char *name) | |
644 | { | |
645 | zfs_userquota_prop_t prop; | |
646 | ||
647 | for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) { | |
648 | if (strncmp(name, zfs_userquota_prop_prefixes[prop], | |
649 | strlen(zfs_userquota_prop_prefixes[prop])) == 0) { | |
650 | return (B_TRUE); | |
651 | } | |
652 | } | |
653 | ||
654 | return (B_FALSE); | |
655 | } | |
656 | ||
330d06f9 MA |
657 | /* |
658 | * Returns true if this is a valid written@ property. | |
659 | * Note that after the @, any character is valid (eg, another @, for | |
660 | * written@pool/fs@origin). | |
661 | */ | |
662 | boolean_t | |
663 | zfs_prop_written(const char *name) | |
664 | { | |
665 | static const char *prefix = "written@"; | |
666 | return (strncmp(name, prefix, strlen(prefix)) == 0); | |
667 | } | |
668 | ||
34dc7c2f BB |
669 | /* |
670 | * Tables of index types, plus functions to convert between the user view | |
671 | * (strings) and internal representation (uint64_t). | |
672 | */ | |
673 | int | |
674 | zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) | |
675 | { | |
676 | return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); | |
677 | } | |
678 | ||
679 | int | |
680 | zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) | |
681 | { | |
682 | return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); | |
683 | } | |
684 | ||
428870ff BB |
685 | uint64_t |
686 | zfs_prop_random_value(zfs_prop_t prop, uint64_t seed) | |
687 | { | |
688 | return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET)); | |
689 | } | |
690 | ||
34dc7c2f BB |
691 | /* |
692 | * Returns TRUE if the property applies to any of the given dataset types. | |
693 | */ | |
b128c09f | 694 | boolean_t |
962d5242 | 695 | zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck) |
34dc7c2f | 696 | { |
962d5242 | 697 | return (zprop_valid_for_type(prop, types, headcheck)); |
34dc7c2f BB |
698 | } |
699 | ||
700 | zprop_type_t | |
701 | zfs_prop_get_type(zfs_prop_t prop) | |
702 | { | |
703 | return (zfs_prop_table[prop].pd_proptype); | |
704 | } | |
705 | ||
706 | /* | |
707 | * Returns TRUE if the property is readonly. | |
708 | */ | |
709 | boolean_t | |
710 | zfs_prop_readonly(zfs_prop_t prop) | |
711 | { | |
712 | return (zfs_prop_table[prop].pd_attr == PROP_READONLY || | |
b5256303 TC |
713 | zfs_prop_table[prop].pd_attr == PROP_ONETIME || |
714 | zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT); | |
34dc7c2f BB |
715 | } |
716 | ||
d99a0153 CW |
717 | /* |
718 | * Returns TRUE if the property is visible (not hidden). | |
719 | */ | |
720 | boolean_t | |
721 | zfs_prop_visible(zfs_prop_t prop) | |
722 | { | |
723 | return (zfs_prop_table[prop].pd_visible); | |
724 | } | |
725 | ||
34dc7c2f BB |
726 | /* |
727 | * Returns TRUE if the property is only allowed to be set once. | |
728 | */ | |
729 | boolean_t | |
730 | zfs_prop_setonce(zfs_prop_t prop) | |
731 | { | |
b5256303 TC |
732 | return (zfs_prop_table[prop].pd_attr == PROP_ONETIME || |
733 | zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT); | |
34dc7c2f BB |
734 | } |
735 | ||
736 | const char * | |
737 | zfs_prop_default_string(zfs_prop_t prop) | |
738 | { | |
739 | return (zfs_prop_table[prop].pd_strdefault); | |
740 | } | |
741 | ||
742 | uint64_t | |
743 | zfs_prop_default_numeric(zfs_prop_t prop) | |
744 | { | |
745 | return (zfs_prop_table[prop].pd_numdefault); | |
746 | } | |
747 | ||
748 | /* | |
749 | * Given a dataset property ID, returns the corresponding name. | |
750 | * Assuming the zfs dataset property ID is valid. | |
751 | */ | |
752 | const char * | |
753 | zfs_prop_to_name(zfs_prop_t prop) | |
754 | { | |
755 | return (zfs_prop_table[prop].pd_name); | |
756 | } | |
757 | ||
758 | /* | |
759 | * Returns TRUE if the property is inheritable. | |
760 | */ | |
761 | boolean_t | |
762 | zfs_prop_inheritable(zfs_prop_t prop) | |
763 | { | |
764 | return (zfs_prop_table[prop].pd_attr == PROP_INHERIT || | |
765 | zfs_prop_table[prop].pd_attr == PROP_ONETIME); | |
766 | } | |
767 | ||
b5256303 TC |
768 | /* |
769 | * Returns TRUE if property is one of the encryption properties that requires | |
770 | * a loaded encryption key to modify. | |
771 | */ | |
772 | boolean_t | |
773 | zfs_prop_encryption_key_param(zfs_prop_t prop) | |
774 | { | |
775 | /* | |
776 | * keylocation does not count as an encryption property. It can be | |
777 | * changed at will without needing the master keys. | |
778 | */ | |
779 | return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS || | |
780 | prop == ZFS_PROP_KEYFORMAT); | |
781 | } | |
782 | ||
783 | /* | |
784 | * Helper function used by both kernelspace and userspace to check the | |
785 | * keylocation property. If encrypted is set, the keylocation must be valid | |
786 | * for an encrypted dataset. | |
787 | */ | |
788 | boolean_t | |
789 | zfs_prop_valid_keylocation(const char *str, boolean_t encrypted) | |
790 | { | |
791 | if (strcmp("none", str) == 0) | |
792 | return (!encrypted); | |
793 | else if (strcmp("prompt", str) == 0) | |
794 | return (B_TRUE); | |
795 | else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0) | |
796 | return (B_TRUE); | |
797 | ||
798 | return (B_FALSE); | |
799 | } | |
800 | ||
801 | ||
34dc7c2f BB |
802 | #ifndef _KERNEL |
803 | ||
804 | /* | |
805 | * Returns a string describing the set of acceptable values for the given | |
806 | * zfs property, or NULL if it cannot be set. | |
807 | */ | |
808 | const char * | |
809 | zfs_prop_values(zfs_prop_t prop) | |
810 | { | |
811 | return (zfs_prop_table[prop].pd_values); | |
812 | } | |
813 | ||
814 | /* | |
815 | * Returns TRUE if this property is a string type. Note that index types | |
816 | * (compression, checksum) are treated as strings in userland, even though they | |
817 | * are stored numerically on disk. | |
818 | */ | |
819 | int | |
820 | zfs_prop_is_string(zfs_prop_t prop) | |
821 | { | |
822 | return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || | |
823 | zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); | |
824 | } | |
825 | ||
826 | /* | |
827 | * Returns the column header for the given property. Used only in | |
828 | * 'zfs list -o', but centralized here with the other property information. | |
829 | */ | |
830 | const char * | |
831 | zfs_prop_column_name(zfs_prop_t prop) | |
832 | { | |
833 | return (zfs_prop_table[prop].pd_colname); | |
834 | } | |
835 | ||
836 | /* | |
837 | * Returns whether the given property should be displayed right-justified for | |
838 | * 'zfs list'. | |
839 | */ | |
840 | boolean_t | |
841 | zfs_prop_align_right(zfs_prop_t prop) | |
842 | { | |
843 | return (zfs_prop_table[prop].pd_rightalign); | |
844 | } | |
845 | ||
846 | #endif | |
c28b2279 BB |
847 | |
848 | #if defined(_KERNEL) && defined(HAVE_SPL) | |
b4f3666a BB |
849 | static int __init |
850 | zcommon_init(void) | |
851 | { | |
1eeb4562 | 852 | fletcher_4_init(); |
b4f3666a BB |
853 | return (0); |
854 | } | |
c28b2279 | 855 | |
b4f3666a BB |
856 | static void __exit |
857 | zcommon_fini(void) | |
858 | { | |
1eeb4562 | 859 | fletcher_4_fini(); |
b4f3666a | 860 | } |
c28b2279 | 861 | |
b4f3666a BB |
862 | module_init(zcommon_init); |
863 | module_exit(zcommon_fini); | |
c28b2279 BB |
864 | |
865 | MODULE_DESCRIPTION("Generic ZFS support"); | |
866 | MODULE_AUTHOR(ZFS_META_AUTHOR); | |
867 | MODULE_LICENSE(ZFS_META_LICENSE); | |
99e349db | 868 | MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); |
c28b2279 BB |
869 | |
870 | /* zfs dataset property functions */ | |
871 | EXPORT_SYMBOL(zfs_userquota_prop_prefixes); | |
872 | EXPORT_SYMBOL(zfs_prop_init); | |
873 | EXPORT_SYMBOL(zfs_prop_get_type); | |
874 | EXPORT_SYMBOL(zfs_prop_get_table); | |
875 | EXPORT_SYMBOL(zfs_prop_delegatable); | |
d99a0153 | 876 | EXPORT_SYMBOL(zfs_prop_visible); |
c28b2279 BB |
877 | |
878 | /* Dataset property functions shared between libzfs and kernel. */ | |
879 | EXPORT_SYMBOL(zfs_prop_default_string); | |
880 | EXPORT_SYMBOL(zfs_prop_default_numeric); | |
881 | EXPORT_SYMBOL(zfs_prop_readonly); | |
882 | EXPORT_SYMBOL(zfs_prop_inheritable); | |
b5256303 TC |
883 | EXPORT_SYMBOL(zfs_prop_encryption_key_param); |
884 | EXPORT_SYMBOL(zfs_prop_valid_keylocation); | |
c28b2279 BB |
885 | EXPORT_SYMBOL(zfs_prop_setonce); |
886 | EXPORT_SYMBOL(zfs_prop_to_name); | |
887 | EXPORT_SYMBOL(zfs_name_to_prop); | |
888 | EXPORT_SYMBOL(zfs_prop_user); | |
889 | EXPORT_SYMBOL(zfs_prop_userquota); | |
890 | EXPORT_SYMBOL(zfs_prop_index_to_string); | |
891 | EXPORT_SYMBOL(zfs_prop_string_to_index); | |
892 | EXPORT_SYMBOL(zfs_prop_valid_for_type); | |
d99a0153 | 893 | EXPORT_SYMBOL(zfs_prop_written); |
c28b2279 BB |
894 | |
895 | #endif |