Print this page
Integrated Edon-R hash function.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/common/zfs/zfs_prop.c
+++ new/usr/src/common/zfs/zfs_prop.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2011 by Delphix. All rights reserved.
24 24 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25 25 */
26 26
27 27 /* Portions Copyright 2010 Robert Milkowski */
28 28
29 29 #include <sys/zio.h>
30 30 #include <sys/spa.h>
31 31 #include <sys/u8_textprep.h>
32 32 #include <sys/zfs_acl.h>
33 33 #include <sys/zfs_ioctl.h>
34 34 #include <sys/zfs_znode.h>
35 35
36 36 #include "zfs_prop.h"
37 37 #include "zfs_deleg.h"
38 38
39 39 #if defined(_KERNEL)
40 40 #include <sys/systm.h>
41 41 #else
42 42 #include <stdlib.h>
43 43 #include <string.h>
44 44 #include <ctype.h>
45 45 #endif
46 46
47 47 static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
48 48
49 49 /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
50 50 const char *zfs_userquota_prop_prefixes[] = {
51 51 "userused@",
52 52 "userquota@",
53 53 "groupused@",
54 54 "groupquota@"
55 55 };
56 56
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
57 57 zprop_desc_t *
58 58 zfs_prop_get_table(void)
59 59 {
60 60 return (zfs_prop_table);
61 61 }
62 62
63 63 void
64 64 zfs_prop_init(void)
65 65 {
66 66 static zprop_index_t checksum_table[] = {
67 - { "on", ZIO_CHECKSUM_ON },
68 - { "off", ZIO_CHECKSUM_OFF },
69 - { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 },
70 - { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 },
71 - { "sha256", ZIO_CHECKSUM_SHA256 },
67 + { "on", ZIO_CHECKSUM_ON },
68 + { "off", ZIO_CHECKSUM_OFF },
69 + { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 },
70 + { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 },
71 + { "sha256", ZIO_CHECKSUM_SHA256 },
72 + { "edonr512/256", ZIO_CHECKSUM_EDONR512_256 },
72 73 { NULL }
73 74 };
74 75
75 76 static zprop_index_t dedup_table[] = {
76 - { "on", ZIO_CHECKSUM_ON },
77 - { "off", ZIO_CHECKSUM_OFF },
78 - { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
79 - { "sha256", ZIO_CHECKSUM_SHA256 },
77 + { "on", ZIO_CHECKSUM_ON },
78 + { "off", ZIO_CHECKSUM_OFF },
79 + { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
80 + { "sha256", ZIO_CHECKSUM_SHA256 },
80 81 { "sha256,verify",
81 - ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
82 + ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
83 + { "edonr512/256", ZIO_CHECKSUM_EDONR512_256 },
84 + { "edonr512/256,verify",
85 + ZIO_CHECKSUM_EDONR512_256 | ZIO_CHECKSUM_VERIFY },
82 86 { NULL }
83 87 };
84 88
85 89 static zprop_index_t compress_table[] = {
86 90 { "on", ZIO_COMPRESS_ON },
87 91 { "off", ZIO_COMPRESS_OFF },
88 92 { "lzjb", ZIO_COMPRESS_LZJB },
89 93 { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */
90 94 { "gzip-1", ZIO_COMPRESS_GZIP_1 },
91 95 { "gzip-2", ZIO_COMPRESS_GZIP_2 },
92 96 { "gzip-3", ZIO_COMPRESS_GZIP_3 },
93 97 { "gzip-4", ZIO_COMPRESS_GZIP_4 },
94 98 { "gzip-5", ZIO_COMPRESS_GZIP_5 },
95 99 { "gzip-6", ZIO_COMPRESS_GZIP_6 },
96 100 { "gzip-7", ZIO_COMPRESS_GZIP_7 },
97 101 { "gzip-8", ZIO_COMPRESS_GZIP_8 },
98 102 { "gzip-9", ZIO_COMPRESS_GZIP_9 },
99 103 { "zle", ZIO_COMPRESS_ZLE },
100 104 { "lz4", ZIO_COMPRESS_LZ4 },
101 105 { NULL }
102 106 };
103 107
104 108 static zprop_index_t snapdir_table[] = {
105 109 { "hidden", ZFS_SNAPDIR_HIDDEN },
106 110 { "visible", ZFS_SNAPDIR_VISIBLE },
107 111 { NULL }
108 112 };
109 113
110 114 static zprop_index_t acl_mode_table[] = {
111 115 { "discard", ZFS_ACL_DISCARD },
112 116 { "groupmask", ZFS_ACL_GROUPMASK },
113 117 { "passthrough", ZFS_ACL_PASSTHROUGH },
114 118 { "restricted", ZFS_ACL_RESTRICTED },
115 119 { NULL }
116 120 };
117 121
118 122 static zprop_index_t acl_inherit_table[] = {
119 123 { "discard", ZFS_ACL_DISCARD },
120 124 { "noallow", ZFS_ACL_NOALLOW },
121 125 { "restricted", ZFS_ACL_RESTRICTED },
122 126 { "passthrough", ZFS_ACL_PASSTHROUGH },
123 127 { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatability */
124 128 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
125 129 { NULL }
126 130 };
127 131
128 132 static zprop_index_t case_table[] = {
129 133 { "sensitive", ZFS_CASE_SENSITIVE },
130 134 { "insensitive", ZFS_CASE_INSENSITIVE },
131 135 { "mixed", ZFS_CASE_MIXED },
132 136 { NULL }
133 137 };
134 138
135 139 static zprop_index_t copies_table[] = {
136 140 { "1", 1 },
137 141 { "2", 2 },
138 142 { "3", 3 },
139 143 { NULL }
140 144 };
141 145
142 146 /*
143 147 * Use the unique flags we have to send to u8_strcmp() and/or
144 148 * u8_textprep() to represent the various normalization property
145 149 * values.
146 150 */
147 151 static zprop_index_t normalize_table[] = {
148 152 { "none", 0 },
149 153 { "formD", U8_TEXTPREP_NFD },
150 154 { "formKC", U8_TEXTPREP_NFKC },
151 155 { "formC", U8_TEXTPREP_NFC },
152 156 { "formKD", U8_TEXTPREP_NFKD },
153 157 { NULL }
154 158 };
155 159
156 160 static zprop_index_t version_table[] = {
157 161 { "1", 1 },
158 162 { "2", 2 },
159 163 { "3", 3 },
160 164 { "4", 4 },
161 165 { "5", 5 },
162 166 { "current", ZPL_VERSION },
163 167 { NULL }
164 168 };
165 169
166 170 static zprop_index_t boolean_table[] = {
167 171 { "off", 0 },
168 172 { "on", 1 },
169 173 { NULL }
170 174 };
171 175
172 176 static zprop_index_t logbias_table[] = {
173 177 { "latency", ZFS_LOGBIAS_LATENCY },
174 178 { "throughput", ZFS_LOGBIAS_THROUGHPUT },
175 179 { NULL }
176 180 };
177 181
178 182 static zprop_index_t canmount_table[] = {
179 183 { "off", ZFS_CANMOUNT_OFF },
180 184 { "on", ZFS_CANMOUNT_ON },
181 185 { "noauto", ZFS_CANMOUNT_NOAUTO },
182 186 { NULL }
183 187 };
184 188
185 189 static zprop_index_t cache_table[] = {
186 190 { "none", ZFS_CACHE_NONE },
187 191 { "metadata", ZFS_CACHE_METADATA },
188 192 { "all", ZFS_CACHE_ALL },
189 193 { NULL }
190 194 };
191 195
192 196 static zprop_index_t sync_table[] = {
193 197 { "standard", ZFS_SYNC_STANDARD },
194 198 { "always", ZFS_SYNC_ALWAYS },
195 199 { "disabled", ZFS_SYNC_DISABLED },
196 200 { NULL }
↓ open down ↓ |
105 lines elided |
↑ open up ↑ |
197 201 };
198 202
199 203 /* inherit index properties */
200 204 zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
201 205 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
202 206 "standard | always | disabled", "SYNC",
203 207 sync_table);
204 208 zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
205 209 ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
206 210 ZFS_TYPE_VOLUME,
207 - "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
208 - checksum_table);
211 + "on | off | fletcher2 | fletcher4 | sha256 | edonr512/256",
212 + "CHECKSUM", checksum_table);
209 213 zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
210 214 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
211 - "on | off | verify | sha256[,verify]", "DEDUP",
212 - dedup_table);
215 + "on | off | verify | sha256[,verify] | edonr512/256[,verify]",
216 + "DEDUP", dedup_table);
213 217 zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
214 218 ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
215 219 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
216 220 "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4",
217 221 "COMPRESS", compress_table);
218 222 zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
219 223 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
220 224 "hidden | visible", "SNAPDIR", snapdir_table);
221 225 zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
222 226 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
223 227 "discard | groupmask | passthrough | restricted", "ACLMODE",
224 228 acl_mode_table);
225 229 zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
226 230 ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
227 231 "discard | noallow | restricted | passthrough | passthrough-x",
228 232 "ACLINHERIT", acl_inherit_table);
229 233 zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
230 234 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
231 235 "1 | 2 | 3", "COPIES", copies_table);
232 236 zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
233 237 ZFS_CACHE_ALL, PROP_INHERIT,
234 238 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
235 239 "all | none | metadata", "PRIMARYCACHE", cache_table);
236 240 zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
237 241 ZFS_CACHE_ALL, PROP_INHERIT,
238 242 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
239 243 "all | none | metadata", "SECONDARYCACHE", cache_table);
240 244 zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
241 245 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
242 246 "latency | throughput", "LOGBIAS", logbias_table);
243 247
244 248 /* inherit index (boolean) properties */
245 249 zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
246 250 ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
247 251 zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
248 252 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
249 253 boolean_table);
250 254 zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
251 255 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
252 256 boolean_table);
253 257 zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
254 258 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
255 259 boolean_table);
256 260 zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
257 261 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
258 262 boolean_table);
259 263 zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
260 264 ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
261 265 zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
262 266 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
263 267 boolean_table);
264 268 zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
265 269 ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
266 270 boolean_table);
267 271 zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
268 272 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
269 273 boolean_table);
270 274
271 275 /* default index properties */
272 276 zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
273 277 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
274 278 "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table);
275 279 zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
276 280 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
277 281 "CANMOUNT", canmount_table);
278 282
279 283 /* readonly index (boolean) properties */
280 284 zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
281 285 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
282 286 zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
283 287 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
284 288 boolean_table);
285 289
286 290 /* set once index properties */
287 291 zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
288 292 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
289 293 "none | formC | formD | formKC | formKD", "NORMALIZATION",
290 294 normalize_table);
291 295 zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
292 296 ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
293 297 ZFS_TYPE_SNAPSHOT,
294 298 "sensitive | insensitive | mixed", "CASE", case_table);
295 299
296 300 /* set once index (boolean) properties */
297 301 zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
298 302 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
299 303 "on | off", "UTF8ONLY", boolean_table);
300 304
301 305 /* string properties */
302 306 zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
303 307 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
304 308 zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
305 309 ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES");
306 310 zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
307 311 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
308 312 "MOUNTPOINT");
309 313 zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
310 314 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options",
311 315 "SHARENFS");
312 316 zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
313 317 ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE");
314 318 zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
315 319 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
316 320 "on | off | sharemgr(1M) options", "SHARESMB");
317 321 zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
318 322 ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
319 323 "<sensitivity label>", "MLSLABEL");
320 324
321 325 /* readonly number properties */
322 326 zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
323 327 ZFS_TYPE_DATASET, "<size>", "USED");
324 328 zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
325 329 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
326 330 zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
327 331 PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER");
328 332 zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
329 333 PROP_READONLY, ZFS_TYPE_DATASET,
330 334 "<1.00x or higher if compressed>", "RATIO");
331 335 zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
332 336 PROP_READONLY, ZFS_TYPE_DATASET,
333 337 "<1.00x or higher if compressed>", "REFRATIO");
334 338 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
335 339 ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
336 340 ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK");
337 341 zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
338 342 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
339 343 "USEDSNAP");
340 344 zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
341 345 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
342 346 "USEDDS");
343 347 zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
344 348 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
345 349 "USEDCHILD");
346 350 zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
347 351 PROP_READONLY,
348 352 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
349 353 zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
350 354 ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
351 355 zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
352 356 ZFS_TYPE_DATASET, "<size>", "WRITTEN");
353 357
354 358 /* default number properties */
355 359 zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
356 360 ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
357 361 zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
358 362 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
359 363 "<size> | none", "RESERV");
360 364 zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
361 365 ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
362 366 zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
363 367 ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
364 368 zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
365 369 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
366 370 "<size> | none", "REFRESERV");
367 371
368 372 /* inherit number properties */
369 373 zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
370 374 SPA_MAXBLOCKSIZE, PROP_INHERIT,
371 375 ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE");
372 376
373 377 /* hidden properties */
374 378 zprop_register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
375 379 PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG");
376 380 zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
377 381 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
378 382 zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
379 383 PROP_READONLY, ZFS_TYPE_DATASET, "NAME");
380 384 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
381 385 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
382 386 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
383 387 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
384 388 "STMF_SBD_LU");
385 389 zprop_register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER,
386 390 PROP_READONLY, ZFS_TYPE_DATASET, "GUID");
387 391 zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
388 392 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
389 393 "USERACCOUNTING");
390 394 zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
391 395 PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
392 396 zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
393 397 PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
394 398
395 399 /* oddball properties */
396 400 zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
397 401 NULL, PROP_READONLY, ZFS_TYPE_DATASET,
398 402 "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
399 403 }
400 404
401 405 boolean_t
402 406 zfs_prop_delegatable(zfs_prop_t prop)
403 407 {
404 408 zprop_desc_t *pd = &zfs_prop_table[prop];
405 409
406 410 /* The mlslabel property is never delegatable. */
407 411 if (prop == ZFS_PROP_MLSLABEL)
408 412 return (B_FALSE);
409 413
410 414 return (pd->pd_attr != PROP_READONLY);
411 415 }
412 416
413 417 /*
414 418 * Given a zfs dataset property name, returns the corresponding property ID.
415 419 */
416 420 zfs_prop_t
417 421 zfs_name_to_prop(const char *propname)
418 422 {
419 423 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
420 424 }
421 425
422 426 /*
423 427 * For user property names, we allow all lowercase alphanumeric characters, plus
424 428 * a few useful punctuation characters.
425 429 */
426 430 static int
427 431 valid_char(char c)
428 432 {
429 433 return ((c >= 'a' && c <= 'z') ||
430 434 (c >= '0' && c <= '9') ||
431 435 c == '-' || c == '_' || c == '.' || c == ':');
432 436 }
433 437
434 438 /*
435 439 * Returns true if this is a valid user-defined property (one with a ':').
436 440 */
437 441 boolean_t
438 442 zfs_prop_user(const char *name)
439 443 {
440 444 int i;
441 445 char c;
442 446 boolean_t foundsep = B_FALSE;
443 447
444 448 for (i = 0; i < strlen(name); i++) {
445 449 c = name[i];
446 450 if (!valid_char(c))
447 451 return (B_FALSE);
448 452 if (c == ':')
449 453 foundsep = B_TRUE;
450 454 }
451 455
452 456 if (!foundsep)
453 457 return (B_FALSE);
454 458
455 459 return (B_TRUE);
456 460 }
457 461
458 462 /*
459 463 * Returns true if this is a valid userspace-type property (one with a '@').
460 464 * Note that after the @, any character is valid (eg, another @, for SID
461 465 * user@domain).
462 466 */
463 467 boolean_t
464 468 zfs_prop_userquota(const char *name)
465 469 {
466 470 zfs_userquota_prop_t prop;
467 471
468 472 for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
469 473 if (strncmp(name, zfs_userquota_prop_prefixes[prop],
470 474 strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
471 475 return (B_TRUE);
472 476 }
473 477 }
474 478
475 479 return (B_FALSE);
476 480 }
477 481
478 482 /*
479 483 * Returns true if this is a valid written@ property.
480 484 * Note that after the @, any character is valid (eg, another @, for
481 485 * written@pool/fs@origin).
482 486 */
483 487 boolean_t
484 488 zfs_prop_written(const char *name)
485 489 {
486 490 static const char *prefix = "written@";
487 491 return (strncmp(name, prefix, strlen(prefix)) == 0);
488 492 }
489 493
490 494 /*
491 495 * Tables of index types, plus functions to convert between the user view
492 496 * (strings) and internal representation (uint64_t).
493 497 */
494 498 int
495 499 zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
496 500 {
497 501 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
498 502 }
499 503
500 504 int
501 505 zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
502 506 {
503 507 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
504 508 }
505 509
506 510 uint64_t
507 511 zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
508 512 {
509 513 return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
510 514 }
511 515
512 516 /*
513 517 * Returns TRUE if the property applies to any of the given dataset types.
514 518 */
515 519 boolean_t
516 520 zfs_prop_valid_for_type(int prop, zfs_type_t types)
517 521 {
518 522 return (zprop_valid_for_type(prop, types));
519 523 }
520 524
521 525 zprop_type_t
522 526 zfs_prop_get_type(zfs_prop_t prop)
523 527 {
524 528 return (zfs_prop_table[prop].pd_proptype);
525 529 }
526 530
527 531 /*
528 532 * Returns TRUE if the property is readonly.
529 533 */
530 534 boolean_t
531 535 zfs_prop_readonly(zfs_prop_t prop)
532 536 {
533 537 return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
534 538 zfs_prop_table[prop].pd_attr == PROP_ONETIME);
535 539 }
536 540
537 541 /*
538 542 * Returns TRUE if the property is only allowed to be set once.
539 543 */
540 544 boolean_t
541 545 zfs_prop_setonce(zfs_prop_t prop)
542 546 {
543 547 return (zfs_prop_table[prop].pd_attr == PROP_ONETIME);
544 548 }
545 549
546 550 const char *
547 551 zfs_prop_default_string(zfs_prop_t prop)
548 552 {
549 553 return (zfs_prop_table[prop].pd_strdefault);
550 554 }
551 555
552 556 uint64_t
553 557 zfs_prop_default_numeric(zfs_prop_t prop)
554 558 {
555 559 return (zfs_prop_table[prop].pd_numdefault);
556 560 }
557 561
558 562 /*
559 563 * Given a dataset property ID, returns the corresponding name.
560 564 * Assuming the zfs dataset property ID is valid.
561 565 */
562 566 const char *
563 567 zfs_prop_to_name(zfs_prop_t prop)
564 568 {
565 569 return (zfs_prop_table[prop].pd_name);
566 570 }
567 571
568 572 /*
569 573 * Returns TRUE if the property is inheritable.
570 574 */
571 575 boolean_t
572 576 zfs_prop_inheritable(zfs_prop_t prop)
573 577 {
574 578 return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
575 579 zfs_prop_table[prop].pd_attr == PROP_ONETIME);
576 580 }
577 581
578 582 #ifndef _KERNEL
579 583
580 584 /*
581 585 * Returns a string describing the set of acceptable values for the given
582 586 * zfs property, or NULL if it cannot be set.
583 587 */
584 588 const char *
585 589 zfs_prop_values(zfs_prop_t prop)
586 590 {
587 591 return (zfs_prop_table[prop].pd_values);
588 592 }
589 593
590 594 /*
591 595 * Returns TRUE if this property is a string type. Note that index types
592 596 * (compression, checksum) are treated as strings in userland, even though they
593 597 * are stored numerically on disk.
594 598 */
595 599 int
596 600 zfs_prop_is_string(zfs_prop_t prop)
597 601 {
598 602 return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
599 603 zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
600 604 }
601 605
602 606 /*
603 607 * Returns the column header for the given property. Used only in
604 608 * 'zfs list -o', but centralized here with the other property information.
605 609 */
606 610 const char *
607 611 zfs_prop_column_name(zfs_prop_t prop)
608 612 {
609 613 return (zfs_prop_table[prop].pd_colname);
610 614 }
611 615
612 616 /*
613 617 * Returns whether the given property should be displayed right-justified for
614 618 * 'zfs list'.
615 619 */
616 620 boolean_t
617 621 zfs_prop_align_right(zfs_prop_t prop)
618 622 {
619 623 return (zfs_prop_table[prop].pd_rightalign);
620 624 }
621 625
622 626 #endif
↓ open down ↓ |
400 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX