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