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