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