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 https://opensource.org/licenses/CDDL-1.0. 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 /* 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright (c) 2011, 2018 by Delphix. All rights reserved. 24 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. 25 * Copyright 2016, Joyent, Inc. 26 * Copyright (c) 2019, Klara Inc. 27 * Copyright (c) 2019, Allan Jude 28 * Copyright (c) 2022 Hewlett Packard Enterprise Development LP. 29 */ 30 31 /* Portions Copyright 2010 Robert Milkowski */ 32 33 #include <sys/zio.h> 34 #include <sys/spa.h> 35 #include <sys/u8_textprep.h> 36 #include <sys/zfs_acl.h> 37 #include <sys/zfs_ioctl.h> 38 #include <sys/zfs_znode.h> 39 #include <sys/dsl_crypt.h> 40 41 #include "zfs_prop.h" 42 #include "zfs_deleg.h" 43 #include "zfs_fletcher.h" 44 45 #if !defined(_KERNEL) 46 #include <stdlib.h> 47 #include <string.h> 48 #include <ctype.h> 49 #endif 50 51 static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; 52 53 /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */ 54 const char *const zfs_userquota_prop_prefixes[] = { 55 "userused@", 56 "userquota@", 57 "groupused@", 58 "groupquota@", 59 "userobjused@", 60 "userobjquota@", 61 "groupobjused@", 62 "groupobjquota@", 63 "projectused@", 64 "projectquota@", 65 "projectobjused@", 66 "projectobjquota@" 67 }; 68 69 zprop_desc_t * 70 zfs_prop_get_table(void) 71 { 72 return (zfs_prop_table); 73 } 74 75 void 76 zfs_prop_init(void) 77 { 78 static const zprop_index_t checksum_table[] = { 79 { "on", ZIO_CHECKSUM_ON }, 80 { "off", ZIO_CHECKSUM_OFF }, 81 { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, 82 { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, 83 { "sha256", ZIO_CHECKSUM_SHA256 }, 84 { "noparity", ZIO_CHECKSUM_NOPARITY }, 85 { "sha512", ZIO_CHECKSUM_SHA512 }, 86 { "skein", ZIO_CHECKSUM_SKEIN }, 87 { "edonr", ZIO_CHECKSUM_EDONR }, 88 { "blake3", ZIO_CHECKSUM_BLAKE3 }, 89 { NULL } 90 }; 91 92 static const zprop_index_t dedup_table[] = { 93 { "on", ZIO_CHECKSUM_ON }, 94 { "off", ZIO_CHECKSUM_OFF }, 95 { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY }, 96 { "sha256", ZIO_CHECKSUM_SHA256 }, 97 { "sha256,verify", 98 ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY }, 99 { "sha512", ZIO_CHECKSUM_SHA512 }, 100 { "sha512,verify", 101 ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY }, 102 { "skein", ZIO_CHECKSUM_SKEIN }, 103 { "skein,verify", 104 ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY }, 105 { "edonr,verify", 106 ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY }, 107 { "blake3", ZIO_CHECKSUM_BLAKE3 }, 108 { "blake3,verify", 109 ZIO_CHECKSUM_BLAKE3 | ZIO_CHECKSUM_VERIFY }, 110 { NULL } 111 }; 112 113 static const zprop_index_t compress_table[] = { 114 { "on", ZIO_COMPRESS_ON }, 115 { "off", ZIO_COMPRESS_OFF }, 116 { "lzjb", ZIO_COMPRESS_LZJB }, 117 { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ 118 { "gzip-1", ZIO_COMPRESS_GZIP_1 }, 119 { "gzip-2", ZIO_COMPRESS_GZIP_2 }, 120 { "gzip-3", ZIO_COMPRESS_GZIP_3 }, 121 { "gzip-4", ZIO_COMPRESS_GZIP_4 }, 122 { "gzip-5", ZIO_COMPRESS_GZIP_5 }, 123 { "gzip-6", ZIO_COMPRESS_GZIP_6 }, 124 { "gzip-7", ZIO_COMPRESS_GZIP_7 }, 125 { "gzip-8", ZIO_COMPRESS_GZIP_8 }, 126 { "gzip-9", ZIO_COMPRESS_GZIP_9 }, 127 { "zle", ZIO_COMPRESS_ZLE }, 128 { "lz4", ZIO_COMPRESS_LZ4 }, 129 { "zstd", ZIO_COMPRESS_ZSTD }, 130 { "zstd-fast", 131 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_DEFAULT) }, 132 133 /* 134 * ZSTD 1-19 are synthetic. We store the compression level in a 135 * separate hidden property to avoid wasting a large amount of 136 * space in the ZIO_COMPRESS enum. 137 * 138 * The compression level is also stored within the header of the 139 * compressed block since we may need it for later recompression 140 * to avoid checksum errors (L2ARC). 141 * 142 * Note that the level here is defined as bit shifted mask on 143 * top of the method. 144 */ 145 { "zstd-1", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_1) }, 146 { "zstd-2", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_2) }, 147 { "zstd-3", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_3) }, 148 { "zstd-4", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_4) }, 149 { "zstd-5", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_5) }, 150 { "zstd-6", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_6) }, 151 { "zstd-7", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_7) }, 152 { "zstd-8", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_8) }, 153 { "zstd-9", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_9) }, 154 { "zstd-10", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_10) }, 155 { "zstd-11", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_11) }, 156 { "zstd-12", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_12) }, 157 { "zstd-13", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_13) }, 158 { "zstd-14", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_14) }, 159 { "zstd-15", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_15) }, 160 { "zstd-16", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_16) }, 161 { "zstd-17", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_17) }, 162 { "zstd-18", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_18) }, 163 { "zstd-19", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_19) }, 164 165 /* 166 * The ZSTD-Fast levels are also synthetic. 167 */ 168 { "zstd-fast-1", 169 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1) }, 170 { "zstd-fast-2", 171 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_2) }, 172 { "zstd-fast-3", 173 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_3) }, 174 { "zstd-fast-4", 175 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_4) }, 176 { "zstd-fast-5", 177 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_5) }, 178 { "zstd-fast-6", 179 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_6) }, 180 { "zstd-fast-7", 181 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_7) }, 182 { "zstd-fast-8", 183 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_8) }, 184 { "zstd-fast-9", 185 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_9) }, 186 { "zstd-fast-10", 187 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_10) }, 188 { "zstd-fast-20", 189 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_20) }, 190 { "zstd-fast-30", 191 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_30) }, 192 { "zstd-fast-40", 193 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_40) }, 194 { "zstd-fast-50", 195 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_50) }, 196 { "zstd-fast-60", 197 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_60) }, 198 { "zstd-fast-70", 199 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_70) }, 200 { "zstd-fast-80", 201 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_80) }, 202 { "zstd-fast-90", 203 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_90) }, 204 { "zstd-fast-100", 205 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_100) }, 206 { "zstd-fast-500", 207 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_500) }, 208 { "zstd-fast-1000", 209 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1000) }, 210 { NULL } 211 }; 212 213 static const zprop_index_t crypto_table[] = { 214 { "on", ZIO_CRYPT_ON }, 215 { "off", ZIO_CRYPT_OFF }, 216 { "aes-128-ccm", ZIO_CRYPT_AES_128_CCM }, 217 { "aes-192-ccm", ZIO_CRYPT_AES_192_CCM }, 218 { "aes-256-ccm", ZIO_CRYPT_AES_256_CCM }, 219 { "aes-128-gcm", ZIO_CRYPT_AES_128_GCM }, 220 { "aes-192-gcm", ZIO_CRYPT_AES_192_GCM }, 221 { "aes-256-gcm", ZIO_CRYPT_AES_256_GCM }, 222 { NULL } 223 }; 224 225 static const zprop_index_t keyformat_table[] = { 226 { "none", ZFS_KEYFORMAT_NONE }, 227 { "raw", ZFS_KEYFORMAT_RAW }, 228 { "hex", ZFS_KEYFORMAT_HEX }, 229 { "passphrase", ZFS_KEYFORMAT_PASSPHRASE }, 230 { NULL } 231 }; 232 233 static const zprop_index_t snapdir_table[] = { 234 { "hidden", ZFS_SNAPDIR_HIDDEN }, 235 { "visible", ZFS_SNAPDIR_VISIBLE }, 236 { NULL } 237 }; 238 239 static const zprop_index_t snapdev_table[] = { 240 { "hidden", ZFS_SNAPDEV_HIDDEN }, 241 { "visible", ZFS_SNAPDEV_VISIBLE }, 242 { NULL } 243 }; 244 245 static const zprop_index_t acl_mode_table[] = { 246 { "discard", ZFS_ACL_DISCARD }, 247 { "groupmask", ZFS_ACL_GROUPMASK }, 248 { "passthrough", ZFS_ACL_PASSTHROUGH }, 249 { "restricted", ZFS_ACL_RESTRICTED }, 250 { NULL } 251 }; 252 253 static const zprop_index_t acltype_table[] = { 254 { "off", ZFS_ACLTYPE_OFF }, 255 { "posix", ZFS_ACLTYPE_POSIX }, 256 { "nfsv4", ZFS_ACLTYPE_NFSV4 }, 257 { "disabled", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */ 258 { "noacl", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */ 259 { "posixacl", ZFS_ACLTYPE_POSIX }, /* bkwrd compatibility */ 260 { NULL } 261 }; 262 263 static const zprop_index_t acl_inherit_table[] = { 264 { "discard", ZFS_ACL_DISCARD }, 265 { "noallow", ZFS_ACL_NOALLOW }, 266 { "restricted", ZFS_ACL_RESTRICTED }, 267 { "passthrough", ZFS_ACL_PASSTHROUGH }, 268 { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatibility */ 269 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X }, 270 { NULL } 271 }; 272 273 static const zprop_index_t case_table[] = { 274 { "sensitive", ZFS_CASE_SENSITIVE }, 275 { "insensitive", ZFS_CASE_INSENSITIVE }, 276 { "mixed", ZFS_CASE_MIXED }, 277 { NULL } 278 }; 279 280 static const zprop_index_t copies_table[] = { 281 { "1", 1 }, 282 { "2", 2 }, 283 { "3", 3 }, 284 { NULL } 285 }; 286 287 /* 288 * Use the unique flags we have to send to u8_strcmp() and/or 289 * u8_textprep() to represent the various normalization property 290 * values. 291 */ 292 static const zprop_index_t normalize_table[] = { 293 { "none", 0 }, 294 { "formD", U8_TEXTPREP_NFD }, 295 { "formKC", U8_TEXTPREP_NFKC }, 296 { "formC", U8_TEXTPREP_NFC }, 297 { "formKD", U8_TEXTPREP_NFKD }, 298 { NULL } 299 }; 300 301 static const zprop_index_t version_table[] = { 302 { "1", 1 }, 303 { "2", 2 }, 304 { "3", 3 }, 305 { "4", 4 }, 306 { "5", 5 }, 307 { "current", ZPL_VERSION }, 308 { NULL } 309 }; 310 311 static const zprop_index_t boolean_table[] = { 312 { "off", 0 }, 313 { "on", 1 }, 314 { NULL } 315 }; 316 317 static const zprop_index_t keystatus_table[] = { 318 { "none", ZFS_KEYSTATUS_NONE}, 319 { "unavailable", ZFS_KEYSTATUS_UNAVAILABLE}, 320 { "available", ZFS_KEYSTATUS_AVAILABLE}, 321 { NULL } 322 }; 323 324 static const zprop_index_t logbias_table[] = { 325 { "latency", ZFS_LOGBIAS_LATENCY }, 326 { "throughput", ZFS_LOGBIAS_THROUGHPUT }, 327 { NULL } 328 }; 329 330 static const zprop_index_t canmount_table[] = { 331 { "off", ZFS_CANMOUNT_OFF }, 332 { "on", ZFS_CANMOUNT_ON }, 333 { "noauto", ZFS_CANMOUNT_NOAUTO }, 334 { NULL } 335 }; 336 337 static const zprop_index_t cache_table[] = { 338 { "none", ZFS_CACHE_NONE }, 339 { "metadata", ZFS_CACHE_METADATA }, 340 { "all", ZFS_CACHE_ALL }, 341 { NULL } 342 }; 343 344 static const zprop_index_t sync_table[] = { 345 { "standard", ZFS_SYNC_STANDARD }, 346 { "always", ZFS_SYNC_ALWAYS }, 347 { "disabled", ZFS_SYNC_DISABLED }, 348 { NULL } 349 }; 350 351 static const zprop_index_t xattr_table[] = { 352 { "off", ZFS_XATTR_OFF }, 353 { "on", ZFS_XATTR_DIR }, 354 { "sa", ZFS_XATTR_SA }, 355 { "dir", ZFS_XATTR_DIR }, 356 { NULL } 357 }; 358 359 static const zprop_index_t dnsize_table[] = { 360 { "legacy", ZFS_DNSIZE_LEGACY }, 361 { "auto", ZFS_DNSIZE_AUTO }, 362 { "1k", ZFS_DNSIZE_1K }, 363 { "2k", ZFS_DNSIZE_2K }, 364 { "4k", ZFS_DNSIZE_4K }, 365 { "8k", ZFS_DNSIZE_8K }, 366 { "16k", ZFS_DNSIZE_16K }, 367 { NULL } 368 }; 369 370 static const zprop_index_t redundant_metadata_table[] = { 371 { "all", ZFS_REDUNDANT_METADATA_ALL }, 372 { "most", ZFS_REDUNDANT_METADATA_MOST }, 373 { "some", ZFS_REDUNDANT_METADATA_SOME }, 374 { "none", ZFS_REDUNDANT_METADATA_NONE }, 375 { NULL } 376 }; 377 378 static const zprop_index_t volmode_table[] = { 379 { "default", ZFS_VOLMODE_DEFAULT }, 380 { "full", ZFS_VOLMODE_GEOM }, 381 { "geom", ZFS_VOLMODE_GEOM }, 382 { "dev", ZFS_VOLMODE_DEV }, 383 { "none", ZFS_VOLMODE_NONE }, 384 { NULL } 385 }; 386 387 struct zfs_mod_supported_features *sfeatures = 388 zfs_mod_list_supported(ZFS_SYSFS_DATASET_PROPERTIES); 389 390 /* inherit index properties */ 391 zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata", 392 ZFS_REDUNDANT_METADATA_ALL, 393 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 394 "all | most | some | none", "REDUND_MD", 395 redundant_metadata_table, sfeatures); 396 zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD, 397 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 398 "standard | always | disabled", "SYNC", 399 sync_table, sfeatures); 400 zprop_register_index(ZFS_PROP_CHECKSUM, "checksum", 401 ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | 402 ZFS_TYPE_VOLUME, 403 "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein" 404 " | edonr | blake3", 405 "CHECKSUM", checksum_table, sfeatures); 406 zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF, 407 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 408 "on | off | verify | sha256[,verify] | sha512[,verify] | " 409 "skein[,verify] | edonr,verify | blake3[,verify]", 410 "DEDUP", dedup_table, sfeatures); 411 zprop_register_index(ZFS_PROP_COMPRESSION, "compression", 412 ZIO_COMPRESS_DEFAULT, PROP_INHERIT, 413 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 414 "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | " 415 "zstd | zstd-[1-19] | " 416 "zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]", 417 "COMPRESS", compress_table, sfeatures); 418 zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, 419 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 420 "hidden | visible", "SNAPDIR", snapdir_table, sfeatures); 421 zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN, 422 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 423 "hidden | visible", "SNAPDEV", snapdev_table, sfeatures); 424 zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD, 425 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 426 "discard | groupmask | passthrough | restricted", "ACLMODE", 427 acl_mode_table, sfeatures); 428 zprop_register_index(ZFS_PROP_ACLTYPE, "acltype", 429 #ifdef __linux__ 430 /* Linux doesn't natively support ZFS's NFSv4-style ACLs. */ 431 ZFS_ACLTYPE_OFF, 432 #else 433 ZFS_ACLTYPE_NFSV4, 434 #endif 435 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 436 "off | nfsv4 | posix", "ACLTYPE", acltype_table, sfeatures); 437 zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit", 438 ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 439 "discard | noallow | restricted | passthrough | passthrough-x", 440 "ACLINHERIT", acl_inherit_table, sfeatures); 441 zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT, 442 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 443 "1 | 2 | 3", "COPIES", copies_table, sfeatures); 444 zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", 445 ZFS_CACHE_ALL, PROP_INHERIT, 446 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 447 "all | none | metadata", "PRIMARYCACHE", cache_table, sfeatures); 448 zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", 449 ZFS_CACHE_ALL, PROP_INHERIT, 450 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 451 "all | none | metadata", "SECONDARYCACHE", cache_table, sfeatures); 452 zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY, 453 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 454 "latency | throughput", "LOGBIAS", logbias_table, sfeatures); 455 zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR, 456 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 457 "on | off | dir | sa", "XATTR", xattr_table, sfeatures); 458 zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize", 459 ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 460 "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table, 461 sfeatures); 462 zprop_register_index(ZFS_PROP_VOLMODE, "volmode", 463 ZFS_VOLMODE_DEFAULT, PROP_INHERIT, 464 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 465 "default | full | geom | dev | none", "VOLMODE", volmode_table, 466 sfeatures); 467 468 /* inherit index (boolean) properties */ 469 zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, 470 ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table, sfeatures); 471 zprop_register_index(ZFS_PROP_RELATIME, "relatime", 1, PROP_INHERIT, 472 ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table, 473 sfeatures); 474 zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, 475 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", 476 boolean_table, sfeatures); 477 zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, 478 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", 479 boolean_table, sfeatures); 480 zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, 481 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", 482 boolean_table, sfeatures); 483 zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, 484 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", 485 boolean_table, sfeatures); 486 #ifdef __FreeBSD__ 487 zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT, 488 ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table, 489 sfeatures); 490 #else 491 zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT, 492 ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table, sfeatures); 493 #endif 494 zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, 495 ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table, sfeatures); 496 zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT, 497 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND", 498 boolean_table, sfeatures); 499 zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT, 500 ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table, 501 sfeatures); 502 503 /* default index properties */ 504 zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, 505 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 506 "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table, sfeatures); 507 zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, 508 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", 509 "CANMOUNT", canmount_table, sfeatures); 510 511 /* readonly index properties */ 512 zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, 513 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table, 514 sfeatures); 515 zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0, 516 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY", 517 boolean_table, sfeatures); 518 zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus", 519 ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET, 520 "none | unavailable | available", 521 "KEYSTATUS", keystatus_table, sfeatures); 522 523 /* set once index properties */ 524 zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0, 525 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 526 "none | formC | formD | formKC | formKD", "NORMALIZATION", 527 normalize_table, sfeatures); 528 zprop_register_index(ZFS_PROP_CASE, "casesensitivity", 529 ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM | 530 ZFS_TYPE_SNAPSHOT, 531 "sensitive | insensitive | mixed", "CASE", case_table, sfeatures); 532 zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat", 533 ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT, 534 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 535 "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table, 536 sfeatures); 537 zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption", 538 ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET, 539 "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | " 540 "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION", 541 crypto_table, sfeatures); 542 543 /* set once index (boolean) properties */ 544 zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, 545 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 546 "on | off", "UTF8ONLY", boolean_table, sfeatures); 547 548 /* string properties */ 549 zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, 550 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN", 551 sfeatures); 552 zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY, 553 ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES", sfeatures); 554 zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", 555 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", 556 "MOUNTPOINT", sfeatures); 557 zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", 558 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | NFS share options", 559 "SHARENFS", sfeatures); 560 zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, 561 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, 562 "filesystem | volume | snapshot | bookmark", "TYPE", sfeatures); 563 zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", 564 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 565 "on | off | SMB share options", "SHARESMB", sfeatures); 566 zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel", 567 ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET, 568 "<sensitivity label>", "MLSLABEL", sfeatures); 569 zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context", 570 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux context>", 571 "CONTEXT", sfeatures); 572 zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext", 573 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux fscontext>", 574 "FSCONTEXT", sfeatures); 575 zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext", 576 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux defcontext>", 577 "DEFCONTEXT", sfeatures); 578 zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext", 579 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux rootcontext>", 580 "ROOTCONTEXT", sfeatures); 581 zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN, 582 "receive_resume_token", 583 NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 584 "<string token>", "RESUMETOK", sfeatures); 585 zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL, 586 PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>", 587 "ENCROOT", sfeatures); 588 zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation", 589 "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 590 "prompt | <file URI> | <https URL> | <http URL>", "KEYLOCATION", 591 sfeatures); 592 zprop_register_string(ZFS_PROP_REDACT_SNAPS, 593 "redact_snaps", NULL, PROP_READONLY, 594 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<snapshot>[,...]", 595 "RSNAPS", sfeatures); 596 597 /* readonly number properties */ 598 zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, 599 ZFS_TYPE_DATASET, "<size>", "USED", B_FALSE, sfeatures); 600 zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, 601 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL", 602 B_FALSE, sfeatures); 603 zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0, 604 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>", 605 "REFER", B_FALSE, sfeatures); 606 zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, 607 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, 608 "<1.00x or higher if compressed>", "RATIO", B_FALSE, sfeatures); 609 zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0, 610 PROP_READONLY, ZFS_TYPE_DATASET, 611 "<1.00x or higher if compressed>", "REFRATIO", B_FALSE, sfeatures); 612 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 613 ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME, 614 ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK", B_FALSE, 615 sfeatures); 616 zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, 617 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 618 "USEDSNAP", B_FALSE, sfeatures); 619 zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, 620 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 621 "USEDDS", B_FALSE, sfeatures); 622 zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, 623 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 624 "USEDCHILD", B_FALSE, sfeatures); 625 zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, 626 PROP_READONLY, 627 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV", 628 B_FALSE, sfeatures); 629 zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY, 630 ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS", B_FALSE, sfeatures); 631 zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY, 632 ZFS_TYPE_DATASET, "<size>", "WRITTEN", B_FALSE, sfeatures); 633 zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0, 634 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 635 "LUSED", B_FALSE, sfeatures); 636 zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced", 637 0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>", 638 "LREFER", B_FALSE, sfeatures); 639 zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count", 640 UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM, 641 "<count>", "FSCOUNT", B_FALSE, sfeatures); 642 zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count", 643 UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 644 "<count>", "SSCOUNT", B_FALSE, sfeatures); 645 zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY, 646 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID", 647 B_TRUE, sfeatures); 648 zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY, 649 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG", 650 B_TRUE, sfeatures); 651 zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters", 652 0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 653 "<iters>", "PBKDF2ITERS", B_TRUE, sfeatures); 654 zprop_register_number(ZFS_PROP_OBJSETID, "objsetid", 0, 655 PROP_READONLY, ZFS_TYPE_DATASET, "<uint64>", "OBJSETID", B_TRUE, 656 sfeatures); 657 658 /* default number properties */ 659 zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, 660 ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA", B_FALSE, sfeatures); 661 zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0, 662 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 663 "<size> | none", "RESERV", B_FALSE, sfeatures); 664 zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, 665 ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE", 666 B_FALSE, sfeatures); 667 zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, 668 ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA", B_FALSE, 669 sfeatures); 670 zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, 671 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 672 "<size> | none", "REFRESERV", B_FALSE, sfeatures); 673 zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit", 674 UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, 675 "<count> | none", "FSLIMIT", B_FALSE, sfeatures); 676 zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit", 677 UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 678 "<count> | none", "SSLIMIT", B_FALSE, sfeatures); 679 680 /* inherit number properties */ 681 zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize", 682 SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT, 683 ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE", B_FALSE, 684 sfeatures); 685 zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS, 686 "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 687 "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS", B_FALSE, 688 sfeatures); 689 690 /* hidden properties */ 691 zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, 692 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES", B_FALSE, sfeatures); 693 zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, 694 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME", 695 B_TRUE, sfeatures); 696 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", 697 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS", 698 B_TRUE, sfeatures); 699 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu", 700 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, 701 "STMF_SBD_LU", B_TRUE, sfeatures); 702 zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting", 703 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, 704 "USERACCOUNTING", B_FALSE, sfeatures); 705 zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER, 706 PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE", B_FALSE, sfeatures); 707 zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent", 708 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT", 709 B_FALSE, sfeatures); 710 zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid", 711 PROP_TYPE_NUMBER, PROP_READONLY, 712 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID", B_TRUE, 713 sfeatures); 714 zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING, 715 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP", 716 B_TRUE, sfeatures); 717 zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt", 718 PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT, 719 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT", B_FALSE, 720 sfeatures); 721 zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER, 722 PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID", B_TRUE, sfeatures); 723 zprop_register_hidden(ZFS_PROP_REDACTED, "redacted", PROP_TYPE_NUMBER, 724 PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED", B_FALSE, sfeatures); 725 726 /* 727 * Properties that are obsolete and not used. These are retained so 728 * that we don't have to change the values of the zfs_prop_t enum, or 729 * have NULL pointers in the zfs_prop_table[]. 730 */ 731 zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER, 732 PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG", B_FALSE, sfeatures); 733 734 /* oddball properties */ 735 /* 'creation' is a number but displayed as human-readable => flex */ 736 zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, 737 NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, 738 "<date>", "CREATION", B_FALSE, B_TRUE, B_TRUE, NULL, sfeatures); 739 740 zprop_register_impl(ZFS_PROP_SNAPSHOTS_CHANGED, "snapshots_changed", 741 PROP_TYPE_NUMBER, 0, NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | 742 ZFS_TYPE_VOLUME, "<date>", "SNAPSHOTS_CHANGED", B_FALSE, B_TRUE, 743 B_TRUE, NULL, sfeatures); 744 745 zfs_mod_list_supported_free(sfeatures); 746 } 747 748 boolean_t 749 zfs_prop_delegatable(zfs_prop_t prop) 750 { 751 ASSERT3S(prop, >=, 0); 752 ASSERT3S(prop, <, ZFS_NUM_PROPS); 753 zprop_desc_t *pd = &zfs_prop_table[prop]; 754 755 /* The mlslabel property is never delegatable. */ 756 if (prop == ZFS_PROP_MLSLABEL) 757 return (B_FALSE); 758 759 return (pd->pd_attr != PROP_READONLY); 760 } 761 762 /* 763 * Given a zfs dataset property name, returns the corresponding property ID. 764 */ 765 zfs_prop_t 766 zfs_name_to_prop(const char *propname) 767 { 768 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); 769 } 770 771 /* 772 * Returns true if this is a valid user-defined property (one with a ':'). 773 */ 774 boolean_t 775 zfs_prop_user(const char *name) 776 { 777 int i; 778 char c; 779 boolean_t foundsep = B_FALSE; 780 781 for (i = 0; i < strlen(name); i++) { 782 c = name[i]; 783 if (!zprop_valid_char(c)) 784 return (B_FALSE); 785 if (c == ':') 786 foundsep = B_TRUE; 787 } 788 789 if (!foundsep) 790 return (B_FALSE); 791 792 return (B_TRUE); 793 } 794 795 /* 796 * Returns true if this is a valid userspace-type property (one with a '@'). 797 * Note that after the @, any character is valid (eg, another @, for SID 798 * user@domain). 799 */ 800 boolean_t 801 zfs_prop_userquota(const char *name) 802 { 803 zfs_userquota_prop_t prop; 804 805 for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) { 806 if (strncmp(name, zfs_userquota_prop_prefixes[prop], 807 strlen(zfs_userquota_prop_prefixes[prop])) == 0) { 808 return (B_TRUE); 809 } 810 } 811 812 return (B_FALSE); 813 } 814 815 /* 816 * Returns true if this is a valid written@ property. 817 * Note that after the @, any character is valid (eg, another @, for 818 * written@pool/fs@origin). 819 */ 820 boolean_t 821 zfs_prop_written(const char *name) 822 { 823 static const char *prop_prefix = "written@"; 824 static const char *book_prefix = "written#"; 825 return (strncmp(name, prop_prefix, strlen(prop_prefix)) == 0 || 826 strncmp(name, book_prefix, strlen(book_prefix)) == 0); 827 } 828 829 /* 830 * Tables of index types, plus functions to convert between the user view 831 * (strings) and internal representation (uint64_t). 832 */ 833 int 834 zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) 835 { 836 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); 837 } 838 839 int 840 zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) 841 { 842 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); 843 } 844 845 uint64_t 846 zfs_prop_random_value(zfs_prop_t prop, uint64_t seed) 847 { 848 return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET)); 849 } 850 851 /* 852 * Returns TRUE if the property applies to any of the given dataset types. 853 */ 854 boolean_t 855 zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck) 856 { 857 return (zprop_valid_for_type(prop, types, headcheck)); 858 } 859 860 zprop_type_t 861 zfs_prop_get_type(zfs_prop_t prop) 862 { 863 ASSERT3S(prop, >=, 0); 864 ASSERT3S(prop, <, ZFS_NUM_PROPS); 865 return (zfs_prop_table[prop].pd_proptype); 866 } 867 868 /* 869 * Returns TRUE if the property is readonly. 870 */ 871 boolean_t 872 zfs_prop_readonly(zfs_prop_t prop) 873 { 874 ASSERT3S(prop, >=, 0); 875 ASSERT3S(prop, <, ZFS_NUM_PROPS); 876 return (zfs_prop_table[prop].pd_attr == PROP_READONLY || 877 zfs_prop_table[prop].pd_attr == PROP_ONETIME || 878 zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT); 879 } 880 881 /* 882 * Returns TRUE if the property is visible (not hidden). 883 */ 884 boolean_t 885 zfs_prop_visible(zfs_prop_t prop) 886 { 887 ASSERT3S(prop, >=, 0); 888 ASSERT3S(prop, <, ZFS_NUM_PROPS); 889 return (zfs_prop_table[prop].pd_visible && 890 zfs_prop_table[prop].pd_zfs_mod_supported); 891 } 892 893 /* 894 * Returns TRUE if the property is only allowed to be set once. 895 */ 896 boolean_t 897 zfs_prop_setonce(zfs_prop_t prop) 898 { 899 ASSERT3S(prop, >=, 0); 900 ASSERT3S(prop, <, ZFS_NUM_PROPS); 901 return (zfs_prop_table[prop].pd_attr == PROP_ONETIME || 902 zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT); 903 } 904 905 const char * 906 zfs_prop_default_string(zfs_prop_t prop) 907 { 908 ASSERT3S(prop, >=, 0); 909 ASSERT3S(prop, <, ZFS_NUM_PROPS); 910 return (zfs_prop_table[prop].pd_strdefault); 911 } 912 913 uint64_t 914 zfs_prop_default_numeric(zfs_prop_t prop) 915 { 916 ASSERT3S(prop, >=, 0); 917 ASSERT3S(prop, <, ZFS_NUM_PROPS); 918 return (zfs_prop_table[prop].pd_numdefault); 919 } 920 921 /* 922 * Given a dataset property ID, returns the corresponding name. 923 * Assuming the zfs dataset property ID is valid. 924 */ 925 const char * 926 zfs_prop_to_name(zfs_prop_t prop) 927 { 928 ASSERT3S(prop, >=, 0); 929 ASSERT3S(prop, <, ZFS_NUM_PROPS); 930 return (zfs_prop_table[prop].pd_name); 931 } 932 933 /* 934 * Returns TRUE if the property is inheritable. 935 */ 936 boolean_t 937 zfs_prop_inheritable(zfs_prop_t prop) 938 { 939 ASSERT3S(prop, >=, 0); 940 ASSERT3S(prop, <, ZFS_NUM_PROPS); 941 return (zfs_prop_table[prop].pd_attr == PROP_INHERIT || 942 zfs_prop_table[prop].pd_attr == PROP_ONETIME); 943 } 944 945 /* 946 * Returns TRUE if property is one of the encryption properties that requires 947 * a loaded encryption key to modify. 948 */ 949 boolean_t 950 zfs_prop_encryption_key_param(zfs_prop_t prop) 951 { 952 /* 953 * keylocation does not count as an encryption property. It can be 954 * changed at will without needing the master keys. 955 */ 956 return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS || 957 prop == ZFS_PROP_KEYFORMAT); 958 } 959 960 /* 961 * Helper function used by both kernelspace and userspace to check the 962 * keylocation property. If encrypted is set, the keylocation must be valid 963 * for an encrypted dataset. 964 */ 965 boolean_t 966 zfs_prop_valid_keylocation(const char *str, boolean_t encrypted) 967 { 968 if (strcmp("none", str) == 0) 969 return (!encrypted); 970 else if (strcmp("prompt", str) == 0) 971 return (B_TRUE); 972 else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0) 973 return (B_TRUE); 974 else if (strlen(str) > 8 && strncmp("https://", str, 8) == 0) 975 return (B_TRUE); 976 else if (strlen(str) > 7 && strncmp("http://", str, 7) == 0) 977 return (B_TRUE); 978 979 return (B_FALSE); 980 } 981 982 983 #ifndef _KERNEL 984 #include <libzfs.h> 985 986 /* 987 * Returns a string describing the set of acceptable values for the given 988 * zfs property, or NULL if it cannot be set. 989 */ 990 const char * 991 zfs_prop_values(zfs_prop_t prop) 992 { 993 ASSERT3S(prop, >=, 0); 994 ASSERT3S(prop, <, ZFS_NUM_PROPS); 995 return (zfs_prop_table[prop].pd_values); 996 } 997 998 /* 999 * Returns TRUE if this property is a string type. Note that index types 1000 * (compression, checksum) are treated as strings in userland, even though they 1001 * are stored numerically on disk. 1002 */ 1003 int 1004 zfs_prop_is_string(zfs_prop_t prop) 1005 { 1006 ASSERT3S(prop, >=, 0); 1007 ASSERT3S(prop, <, ZFS_NUM_PROPS); 1008 return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || 1009 zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); 1010 } 1011 1012 /* 1013 * Returns the column header for the given property. Used only in 1014 * 'zfs list -o', but centralized here with the other property information. 1015 */ 1016 const char * 1017 zfs_prop_column_name(zfs_prop_t prop) 1018 { 1019 ASSERT3S(prop, >=, 0); 1020 ASSERT3S(prop, <, ZFS_NUM_PROPS); 1021 return (zfs_prop_table[prop].pd_colname); 1022 } 1023 1024 /* 1025 * Returns whether the given property should be displayed right-justified for 1026 * 'zfs list'. 1027 */ 1028 boolean_t 1029 zfs_prop_align_right(zfs_prop_t prop) 1030 { 1031 ASSERT3S(prop, >=, 0); 1032 ASSERT3S(prop, <, ZFS_NUM_PROPS); 1033 return (zfs_prop_table[prop].pd_rightalign); 1034 } 1035 1036 #endif 1037 1038 #if defined(_KERNEL) 1039 1040 #include <sys/simd.h> 1041 1042 #if defined(HAVE_KERNEL_FPU_INTERNAL) 1043 uint8_t **zfs_kfpu_fpregs; 1044 EXPORT_SYMBOL(zfs_kfpu_fpregs); 1045 #endif /* defined(HAVE_KERNEL_FPU_INTERNAL) */ 1046 1047 extern int __init zcommon_init(void); 1048 extern void zcommon_fini(void); 1049 1050 int __init 1051 zcommon_init(void) 1052 { 1053 int error = kfpu_init(); 1054 if (error) 1055 return (error); 1056 1057 fletcher_4_init(); 1058 1059 return (0); 1060 } 1061 1062 void 1063 zcommon_fini(void) 1064 { 1065 fletcher_4_fini(); 1066 kfpu_fini(); 1067 } 1068 1069 #ifdef __FreeBSD__ 1070 module_init_early(zcommon_init); 1071 module_exit(zcommon_fini); 1072 #endif 1073 1074 #endif 1075 1076 /* zfs dataset property functions */ 1077 EXPORT_SYMBOL(zfs_userquota_prop_prefixes); 1078 EXPORT_SYMBOL(zfs_prop_init); 1079 EXPORT_SYMBOL(zfs_prop_get_type); 1080 EXPORT_SYMBOL(zfs_prop_get_table); 1081 EXPORT_SYMBOL(zfs_prop_delegatable); 1082 EXPORT_SYMBOL(zfs_prop_visible); 1083 1084 /* Dataset property functions shared between libzfs and kernel. */ 1085 EXPORT_SYMBOL(zfs_prop_default_string); 1086 EXPORT_SYMBOL(zfs_prop_default_numeric); 1087 EXPORT_SYMBOL(zfs_prop_readonly); 1088 EXPORT_SYMBOL(zfs_prop_inheritable); 1089 EXPORT_SYMBOL(zfs_prop_encryption_key_param); 1090 EXPORT_SYMBOL(zfs_prop_valid_keylocation); 1091 EXPORT_SYMBOL(zfs_prop_setonce); 1092 EXPORT_SYMBOL(zfs_prop_to_name); 1093 EXPORT_SYMBOL(zfs_name_to_prop); 1094 EXPORT_SYMBOL(zfs_prop_user); 1095 EXPORT_SYMBOL(zfs_prop_userquota); 1096 EXPORT_SYMBOL(zfs_prop_index_to_string); 1097 EXPORT_SYMBOL(zfs_prop_string_to_index); 1098 EXPORT_SYMBOL(zfs_prop_valid_for_type); 1099 EXPORT_SYMBOL(zfs_prop_written); 1100