Path: blob/main/sys/contrib/openzfs/module/zcommon/zfs_prop.c
48383 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* 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.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/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 Jude28* Copyright (c) 2022 Hewlett Packard Enterprise Development LP.29*/3031/* Portions Copyright 2010 Robert Milkowski */3233#if defined(_KERNEL)34#include <sys/simd.h>35#endif3637#include <sys/zio.h>38#include <sys/spa.h>39#include <sys/u8_textprep.h>40#include <sys/zfs_acl.h>41#include <sys/zfs_ioctl.h>42#include <sys/zfs_znode.h>43#include <sys/dsl_crypt.h>44#include <sys/simd.h>4546#include "zfs_prop.h"47#include "zfs_deleg.h"48#include "zfs_fletcher.h"4950#if !defined(_KERNEL)51#include <stdlib.h>52#include <string.h>53#include <ctype.h>54#endif5556static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];5758/* Note this is indexed by zfs_userquota_prop_t, keep the order the same */59const char *const zfs_userquota_prop_prefixes[] = {60"userused@",61"userquota@",62"groupused@",63"groupquota@",64"userobjused@",65"userobjquota@",66"groupobjused@",67"groupobjquota@",68"projectused@",69"projectquota@",70"projectobjused@",71"projectobjquota@"72};7374zprop_desc_t *75zfs_prop_get_table(void)76{77return (zfs_prop_table);78}7980void81zfs_prop_init(void)82{83static const zprop_index_t checksum_table[] = {84{ "on", ZIO_CHECKSUM_ON },85{ "off", ZIO_CHECKSUM_OFF },86{ "fletcher2", ZIO_CHECKSUM_FLETCHER_2 },87{ "fletcher4", ZIO_CHECKSUM_FLETCHER_4 },88{ "sha256", ZIO_CHECKSUM_SHA256 },89{ "noparity", ZIO_CHECKSUM_NOPARITY },90{ "sha512", ZIO_CHECKSUM_SHA512 },91{ "skein", ZIO_CHECKSUM_SKEIN },92{ "edonr", ZIO_CHECKSUM_EDONR },93{ "blake3", ZIO_CHECKSUM_BLAKE3 },94{ NULL }95};9697static const zprop_index_t dedup_table[] = {98{ "on", ZIO_CHECKSUM_ON },99{ "off", ZIO_CHECKSUM_OFF },100{ "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },101{ "sha256", ZIO_CHECKSUM_SHA256 },102{ "sha256,verify",103ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },104{ "sha512", ZIO_CHECKSUM_SHA512 },105{ "sha512,verify",106ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY },107{ "skein", ZIO_CHECKSUM_SKEIN },108{ "skein,verify",109ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY },110{ "edonr,verify",111ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY },112{ "blake3", ZIO_CHECKSUM_BLAKE3 },113{ "blake3,verify",114ZIO_CHECKSUM_BLAKE3 | ZIO_CHECKSUM_VERIFY },115{ NULL }116};117118static const zprop_index_t compress_table[] = {119{ "on", ZIO_COMPRESS_ON },120{ "off", ZIO_COMPRESS_OFF },121{ "lzjb", ZIO_COMPRESS_LZJB },122{ "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */123{ "gzip-1", ZIO_COMPRESS_GZIP_1 },124{ "gzip-2", ZIO_COMPRESS_GZIP_2 },125{ "gzip-3", ZIO_COMPRESS_GZIP_3 },126{ "gzip-4", ZIO_COMPRESS_GZIP_4 },127{ "gzip-5", ZIO_COMPRESS_GZIP_5 },128{ "gzip-6", ZIO_COMPRESS_GZIP_6 },129{ "gzip-7", ZIO_COMPRESS_GZIP_7 },130{ "gzip-8", ZIO_COMPRESS_GZIP_8 },131{ "gzip-9", ZIO_COMPRESS_GZIP_9 },132{ "zle", ZIO_COMPRESS_ZLE },133{ "lz4", ZIO_COMPRESS_LZ4 },134{ "zstd", ZIO_COMPRESS_ZSTD },135{ "zstd-fast",136ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_DEFAULT) },137138/*139* ZSTD 1-19 are synthetic. We store the compression level in a140* separate hidden property to avoid wasting a large amount of141* space in the ZIO_COMPRESS enum.142*143* The compression level is also stored within the header of the144* compressed block since we may need it for later recompression145* to avoid checksum errors (L2ARC).146*147* Note that the level here is defined as bit shifted mask on148* top of the method.149*/150{ "zstd-1", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_1) },151{ "zstd-2", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_2) },152{ "zstd-3", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_3) },153{ "zstd-4", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_4) },154{ "zstd-5", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_5) },155{ "zstd-6", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_6) },156{ "zstd-7", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_7) },157{ "zstd-8", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_8) },158{ "zstd-9", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_9) },159{ "zstd-10", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_10) },160{ "zstd-11", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_11) },161{ "zstd-12", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_12) },162{ "zstd-13", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_13) },163{ "zstd-14", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_14) },164{ "zstd-15", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_15) },165{ "zstd-16", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_16) },166{ "zstd-17", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_17) },167{ "zstd-18", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_18) },168{ "zstd-19", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_19) },169170/*171* The ZSTD-Fast levels are also synthetic.172*/173{ "zstd-fast-1",174ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1) },175{ "zstd-fast-2",176ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_2) },177{ "zstd-fast-3",178ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_3) },179{ "zstd-fast-4",180ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_4) },181{ "zstd-fast-5",182ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_5) },183{ "zstd-fast-6",184ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_6) },185{ "zstd-fast-7",186ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_7) },187{ "zstd-fast-8",188ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_8) },189{ "zstd-fast-9",190ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_9) },191{ "zstd-fast-10",192ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_10) },193{ "zstd-fast-20",194ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_20) },195{ "zstd-fast-30",196ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_30) },197{ "zstd-fast-40",198ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_40) },199{ "zstd-fast-50",200ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_50) },201{ "zstd-fast-60",202ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_60) },203{ "zstd-fast-70",204ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_70) },205{ "zstd-fast-80",206ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_80) },207{ "zstd-fast-90",208ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_90) },209{ "zstd-fast-100",210ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_100) },211{ "zstd-fast-500",212ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_500) },213{ "zstd-fast-1000",214ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1000) },215{ NULL }216};217218static const zprop_index_t crypto_table[] = {219{ "on", ZIO_CRYPT_ON },220{ "off", ZIO_CRYPT_OFF },221{ "aes-128-ccm", ZIO_CRYPT_AES_128_CCM },222{ "aes-192-ccm", ZIO_CRYPT_AES_192_CCM },223{ "aes-256-ccm", ZIO_CRYPT_AES_256_CCM },224{ "aes-128-gcm", ZIO_CRYPT_AES_128_GCM },225{ "aes-192-gcm", ZIO_CRYPT_AES_192_GCM },226{ "aes-256-gcm", ZIO_CRYPT_AES_256_GCM },227{ NULL }228};229230static const zprop_index_t keyformat_table[] = {231{ "none", ZFS_KEYFORMAT_NONE },232{ "raw", ZFS_KEYFORMAT_RAW },233{ "hex", ZFS_KEYFORMAT_HEX },234{ "passphrase", ZFS_KEYFORMAT_PASSPHRASE },235{ NULL }236};237238static const zprop_index_t snapdir_table[] = {239{ "hidden", ZFS_SNAPDIR_HIDDEN },240{ "visible", ZFS_SNAPDIR_VISIBLE },241{ "disabled", ZFS_SNAPDIR_DISABLED },242{ NULL }243};244245static const zprop_index_t snapdev_table[] = {246{ "hidden", ZFS_SNAPDEV_HIDDEN },247{ "visible", ZFS_SNAPDEV_VISIBLE },248{ NULL }249};250251static const zprop_index_t acl_mode_table[] = {252{ "discard", ZFS_ACL_DISCARD },253{ "groupmask", ZFS_ACL_GROUPMASK },254{ "passthrough", ZFS_ACL_PASSTHROUGH },255{ "restricted", ZFS_ACL_RESTRICTED },256{ NULL }257};258259static const zprop_index_t acltype_table[] = {260{ "off", ZFS_ACLTYPE_OFF },261{ "posix", ZFS_ACLTYPE_POSIX },262{ "nfsv4", ZFS_ACLTYPE_NFSV4 },263{ "disabled", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */264{ "noacl", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */265{ "posixacl", ZFS_ACLTYPE_POSIX }, /* bkwrd compatibility */266{ NULL }267};268269static const zprop_index_t acl_inherit_table[] = {270{ "discard", ZFS_ACL_DISCARD },271{ "noallow", ZFS_ACL_NOALLOW },272{ "restricted", ZFS_ACL_RESTRICTED },273{ "passthrough", ZFS_ACL_PASSTHROUGH },274{ "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatibility */275{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X },276{ NULL }277};278279static const zprop_index_t case_table[] = {280{ "sensitive", ZFS_CASE_SENSITIVE },281{ "insensitive", ZFS_CASE_INSENSITIVE },282{ "mixed", ZFS_CASE_MIXED },283{ NULL }284};285286static const zprop_index_t copies_table[] = {287{ "1", 1 },288{ "2", 2 },289{ "3", 3 },290{ NULL }291};292293/*294* Use the unique flags we have to send to u8_strcmp() and/or295* u8_textprep() to represent the various normalization property296* values.297*/298static const zprop_index_t normalize_table[] = {299{ "none", 0 },300{ "formD", U8_TEXTPREP_NFD },301{ "formKC", U8_TEXTPREP_NFKC },302{ "formC", U8_TEXTPREP_NFC },303{ "formKD", U8_TEXTPREP_NFKD },304{ NULL }305};306307static const zprop_index_t version_table[] = {308{ "1", 1 },309{ "2", 2 },310{ "3", 3 },311{ "4", 4 },312{ "5", 5 },313{ "current", ZPL_VERSION },314{ NULL }315};316317static const zprop_index_t boolean_table[] = {318{ "off", 0 },319{ "on", 1 },320{ NULL }321};322323static const zprop_index_t keystatus_table[] = {324{ "none", ZFS_KEYSTATUS_NONE},325{ "unavailable", ZFS_KEYSTATUS_UNAVAILABLE},326{ "available", ZFS_KEYSTATUS_AVAILABLE},327{ NULL }328};329330static const zprop_index_t logbias_table[] = {331{ "latency", ZFS_LOGBIAS_LATENCY },332{ "throughput", ZFS_LOGBIAS_THROUGHPUT },333{ NULL }334};335336static const zprop_index_t canmount_table[] = {337{ "off", ZFS_CANMOUNT_OFF },338{ "on", ZFS_CANMOUNT_ON },339{ "noauto", ZFS_CANMOUNT_NOAUTO },340{ NULL }341};342343static const zprop_index_t cache_table[] = {344{ "none", ZFS_CACHE_NONE },345{ "metadata", ZFS_CACHE_METADATA },346{ "all", ZFS_CACHE_ALL },347{ NULL }348};349350static const zprop_index_t prefetch_table[] = {351{ "none", ZFS_PREFETCH_NONE },352{ "metadata", ZFS_PREFETCH_METADATA },353{ "all", ZFS_PREFETCH_ALL },354{ NULL }355};356357static const zprop_index_t sync_table[] = {358{ "standard", ZFS_SYNC_STANDARD },359{ "always", ZFS_SYNC_ALWAYS },360{ "disabled", ZFS_SYNC_DISABLED },361{ NULL }362};363364static const zprop_index_t xattr_table[] = {365{ "off", ZFS_XATTR_OFF },366{ "sa", ZFS_XATTR_SA },367{ "on", ZFS_XATTR_SA },368{ "dir", ZFS_XATTR_DIR },369{ NULL }370};371372static const zprop_index_t dnsize_table[] = {373{ "legacy", ZFS_DNSIZE_LEGACY },374{ "auto", ZFS_DNSIZE_AUTO },375{ "1k", ZFS_DNSIZE_1K },376{ "2k", ZFS_DNSIZE_2K },377{ "4k", ZFS_DNSIZE_4K },378{ "8k", ZFS_DNSIZE_8K },379{ "16k", ZFS_DNSIZE_16K },380{ NULL }381};382383static const zprop_index_t redundant_metadata_table[] = {384{ "all", ZFS_REDUNDANT_METADATA_ALL },385{ "most", ZFS_REDUNDANT_METADATA_MOST },386{ "some", ZFS_REDUNDANT_METADATA_SOME },387{ "none", ZFS_REDUNDANT_METADATA_NONE },388{ NULL }389};390391static const zprop_index_t volmode_table[] = {392{ "default", ZFS_VOLMODE_DEFAULT },393{ "full", ZFS_VOLMODE_GEOM },394{ "geom", ZFS_VOLMODE_GEOM },395{ "dev", ZFS_VOLMODE_DEV },396{ "none", ZFS_VOLMODE_NONE },397{ NULL }398};399400static const zprop_index_t direct_table[] = {401{ "disabled", ZFS_DIRECT_DISABLED },402{ "standard", ZFS_DIRECT_STANDARD },403{ "always", ZFS_DIRECT_ALWAYS },404{ NULL }405};406407struct zfs_mod_supported_features *sfeatures =408zfs_mod_list_supported(ZFS_SYSFS_DATASET_PROPERTIES);409410/* inherit index properties */411zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",412ZFS_REDUNDANT_METADATA_ALL,413PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,414"all | most | some | none", "REDUND_MD",415redundant_metadata_table, sfeatures);416zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,417PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,418"standard | always | disabled", "SYNC",419sync_table, sfeatures);420zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",421ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |422ZFS_TYPE_VOLUME,423"on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein"424" | edonr | blake3",425"CHECKSUM", checksum_table, sfeatures);426zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,427PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,428"on | off | verify | sha256[,verify] | sha512[,verify] | "429"skein[,verify] | edonr,verify | blake3[,verify]",430"DEDUP", dedup_table, sfeatures);431zprop_register_index(ZFS_PROP_COMPRESSION, "compression",432ZIO_COMPRESS_DEFAULT, PROP_INHERIT,433ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,434"on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | "435"zstd | zstd-[1-19] | "436"zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]",437"COMPRESS", compress_table, sfeatures);438zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,439PROP_INHERIT, ZFS_TYPE_FILESYSTEM,440"disabled | hidden | visible", "SNAPDIR", snapdir_table, sfeatures);441zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN,442PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,443"hidden | visible", "SNAPDEV", snapdev_table, sfeatures);444zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,445PROP_INHERIT, ZFS_TYPE_FILESYSTEM,446"discard | groupmask | passthrough | restricted", "ACLMODE",447acl_mode_table, sfeatures);448zprop_register_index(ZFS_PROP_ACLTYPE, "acltype",449#ifdef __linux__450/* Linux doesn't natively support ZFS's NFSv4-style ACLs. */451ZFS_ACLTYPE_OFF,452#else453ZFS_ACLTYPE_NFSV4,454#endif455PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,456"off | nfsv4 | posix", "ACLTYPE", acltype_table, sfeatures);457zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",458ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,459"discard | noallow | restricted | passthrough | passthrough-x",460"ACLINHERIT", acl_inherit_table, sfeatures);461zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,462ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,463"1 | 2 | 3", "COPIES", copies_table, sfeatures);464zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",465ZFS_CACHE_ALL, PROP_INHERIT,466ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,467"all | none | metadata", "PRIMARYCACHE", cache_table, sfeatures);468zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",469ZFS_CACHE_ALL, PROP_INHERIT,470ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,471"all | none | metadata", "SECONDARYCACHE", cache_table, sfeatures);472zprop_register_index(ZFS_PROP_PREFETCH, "prefetch",473ZFS_PREFETCH_ALL, PROP_INHERIT,474ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,475"none | metadata | all", "PREFETCH", prefetch_table, sfeatures);476zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,477PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,478"latency | throughput", "LOGBIAS", logbias_table, sfeatures);479zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_SA,480PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,481"on | off | dir | sa", "XATTR", xattr_table, sfeatures);482zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",483ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,484"legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table,485sfeatures);486zprop_register_index(ZFS_PROP_VOLMODE, "volmode",487ZFS_VOLMODE_DEFAULT, PROP_INHERIT,488ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,489"default | full | geom | dev | none", "VOLMODE", volmode_table,490sfeatures);491zprop_register_index(ZFS_PROP_DIRECT, "direct",492ZFS_DIRECT_STANDARD, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,493"disabled | standard | always", "DIRECT", direct_table,494sfeatures);495496/* inherit index (boolean) properties */497zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,498ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table, sfeatures);499zprop_register_index(ZFS_PROP_RELATIME, "relatime", 1, PROP_INHERIT,500ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table,501sfeatures);502zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,503ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",504boolean_table, sfeatures);505zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,506ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",507boolean_table, sfeatures);508zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,509ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",510boolean_table, sfeatures);511zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,512ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",513boolean_table, sfeatures);514#ifdef __FreeBSD__515zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT,516ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table,517sfeatures);518#else519zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,520ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table, sfeatures);521#endif522zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,523ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table, sfeatures);524zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,525ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",526boolean_table, sfeatures);527zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT,528ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table,529sfeatures);530531/* default index properties */532zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,533ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,534"1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table, sfeatures);535zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,536PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",537"CANMOUNT", canmount_table, sfeatures);538539/* readonly index properties */540zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,541ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table,542sfeatures);543zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,544PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",545boolean_table, sfeatures);546zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",547ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,548"none | unavailable | available",549"KEYSTATUS", keystatus_table, sfeatures);550551/* set once index properties */552zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,553PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,554"none | formC | formD | formKC | formKD", "NORMALIZATION",555normalize_table, sfeatures);556zprop_register_index(ZFS_PROP_CASE, "casesensitivity",557ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |558ZFS_TYPE_SNAPSHOT,559"sensitive | insensitive | mixed", "CASE", case_table, sfeatures);560zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",561ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,562ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,563"none | raw | hex | passphrase", "KEYFORMAT", keyformat_table,564sfeatures);565zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption",566ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET,567"on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "568"aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",569crypto_table, sfeatures);570571/* set once index (boolean) properties */572zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,573ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,574"on | off", "UTF8ONLY", boolean_table, sfeatures);575576/* string properties */577zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,578ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN",579sfeatures);580zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,581ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES", sfeatures);582zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",583PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",584"MOUNTPOINT", sfeatures);585zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",586PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | NFS share options",587"SHARENFS", sfeatures);588zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,589ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,590"filesystem | volume | snapshot | bookmark", "TYPE", sfeatures);591zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",592PROP_INHERIT, ZFS_TYPE_FILESYSTEM,593"on | off | SMB share options", "SHARESMB", sfeatures);594zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",595ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,596"<sensitivity label>", "MLSLABEL", sfeatures);597zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context",598"none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux context>",599"CONTEXT", sfeatures);600zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext",601"none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux fscontext>",602"FSCONTEXT", sfeatures);603zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext",604"none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux defcontext>",605"DEFCONTEXT", sfeatures);606zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext",607"none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux rootcontext>",608"ROOTCONTEXT", sfeatures);609zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN,610"receive_resume_token",611NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,612"<string token>", "RESUMETOK", sfeatures);613zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,614PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",615"ENCROOT", sfeatures);616zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",617"none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,618"prompt | <file URI> | <https URL> | <http URL>", "KEYLOCATION",619sfeatures);620zprop_register_string(ZFS_PROP_REDACT_SNAPS,621"redact_snaps", NULL, PROP_READONLY,622ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<snapshot>[,...]",623"RSNAPS", sfeatures);624625/* readonly number properties */626zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,627ZFS_TYPE_DATASET, "<size>", "USED", B_FALSE, sfeatures);628zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,629ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL",630B_FALSE, sfeatures);631zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,632PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",633"REFER", B_FALSE, sfeatures);634zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,635PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,636"<1.00x or higher if compressed>", "RATIO", B_FALSE, sfeatures);637zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,638PROP_READONLY, ZFS_TYPE_DATASET,639"<1.00x or higher if compressed>", "REFRATIO", B_FALSE, sfeatures);640zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",641ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,642ZFS_TYPE_VOLUME, "512 to 16M, power of 2", "VOLBLOCK", B_FALSE,643sfeatures);644zprop_register_index(ZFS_PROP_VOLTHREADING, "volthreading",6451, PROP_DEFAULT, ZFS_TYPE_VOLUME, "on | off", "zvol threading",646boolean_table, sfeatures);647zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,648PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",649"USEDSNAP", B_FALSE, sfeatures);650zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,651PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",652"USEDDS", B_FALSE, sfeatures);653zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,654PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",655"USEDCHILD", B_FALSE, sfeatures);656zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,657PROP_READONLY,658ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV",659B_FALSE, sfeatures);660zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,661ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS", B_FALSE, sfeatures);662zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,663ZFS_TYPE_DATASET, "<size>", "WRITTEN", B_FALSE, sfeatures);664zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,665PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",666"LUSED", B_FALSE, sfeatures);667zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",6680, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",669"LREFER", B_FALSE, sfeatures);670zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",671UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM,672"<count>", "FSCOUNT", B_FALSE, sfeatures);673zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",674UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,675"<count>", "SSCOUNT", B_FALSE, sfeatures);676zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY,677ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID",678B_TRUE, sfeatures);679zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,680ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG",681B_TRUE, sfeatures);682zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",6830, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,684"<iters>", "PBKDF2ITERS", B_TRUE, sfeatures);685zprop_register_number(ZFS_PROP_OBJSETID, "objsetid", 0,686PROP_READONLY, ZFS_TYPE_DATASET, "<uint64>", "OBJSETID", B_TRUE,687sfeatures);688689/* default number properties */690zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,691ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA", B_FALSE, sfeatures);692zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,693PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,694"<size> | none", "RESERV", B_FALSE, sfeatures);695zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,696ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE",697B_FALSE, sfeatures);698zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,699ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA", B_FALSE,700sfeatures);701zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,702PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,703"<size> | none", "REFRESERV", B_FALSE, sfeatures);704zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",705UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,706"<count> | none", "FSLIMIT", B_FALSE, sfeatures);707zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",708UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,709"<count> | none", "SSLIMIT", B_FALSE, sfeatures);710zprop_register_number(ZFS_PROP_DEFAULTUSERQUOTA, "defaultuserquota", 0,711PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,712"<size> | none", "DEFAULTUSERQUOTA", B_FALSE, sfeatures);713zprop_register_number(ZFS_PROP_DEFAULTGROUPQUOTA, "defaultgroupquota",7140, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,715"<size> | none", "DEFAULTGROUPQUOTA", B_FALSE, sfeatures);716zprop_register_number(ZFS_PROP_DEFAULTPROJECTQUOTA,717"defaultprojectquota", 0, PROP_DEFAULT,718ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "<size> | none",719"DEFAULTPROJECTQUOTA", B_FALSE, sfeatures);720zprop_register_number(ZFS_PROP_DEFAULTUSEROBJQUOTA,721"defaultuserobjquota", 0, PROP_DEFAULT,722ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "<size> | none",723"DEFAULTUSEROBJQUOTA", B_FALSE, sfeatures);724zprop_register_number(ZFS_PROP_DEFAULTGROUPOBJQUOTA,725"defaultgroupobjquota", 0, PROP_DEFAULT,726ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "<size> | none",727"DEFAULTGROUPOBJQUOTA", B_FALSE, sfeatures);728zprop_register_number(ZFS_PROP_DEFAULTPROJECTOBJQUOTA,729"defaultprojectobjquota", 0, PROP_DEFAULT,730ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "<size> | none",731"DEFAULTPROJECTOBJQUOTA", B_FALSE, sfeatures);732733/* inherit number properties */734zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",735SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,736ZFS_TYPE_FILESYSTEM, "512 to 16M, power of 2",737"RECSIZE", B_FALSE, sfeatures);738zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,739"special_small_blocks", 0, PROP_INHERIT,740ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "0 to 16M",741"SPECIAL_SMALL_BLOCKS", B_FALSE, sfeatures);742743/* hidden properties */744zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,745PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES", B_FALSE, sfeatures);746zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,747PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME",748B_TRUE, sfeatures);749zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",750PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS",751B_TRUE, sfeatures);752zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",753PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,754"STMF_SBD_LU", B_TRUE, sfeatures);755zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",756PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,757"USERACCOUNTING", B_FALSE, sfeatures);758zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,759PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE", B_FALSE, sfeatures);760zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",761PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT",762B_FALSE, sfeatures);763zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid",764PROP_TYPE_NUMBER, PROP_READONLY,765ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID", B_TRUE,766sfeatures);767zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,768PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP",769B_TRUE, sfeatures);770zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",771PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,772ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT", B_FALSE,773sfeatures);774zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,775PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID", B_TRUE, sfeatures);776zprop_register_hidden(ZFS_PROP_REDACTED, "redacted", PROP_TYPE_NUMBER,777PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED", B_FALSE, sfeatures);778779/*780* Properties that are obsolete and not used. These are retained so781* that we don't have to change the values of the zfs_prop_t enum, or782* have NULL pointers in the zfs_prop_table[].783*/784zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,785PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG", B_FALSE, sfeatures);786787/* oddball properties */788/* 'creation' is a number but displayed as human-readable => flex */789zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,790NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,791"<date>", "CREATION", B_FALSE, B_TRUE, B_TRUE, NULL, sfeatures);792793zprop_register_impl(ZFS_PROP_SNAPSHOTS_CHANGED, "snapshots_changed",794PROP_TYPE_NUMBER, 0, NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM |795ZFS_TYPE_VOLUME, "<date>", "SNAPSHOTS_CHANGED", B_FALSE, B_TRUE,796B_TRUE, NULL, sfeatures);797798zprop_register_index(ZFS_PROP_LONGNAME, "longname", 0, PROP_INHERIT,799ZFS_TYPE_FILESYSTEM, "on | off", "LONGNAME", boolean_table,800sfeatures);801802zfs_mod_list_supported_free(sfeatures);803}804805boolean_t806zfs_prop_delegatable(zfs_prop_t prop)807{808ASSERT3S(prop, >=, 0);809ASSERT3S(prop, <, ZFS_NUM_PROPS);810zprop_desc_t *pd = &zfs_prop_table[prop];811812/* The mlslabel property is never delegatable. */813if (prop == ZFS_PROP_MLSLABEL)814return (B_FALSE);815816return (pd->pd_attr != PROP_READONLY);817}818819/*820* Given a zfs dataset property name, returns the corresponding property ID.821*/822zfs_prop_t823zfs_name_to_prop(const char *propname)824{825return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));826}827828/*829* Returns true if this is a valid user-defined property (one with a ':').830*/831boolean_t832zfs_prop_user(const char *name)833{834int i, len;835char c;836boolean_t foundsep = B_FALSE;837838len = strlen(name);839for (i = 0; i < len; i++) {840c = name[i];841if (!zprop_valid_char(c))842return (B_FALSE);843if (c == ':')844foundsep = B_TRUE;845}846847if (!foundsep)848return (B_FALSE);849850return (B_TRUE);851}852853/*854* Returns true if this is a valid userspace-type property (one with a '@').855* Note that after the @, any character is valid (eg, another @, for SID856* user@domain).857*/858boolean_t859zfs_prop_userquota(const char *name)860{861zfs_userquota_prop_t prop;862863for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {864if (strncmp(name, zfs_userquota_prop_prefixes[prop],865strlen(zfs_userquota_prop_prefixes[prop])) == 0) {866return (B_TRUE);867}868}869870return (B_FALSE);871}872873/*874* Returns true if this is a valid written@ property.875* Note that after the @, any character is valid (eg, another @, for876* written@pool/fs@origin).877*/878boolean_t879zfs_prop_written(const char *name)880{881static const char *prop_prefix = "written@";882static const char *book_prefix = "written#";883return (strncmp(name, prop_prefix, strlen(prop_prefix)) == 0 ||884strncmp(name, book_prefix, strlen(book_prefix)) == 0);885}886887/*888* Tables of index types, plus functions to convert between the user view889* (strings) and internal representation (uint64_t).890*/891int892zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)893{894return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));895}896897int898zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)899{900return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));901}902903uint64_t904zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)905{906return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));907}908909/*910* Returns TRUE if the property applies to any of the given dataset types.911*/912boolean_t913zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck)914{915return (zprop_valid_for_type(prop, types, headcheck));916}917918zprop_type_t919zfs_prop_get_type(zfs_prop_t prop)920{921ASSERT3S(prop, >=, 0);922ASSERT3S(prop, <, ZFS_NUM_PROPS);923return (zfs_prop_table[prop].pd_proptype);924}925926/*927* Returns TRUE if the property is readonly.928*/929boolean_t930zfs_prop_readonly(zfs_prop_t prop)931{932ASSERT3S(prop, >=, 0);933ASSERT3S(prop, <, ZFS_NUM_PROPS);934return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||935zfs_prop_table[prop].pd_attr == PROP_ONETIME ||936zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);937}938939/*940* Returns TRUE if the property is visible (not hidden).941*/942boolean_t943zfs_prop_visible(zfs_prop_t prop)944{945ASSERT3S(prop, >=, 0);946ASSERT3S(prop, <, ZFS_NUM_PROPS);947return (zfs_prop_table[prop].pd_visible &&948zfs_prop_table[prop].pd_zfs_mod_supported);949}950951/*952* Returns TRUE if the property is only allowed to be set once.953*/954boolean_t955zfs_prop_setonce(zfs_prop_t prop)956{957ASSERT3S(prop, >=, 0);958ASSERT3S(prop, <, ZFS_NUM_PROPS);959return (zfs_prop_table[prop].pd_attr == PROP_ONETIME ||960zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);961}962963const char *964zfs_prop_default_string(zfs_prop_t prop)965{966ASSERT3S(prop, >=, 0);967ASSERT3S(prop, <, ZFS_NUM_PROPS);968return (zfs_prop_table[prop].pd_strdefault);969}970971uint64_t972zfs_prop_default_numeric(zfs_prop_t prop)973{974ASSERT3S(prop, >=, 0);975ASSERT3S(prop, <, ZFS_NUM_PROPS);976return (zfs_prop_table[prop].pd_numdefault);977}978979/*980* Given a dataset property ID, returns the corresponding name.981* Assuming the zfs dataset property ID is valid.982*/983const char *984zfs_prop_to_name(zfs_prop_t prop)985{986ASSERT3S(prop, >=, 0);987ASSERT3S(prop, <, ZFS_NUM_PROPS);988return (zfs_prop_table[prop].pd_name);989}990991/*992* Returns TRUE if the property is inheritable.993*/994boolean_t995zfs_prop_inheritable(zfs_prop_t prop)996{997ASSERT3S(prop, >=, 0);998ASSERT3S(prop, <, ZFS_NUM_PROPS);999return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||1000zfs_prop_table[prop].pd_attr == PROP_ONETIME);1001}10021003/*1004* Returns TRUE if property is one of the encryption properties that requires1005* a loaded encryption key to modify.1006*/1007boolean_t1008zfs_prop_encryption_key_param(zfs_prop_t prop)1009{1010/*1011* keylocation does not count as an encryption property. It can be1012* changed at will without needing the master keys.1013*/1014return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS ||1015prop == ZFS_PROP_KEYFORMAT);1016}10171018/*1019* Helper function used by both kernelspace and userspace to check the1020* keylocation property. If encrypted is set, the keylocation must be valid1021* for an encrypted dataset.1022*/1023boolean_t1024zfs_prop_valid_keylocation(const char *str, boolean_t encrypted)1025{1026if (strcmp("none", str) == 0)1027return (!encrypted);1028else if (strcmp("prompt", str) == 0)1029return (B_TRUE);1030else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0)1031return (B_TRUE);1032else if (strlen(str) > 8 && strncmp("https://", str, 8) == 0)1033return (B_TRUE);1034else if (strlen(str) > 7 && strncmp("http://", str, 7) == 0)1035return (B_TRUE);10361037return (B_FALSE);1038}103910401041#ifndef _KERNEL1042#include <libzfs.h>10431044/*1045* Returns a string describing the set of acceptable values for the given1046* zfs property, or NULL if it cannot be set.1047*/1048const char *1049zfs_prop_values(zfs_prop_t prop)1050{1051ASSERT3S(prop, >=, 0);1052ASSERT3S(prop, <, ZFS_NUM_PROPS);1053return (zfs_prop_table[prop].pd_values);1054}10551056/*1057* Returns TRUE if this property is a string type. Note that index types1058* (compression, checksum) are treated as strings in userland, even though they1059* are stored numerically on disk.1060*/1061int1062zfs_prop_is_string(zfs_prop_t prop)1063{1064ASSERT3S(prop, >=, 0);1065ASSERT3S(prop, <, ZFS_NUM_PROPS);1066return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||1067zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);1068}10691070/*1071* Returns the column header for the given property. Used only in1072* 'zfs list -o', but centralized here with the other property information.1073*/1074const char *1075zfs_prop_column_name(zfs_prop_t prop)1076{1077ASSERT3S(prop, >=, 0);1078ASSERT3S(prop, <, ZFS_NUM_PROPS);1079return (zfs_prop_table[prop].pd_colname);1080}10811082/*1083* Returns whether the given property should be displayed right-justified for1084* 'zfs list'.1085*/1086boolean_t1087zfs_prop_align_right(zfs_prop_t prop)1088{1089ASSERT3S(prop, >=, 0);1090ASSERT3S(prop, <, ZFS_NUM_PROPS);1091return (zfs_prop_table[prop].pd_rightalign);1092}10931094#endif10951096#if defined(_KERNEL)10971098#if defined(HAVE_KERNEL_FPU_INTERNAL)1099uint8_t **zfs_kfpu_fpregs;1100EXPORT_SYMBOL(zfs_kfpu_fpregs);1101#endif /* defined(HAVE_KERNEL_FPU_INTERNAL) */11021103extern int __init zcommon_init(void);1104extern void zcommon_fini(void);11051106int __init1107zcommon_init(void)1108{1109int error = kfpu_init();1110if (error)1111return (error);11121113fletcher_4_init();1114simd_stat_init();11151116return (0);1117}11181119void1120zcommon_fini(void)1121{1122simd_stat_fini();1123fletcher_4_fini();1124kfpu_fini();1125}11261127#ifdef __FreeBSD__1128module_init_early(zcommon_init);1129module_exit(zcommon_fini);1130#endif11311132#endif11331134/* zfs dataset property functions */1135EXPORT_SYMBOL(zfs_userquota_prop_prefixes);1136EXPORT_SYMBOL(zfs_prop_init);1137EXPORT_SYMBOL(zfs_prop_get_type);1138EXPORT_SYMBOL(zfs_prop_get_table);1139EXPORT_SYMBOL(zfs_prop_delegatable);1140EXPORT_SYMBOL(zfs_prop_visible);11411142/* Dataset property functions shared between libzfs and kernel. */1143EXPORT_SYMBOL(zfs_prop_default_string);1144EXPORT_SYMBOL(zfs_prop_default_numeric);1145EXPORT_SYMBOL(zfs_prop_readonly);1146EXPORT_SYMBOL(zfs_prop_inheritable);1147EXPORT_SYMBOL(zfs_prop_encryption_key_param);1148EXPORT_SYMBOL(zfs_prop_valid_keylocation);1149EXPORT_SYMBOL(zfs_prop_setonce);1150EXPORT_SYMBOL(zfs_prop_to_name);1151EXPORT_SYMBOL(zfs_name_to_prop);1152EXPORT_SYMBOL(zfs_prop_user);1153EXPORT_SYMBOL(zfs_prop_userquota);1154EXPORT_SYMBOL(zfs_prop_index_to_string);1155EXPORT_SYMBOL(zfs_prop_string_to_index);1156EXPORT_SYMBOL(zfs_prop_valid_for_type);1157EXPORT_SYMBOL(zfs_prop_written);115811591160