1fa9e406ahrens/*
2fa9e406ahrens * CDDL HEADER START
3fa9e406ahrens *
4fa9e406ahrens * The contents of this file are subject to the terms of the
5906d120lling * Common Development and Distribution License (the "License").
6906d120lling * You may not use this file except in compliance with the License.
7fa9e406ahrens *
8fa9e406ahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e406ahrens * or http://www.opensolaris.org/os/licensing.
10fa9e406ahrens * See the License for the specific language governing permissions
11fa9e406ahrens * and limitations under the License.
12fa9e406ahrens *
13fa9e406ahrens * When distributing Covered Code, include this CDDL HEADER in each
14fa9e406ahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e406ahrens * If applicable, add the following below this CDDL HEADER, with the
16fa9e406ahrens * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e406ahrens * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e406ahrens *
19fa9e406ahrens * CDDL HEADER END
20fa9e406ahrens */
21fa9e406ahrens/*
2227dd1e8Mark Shellenbaum * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23dfc1153Chris Williamson * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
24a6f561bSašo Kiselkov * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25c3d26abMatthew Ahrens * Copyright (c) 2014 Integros [integros.com]
26007a6c1Jerry Jelinek * Copyright 2016, Joyent, Inc.
27fa9e406ahrens */
28fa9e406ahrens
2955da60bMark J Musante/* Portions Copyright 2010 Robert Milkowski */
3055da60bMark J Musante
31fa9e406ahrens#include <sys/zio.h>
32fa9e406ahrens#include <sys/spa.h>
33de8267etimh#include <sys/u8_textprep.h>
34fa9e406ahrens#include <sys/zfs_acl.h>
35fa9e406ahrens#include <sys/zfs_ioctl.h>
36e743726ahrens#include <sys/zfs_znode.h>
37eb63303Tom Caputi#include <sys/dsl_crypt.h>
38fa9e406ahrens
39fa9e406ahrens#include "zfs_prop.h"
40ecd6cf8marks#include "zfs_deleg.h"
41fa9e406ahrens
42fa9e406ahrens#if defined(_KERNEL)
43fa9e406ahrens#include <sys/systm.h>
44fa9e406ahrens#else
45fa9e406ahrens#include <stdlib.h>
46fa9e406ahrens#include <string.h>
47fa9e406ahrens#include <ctype.h>
48fa9e406ahrens#endif
49fa9e406ahrens
50990b485llingstatic zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
5191ebeefahrens
521484342Matthew Ahrens/* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
531484342Matthew Ahrensconst char *zfs_userquota_prop_prefixes[] = {
541484342Matthew Ahrens	"userused@",
551484342Matthew Ahrens	"userquota@",
561484342Matthew Ahrens	"groupused@",
57f67950bNasf-Fan	"groupquota@",
58f67950bNasf-Fan	"userobjused@",
59f67950bNasf-Fan	"userobjquota@",
60f67950bNasf-Fan	"groupobjused@",
61f67950bNasf-Fan	"groupobjquota@",
62f67950bNasf-Fan	"projectused@",
63f67950bNasf-Fan	"projectquota@",
64f67950bNasf-Fan	"projectobjused@",
65f67950bNasf-Fan	"projectobjquota@"
661484342Matthew Ahrens};
671484342Matthew Ahrens
68990b485llingzprop_desc_t *
69990b485llingzfs_prop_get_table(void)
7091ebeefahrens{
71990b485lling	return (zfs_prop_table);
7291ebeefahrens}
7391ebeefahrens
7491ebeefahrensvoid
7591ebeefahrenszfs_prop_init(void)
7691ebeefahrens{
77990b485lling	static zprop_index_t checksum_table[] = {
7891ebeefahrens		{ "on",		ZIO_CHECKSUM_ON },
7991ebeefahrens		{ "off",	ZIO_CHECKSUM_OFF },
8091ebeefahrens		{ "fletcher2",	ZIO_CHECKSUM_FLETCHER_2 },
8191ebeefahrens		{ "fletcher4",	ZIO_CHECKSUM_FLETCHER_4 },
8291ebeefahrens		{ "sha256",	ZIO_CHECKSUM_SHA256 },
83810e43bBill Pijewski		{ "noparity",	ZIO_CHECKSUM_NOPARITY },
8445818eeMatthew Ahrens		{ "sha512",	ZIO_CHECKSUM_SHA512 },
8545818eeMatthew Ahrens		{ "skein",	ZIO_CHECKSUM_SKEIN },
8645818eeMatthew Ahrens		{ "edonr",	ZIO_CHECKSUM_EDONR },
8791ebeefahrens		{ NULL }
8891ebeefahrens	};
8991ebeefahrens
90b24ab67Jeff Bonwick	static zprop_index_t dedup_table[] = {
91b24ab67Jeff Bonwick		{ "on",		ZIO_CHECKSUM_ON },
92b24ab67Jeff Bonwick		{ "off",	ZIO_CHECKSUM_OFF },
93b24ab67Jeff Bonwick		{ "verify",	ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
94b24ab67Jeff Bonwick		{ "sha256",	ZIO_CHECKSUM_SHA256 },
95b24ab67Jeff Bonwick		{ "sha256,verify",
96b24ab67Jeff Bonwick				ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
9745818eeMatthew Ahrens		{ "sha512",	ZIO_CHECKSUM_SHA512 },
9845818eeMatthew Ahrens		{ "sha512,verify",
9945818eeMatthew Ahrens				ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY },
10045818eeMatthew Ahrens		{ "skein",	ZIO_CHECKSUM_SKEIN },
10145818eeMatthew Ahrens		{ "skein,verify",
10245818eeMatthew Ahrens				ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY },
10345818eeMatthew Ahrens		{ "edonr,verify",
10445818eeMatthew Ahrens				ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY },
105b24ab67Jeff Bonwick		{ NULL }
106b24ab67Jeff Bonwick	};
107b24ab67Jeff Bonwick
108990b485lling	static zprop_index_t compress_table[] = {
10991ebeefahrens		{ "on",		ZIO_COMPRESS_ON },
11091ebeefahrens		{ "off",	ZIO_COMPRESS_OFF },
11191ebeefahrens		{ "lzjb",	ZIO_COMPRESS_LZJB },
11291ebeefahrens		{ "gzip",	ZIO_COMPRESS_GZIP_6 },	/* gzip default */
11391ebeefahrens		{ "gzip-1",	ZIO_COMPRESS_GZIP_1 },
11491ebeefahrens		{ "gzip-2",	ZIO_COMPRESS_GZIP_2 },
11591ebeefahrens		{ "gzip-3",	ZIO_COMPRESS_GZIP_3 },
11691ebeefahrens		{ "gzip-4",	ZIO_COMPRESS_GZIP_4 },
11791ebeefahrens		{ "gzip-5",	ZIO_COMPRESS_GZIP_5 },
11891ebeefahrens		{ "gzip-6",	ZIO_COMPRESS_GZIP_6 },
11991ebeefahrens		{ "gzip-7",	ZIO_COMPRESS_GZIP_7 },
12091ebeefahrens		{ "gzip-8",	ZIO_COMPRESS_GZIP_8 },
12191ebeefahrens		{ "gzip-9",	ZIO_COMPRESS_GZIP_9 },
122b24ab67Jeff Bonwick		{ "zle",	ZIO_COMPRESS_ZLE },
123a6f561bSašo Kiselkov		{ "lz4",	ZIO_COMPRESS_LZ4 },
12491ebeefahrens		{ NULL }
12591ebeefahrens	};
12691ebeefahrens
127eb63303Tom Caputi	static zprop_index_t crypto_table[] = {
128eb63303Tom Caputi		{ "on",			ZIO_CRYPT_ON },
129eb63303Tom Caputi		{ "off",		ZIO_CRYPT_OFF },
130eb63303Tom Caputi		{ "aes-128-ccm",	ZIO_CRYPT_AES_128_CCM },
131eb63303Tom Caputi		{ "aes-192-ccm",	ZIO_CRYPT_AES_192_CCM },
132eb63303Tom Caputi		{ "aes-256-ccm",	ZIO_CRYPT_AES_256_CCM },
133eb63303Tom Caputi		{ "aes-128-gcm",	ZIO_CRYPT_AES_128_GCM },
134eb63303Tom Caputi		{ "aes-192-gcm",	ZIO_CRYPT_AES_192_GCM },
135eb63303Tom Caputi		{ "aes-256-gcm",	ZIO_CRYPT_AES_256_GCM },
136eb63303Tom Caputi		{ NULL }
137eb63303Tom Caputi	};
138eb63303Tom Caputi
139eb63303Tom Caputi	static zprop_index_t keyformat_table[] = {
140eb63303Tom Caputi		{ "none",		ZFS_KEYFORMAT_NONE },
141eb63303Tom Caputi		{ "raw",		ZFS_KEYFORMAT_RAW },
142eb63303Tom Caputi		{ "hex",		ZFS_KEYFORMAT_HEX },
143eb63303Tom Caputi		{ "passphrase",		ZFS_KEYFORMAT_PASSPHRASE },
144eb63303Tom Caputi		{ NULL }
145eb63303Tom Caputi	};
146eb63303Tom Caputi
147990b485lling	static zprop_index_t snapdir_table[] = {
14891ebeefahrens		{ "hidden",	ZFS_SNAPDIR_HIDDEN },
14991ebeefahrens		{ "visible",	ZFS_SNAPDIR_VISIBLE },
15091ebeefahrens		{ NULL }
15191ebeefahrens	};
15291ebeefahrens
153a3c49ceAlbert Lee	static zprop_index_t acl_mode_table[] = {
154a3c49ceAlbert Lee		{ "discard",	ZFS_ACL_DISCARD },
155a3c49ceAlbert Lee		{ "groupmask",	ZFS_ACL_GROUPMASK },
156a3c49ceAlbert Lee		{ "passthrough", ZFS_ACL_PASSTHROUGH },
15771dbfc2Paul B. Henson		{ "restricted", ZFS_ACL_RESTRICTED },
158a3c49ceAlbert Lee		{ NULL }
159a3c49ceAlbert Lee	};
160a3c49ceAlbert Lee
161990b485lling	static zprop_index_t acl_inherit_table[] = {
16291ebeefahrens		{ "discard",	ZFS_ACL_DISCARD },
16391ebeefahrens		{ "noallow",	ZFS_ACL_NOALLOW },
164b3d141fmarks		{ "restricted",	ZFS_ACL_RESTRICTED },
16591ebeefahrens		{ "passthrough", ZFS_ACL_PASSTHROUGH },
166b3d141fmarks		{ "secure",	ZFS_ACL_RESTRICTED }, /* bkwrd compatability */
167d0f3f37Mark Shellenbaum		{ "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
16891ebeefahrens		{ NULL }
16991ebeefahrens	};
17091ebeefahrens
171da6c28aamw	static zprop_index_t case_table[] = {
172da6c28aamw		{ "sensitive",		ZFS_CASE_SENSITIVE },
173da6c28aamw		{ "insensitive",	ZFS_CASE_INSENSITIVE },
174da6c28aamw		{ "mixed",		ZFS_CASE_MIXED },
175da6c28aamw		{ NULL }
176da6c28aamw	};
177da6c28aamw
178990b485lling	static zprop_index_t copies_table[] = {
17991ebeefahrens		{ "1",		1 },
18091ebeefahrens		{ "2",		2 },
18191ebeefahrens		{ "3",		3 },
18291ebeefahrens		{ NULL }
18391ebeefahrens	};
18491ebeefahrens
185de8267etimh	/*
186de8267etimh	 * Use the unique flags we have to send to u8_strcmp() and/or
187de8267etimh	 * u8_textprep() to represent the various normalization property
188de8267etimh	 * values.
189de8267etimh	 */
190da6c28aamw	static zprop_index_t normalize_table[] = {
191de8267etimh		{ "none",	0 },
192de8267etimh		{ "formD",	U8_TEXTPREP_NFD },
193de8267etimh		{ "formKC",	U8_TEXTPREP_NFKC },
194de8267etimh		{ "formC",	U8_TEXTPREP_NFC },
195de8267etimh		{ "formKD",	U8_TEXTPREP_NFKD },
196da6c28aamw		{ NULL }
197da6c28aamw	};
198da6c28aamw
199990b485lling	static zprop_index_t version_table[] = {
20091ebeefahrens		{ "1",		1 },
20191ebeefahrens		{ "2",		2 },
202da6c28aamw		{ "3",		3 },
2031484342Matthew Ahrens		{ "4",		4 },
2040a586ceMark Shellenbaum		{ "5",		5 },
20591ebeefahrens		{ "current",	ZPL_VERSION },
20691ebeefahrens		{ NULL }
20791ebeefahrens	};
20891ebeefahrens
209990b485lling	static zprop_index_t boolean_table[] = {
210e45ce72ahrens		{ "off",	0 },
211e45ce72ahrens		{ "on",		1 },
212e45ce72ahrens		{ NULL }
213e45ce72ahrens	};
214e45ce72ahrens
215eb63303Tom Caputi	static zprop_index_t keystatus_table[] = {
216eb63303Tom Caputi		{ "none",		ZFS_KEYSTATUS_NONE },
217eb63303Tom Caputi		{ "unavailable",	ZFS_KEYSTATUS_UNAVAILABLE },
218eb63303Tom Caputi		{ "available",		ZFS_KEYSTATUS_AVAILABLE },
219eb63303Tom Caputi		{ NULL }
220eb63303Tom Caputi	};
221eb63303Tom Caputi
222e09fa4dNeil Perrin	static zprop_index_t logbias_table[] = {
223e09fa4dNeil Perrin		{ "latency",	ZFS_LOGBIAS_LATENCY },
224e09fa4dNeil Perrin		{ "throughput",	ZFS_LOGBIAS_THROUGHPUT },
225e09fa4dNeil Perrin		{ NULL }
226e09fa4dNeil Perrin	};
227e09fa4dNeil Perrin
228a227b7fhs	static zprop_index_t canmount_table[] = {
229a227b7fhs		{ "off",	ZFS_CANMOUNT_OFF },
230a227b7fhs		{ "on",		ZFS_CANMOUNT_ON },
231a227b7fhs		{ "noauto",	ZFS_CANMOUNT_NOAUTO },
232a227b7fhs		{ NULL }
233a227b7fhs	};
234a227b7fhs
2353baa08fek	static zprop_index_t cache_table[] = {
2363baa08fek		{ "none",	ZFS_CACHE_NONE },
2373baa08fek		{ "metadata",	ZFS_CACHE_METADATA },
2383baa08fek		{ "all",	ZFS_CACHE_ALL },
2393baa08fek		{ NULL }
2403baa08fek	};
2413baa08fek
24255da60bMark J Musante	static zprop_index_t sync_table[] = {
24355da60bMark J Musante		{ "standard",	ZFS_SYNC_STANDARD },
24455da60bMark J Musante		{ "always",	ZFS_SYNC_ALWAYS },
24555da60bMark J Musante		{ "disabled",	ZFS_SYNC_DISABLED },
24655da60bMark J Musante		{ NULL }
24755da60bMark J Musante	};
24855da60bMark J Musante
24954811daToomas Soome	static zprop_index_t dnsize_table[] = {
25054811daToomas Soome		{ "legacy",	ZFS_DNSIZE_LEGACY },
25154811daToomas Soome		{ "auto",	ZFS_DNSIZE_AUTO },
25254811daToomas Soome		{ "1k",		ZFS_DNSIZE_1K },
25354811daToomas Soome		{ "2k",		ZFS_DNSIZE_2K },
25454811daToomas Soome		{ "4k",		ZFS_DNSIZE_4K },
25554811daToomas Soome		{ "8k",		ZFS_DNSIZE_8K },
25654811daToomas Soome		{ "16k",	ZFS_DNSIZE_16K },
25754811daToomas Soome		{ NULL }
25854811daToomas Soome	};
25954811daToomas Soome
260edf345eMatthew Ahrens	static zprop_index_t redundant_metadata_table[] = {
261edf345eMatthew Ahrens		{ "all",	ZFS_REDUNDANT_METADATA_ALL },
262edf345eMatthew Ahrens		{ "most",	ZFS_REDUNDANT_METADATA_MOST },
263edf345eMatthew Ahrens		{ NULL }
264edf345eMatthew Ahrens	};
265edf345eMatthew Ahrens
26691ebeefahrens	/* inherit index properties */
267edf345eMatthew Ahrens	zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
268edf345eMatthew Ahrens	    ZFS_REDUNDANT_METADATA_ALL,
269edf345eMatthew Ahrens	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
270edf345eMatthew Ahrens	    "all | most", "REDUND_MD",
271edf345eMatthew Ahrens	    redundant_metadata_table);
27255da60bMark J Musante	zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
27355da60bMark J Musante	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
27455da60bMark J Musante	    "standard | always | disabled", "SYNC",
27555da60bMark J Musante	    sync_table);
27683d7f9fTom Erickson	zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
27783d7f9fTom Erickson	    ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
27883d7f9fTom Erickson	    ZFS_TYPE_VOLUME,
27945818eeMatthew Ahrens	    "on | off | fletcher2 | fletcher4 | sha256 | sha512 | "
28045818eeMatthew Ahrens	    "skein | edonr", "CHECKSUM", checksum_table);
28183d7f9fTom Erickson	zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
282b24ab67Jeff Bonwick	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
28345818eeMatthew Ahrens	    "on | off | verify | sha256[,verify], sha512[,verify], "
28445818eeMatthew Ahrens	    "skein[,verify], edonr,verify", "DEDUP", dedup_table);
28583d7f9fTom Erickson	zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
286e45ce72ahrens	    ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
287e45ce72ahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
288a6f561bSašo Kiselkov	    "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4",
289a6f561bSašo Kiselkov	    "COMPRESS", compress_table);
29083d7f9fTom Erickson	zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
291e45ce72ahrens	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
292e45ce72ahrens	    "hidden | visible", "SNAPDIR", snapdir_table);
293a3c49ceAlbert Lee	zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
294a3c49ceAlbert Lee	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
29571dbfc2Paul B. Henson	    "discard | groupmask | passthrough | restricted", "ACLMODE",
29671dbfc2Paul B. Henson	    acl_mode_table);
29783d7f9fTom Erickson	zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
29883d7f9fTom Erickson	    ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
299d0f3f37Mark Shellenbaum	    "discard | noallow | restricted | passthrough | passthrough-x",
300b3d141fmarks	    "ACLINHERIT", acl_inherit_table);
30183d7f9fTom Erickson	zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
30283d7f9fTom Erickson	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
30391ebeefahrens	    "1 | 2 | 3", "COPIES", copies_table);
30483d7f9fTom Erickson	zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
3053baa08fek	    ZFS_CACHE_ALL, PROP_INHERIT,
3063baa08fek	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
3073baa08fek	    "all | none | metadata", "PRIMARYCACHE", cache_table);
30883d7f9fTom Erickson	zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
3093baa08fek	    ZFS_CACHE_ALL, PROP_INHERIT,
3103baa08fek	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
3113baa08fek	    "all | none | metadata", "SECONDARYCACHE", cache_table);
31283d7f9fTom Erickson	zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
313e09fa4dNeil Perrin	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
314e09fa4dNeil Perrin	    "latency | throughput", "LOGBIAS", logbias_table);
31554811daToomas Soome
31654811daToomas Soome	zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",
31754811daToomas Soome	    ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
31854811daToomas Soome	    "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table);
319e45ce72ahrens
320e45ce72ahrens	/* inherit index (boolean) properties */
32183d7f9fTom Erickson	zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
322e45ce72ahrens	    ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
32383d7f9fTom Erickson	zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
324e45ce72ahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
325e45ce72ahrens	    boolean_table);
32683d7f9fTom Erickson	zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
327e45ce72ahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
328e45ce72ahrens	    boolean_table);
32983d7f9fTom Erickson	zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
330e45ce72ahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
331e45ce72ahrens	    boolean_table);
33283d7f9fTom Erickson	zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
333e45ce72ahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
334e45ce72ahrens	    boolean_table);
33583d7f9fTom Erickson	zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
336e45ce72ahrens	    ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
33783d7f9fTom Erickson	zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
338e45ce72ahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
339e45ce72ahrens	    boolean_table);
34083d7f9fTom Erickson	zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
341da6c28aamw	    ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
342da6c28aamw	    boolean_table);
34383d7f9fTom Erickson	zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
344da6c28aamw	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
345da6c28aamw	    boolean_table);
346e45ce72ahrens
347e45ce72ahrens	/* default index properties */
34883d7f9fTom Erickson	zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
3497b55fa8ck	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
35019b94dfMatthew Ahrens	    "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table);
35183d7f9fTom Erickson	zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
352a227b7fhs	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
353a227b7fhs	    "CANMOUNT", canmount_table);
354e45ce72ahrens
355eb63303Tom Caputi	/* readonly index properties */
35683d7f9fTom Erickson	zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
357990b485lling	    ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
35883d7f9fTom Erickson	zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
359842727cChris Kirby	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
360842727cChris Kirby	    boolean_table);
361eb63303Tom Caputi	zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",
362eb63303Tom Caputi	    ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,
363eb63303Tom Caputi	    "none | unavailable | available",
364eb63303Tom Caputi	    "KEYSTATUS", keystatus_table);
365e45ce72ahrens
366da6c28aamw	/* set once index properties */
36783d7f9fTom Erickson	zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
368da6c28aamw	    PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
369da6c28aamw	    "none | formC | formD | formKC | formKD", "NORMALIZATION",
370da6c28aamw	    normalize_table);
37183d7f9fTom Erickson	zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
37283d7f9fTom Erickson	    ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
37383d7f9fTom Erickson	    ZFS_TYPE_SNAPSHOT,
374da6c28aamw	    "sensitive | insensitive | mixed", "CASE", case_table);
375eb63303Tom Caputi	zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",
376eb63303Tom Caputi	    ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,
377eb63303Tom Caputi	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
378eb63303Tom Caputi	    "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table);
379eb63303Tom Caputi	zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption",
380eb63303Tom Caputi	    ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET,
381eb63303Tom Caputi	    "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "
382eb63303Tom Caputi	    "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",
383eb63303Tom Caputi	    crypto_table);
384da6c28aamw
385da6c28aamw	/* set once index (boolean) properties */
38683d7f9fTom Erickson	zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
387da6c28aamw	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
388da6c28aamw	    "on | off", "UTF8ONLY", boolean_table);
389da6c28aamw
39091ebeefahrens	/* string properties */
39183d7f9fTom Erickson	zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
39291ebeefahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
39319b94dfMatthew Ahrens	zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
39419b94dfMatthew Ahrens	    ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES");
39583d7f9fTom Erickson	zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
39683d7f9fTom Erickson	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
39783d7f9fTom Erickson	    "MOUNTPOINT");
39883d7f9fTom Erickson	zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
39983d7f9fTom Erickson	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options",
40083d7f9fTom Erickson	    "SHARENFS");
40183d7f9fTom Erickson	zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
40278f1710Matthew Ahrens	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
40378f1710Matthew Ahrens	    "filesystem | volume | snapshot | bookmark", "TYPE");
40483d7f9fTom Erickson	zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
40583d7f9fTom Erickson	    PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
40683d7f9fTom Erickson	    "on | off | sharemgr(1M) options", "SHARESMB");
40783d7f9fTom Erickson	zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
40883d7f9fTom Erickson	    ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
40983d7f9fTom Erickson	    "<sensitivity label>", "MLSLABEL");
4109c3fd12Matthew Ahrens	zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN,
4119c3fd12Matthew Ahrens	    "receive_resume_token",
4129c3fd12Matthew Ahrens	    NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
4139c3fd12Matthew Ahrens	    "<string token>", "RESUMETOK");
414eb63303Tom Caputi	zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,
415eb63303Tom Caputi	    PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",
416eb63303Tom Caputi	    "ENCROOT");
417eb63303Tom Caputi	zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",
418eb63303Tom Caputi	    "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
419eb63303Tom Caputi	    "prompt | <file URI>", "KEYLOCATION");
42091ebeefahrens
42191ebeefahrens	/* readonly number properties */
42283d7f9fTom Erickson	zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
423990b485lling	    ZFS_TYPE_DATASET, "<size>", "USED");
42483d7f9fTom Erickson	zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
425990b485lling	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
42683d7f9fTom Erickson	zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
42783d7f9fTom Erickson	    PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER");
42883d7f9fTom Erickson	zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
429990b485lling	    PROP_READONLY, ZFS_TYPE_DATASET,
43091ebeefahrens	    "<1.00x or higher if compressed>", "RATIO");
431187d6acMatt Ahrens	zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
432187d6acMatt Ahrens	    PROP_READONLY, ZFS_TYPE_DATASET,
433187d6acMatt Ahrens	    "<1.00x or higher if compressed>", "REFRATIO");
43483d7f9fTom Erickson	zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
435c144956Eric Taylor	    ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
436da6c28aamw	    ZFS_TYPE_VOLUME, "512 to 128k, power of 2",	"VOLBLOCK");
43783d7f9fTom Erickson	zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
43883d7f9fTom Erickson	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
43983d7f9fTom Erickson	    "USEDSNAP");
44083d7f9fTom Erickson	zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
44183d7f9fTom Erickson	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
44283d7f9fTom Erickson	    "USEDDS");
44383d7f9fTom Erickson	zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
44483d7f9fTom Erickson	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
44583d7f9fTom Erickson	    "USEDCHILD");
44683d7f9fTom Erickson	zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
44774e7dc9Matthew Ahrens	    PROP_READONLY,
44874e7dc9Matthew Ahrens	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
44983d7f9fTom Erickson	zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
450842727cChris Kirby	    ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
45119b94dfMatthew Ahrens	zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
45219b94dfMatthew Ahrens	    ZFS_TYPE_DATASET, "<size>", "WRITTEN");
45377372cbMatthew Ahrens	zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
454dfc1153Chris Williamson	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
455dfc1153Chris Williamson	    "LUSED");
45677372cbMatthew Ahrens	zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
45777372cbMatthew Ahrens	    0, PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LREFER");
458007a6c1Jerry Jelinek	zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
459007a6c1Jerry Jelinek	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM,
460007a6c1Jerry Jelinek	    "<count>", "FSCOUNT");
461007a6c1Jerry Jelinek	zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
462007a6c1Jerry Jelinek	    UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
463007a6c1Jerry Jelinek	    "<count>", "SSCOUNT");
464e8d4a73Josh Paetzel	zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY,
465e8d4a73Josh Paetzel	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID");
466e8d4a73Josh Paetzel	zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,
467e8d4a73Josh Paetzel	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG");
468eb63303Tom Caputi	zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",
469eb63303Tom Caputi	    0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
470eb63303Tom Caputi	    "<iters>", "PBKDF2ITERS");
47191ebeefahrens
47291ebeefahrens	/* default number properties */
47383d7f9fTom Erickson	zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
47491ebeefahrens	    ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
47583d7f9fTom Erickson	zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
47683d7f9fTom Erickson	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
47783d7f9fTom Erickson	    "<size> | none", "RESERV");
47883d7f9fTom Erickson	zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
47991ebeefahrens	    ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
48083d7f9fTom Erickson	zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
481a979902ck	    ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
48283d7f9fTom Erickson	zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
483a979902ck	    PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
484a979902ck	    "<size> | none", "REFRESERV");
485a2afb61Jerry Jelinek	zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
486a2afb61Jerry Jelinek	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
487a2afb61Jerry Jelinek	    "<count> | none", "FSLIMIT");
488a2afb61Jerry Jelinek	zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
489a2afb61Jerry Jelinek	    UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
490a2afb61Jerry Jelinek	    "<count> | none", "SSLIMIT");
49191ebeefahrens
49291ebeefahrens	/* inherit number properties */
49383d7f9fTom Erickson	zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
494b515258Matthew Ahrens	    SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,
495b515258Matthew Ahrens	    ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE");
496663207aDon Brady	zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,
497663207aDon Brady	    "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
498663207aDon Brady	    "zero or 512 to 128K, power of 2", "SPECIAL_SMALL_BLOCKS");
49991ebeefahrens
50091ebeefahrens	/* hidden properties */
5015cabbc6Prashanth Sreenivasa	zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,
5025cabbc6Prashanth Sreenivasa	    PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG");
50383d7f9fTom Erickson	zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
504b24ab67Jeff Bonwick	    PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
50583d7f9fTom Erickson	zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
50678f1710Matthew Ahrens	    PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME");
50783d7f9fTom Erickson	zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
50883d7f9fTom Erickson	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
50983d7f9fTom Erickson	zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
510478ed9aEric Taylor	    PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
511478ed9aEric Taylor	    "STMF_SBD_LU");
51283d7f9fTom Erickson	zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
513b24ab67Jeff Bonwick	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
514b24ab67Jeff Bonwick	    "USERACCOUNTING");
51583d7f9fTom Erickson	zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
516b24ab67Jeff Bonwick	    PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
51783d7f9fTom Erickson	zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
5181d71320Eric Schrock	    PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
519ca48f36Keith M Wesolowski	zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
520ca48f36Keith M Wesolowski	    PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT");
521eb63303Tom Caputi	zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid",
522eb63303Tom Caputi	    PROP_TYPE_NUMBER, PROP_READONLY,
523eb63303Tom Caputi	    ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID");
524b461c74Matthew Ahrens	zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
525b461c74Matthew Ahrens	    PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP");
526eb63303Tom Caputi	zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",
527eb63303Tom Caputi	    PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,
528eb63303Tom Caputi	    ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT");
529eb63303Tom Caputi	zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,
530eb63303Tom Caputi	    PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID");
53191ebeefahrens
53291ebeefahrens	/* oddball properties */
53383d7f9fTom Erickson	zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
53478f1710Matthew Ahrens	    NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
53591ebeefahrens	    "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
53691ebeefahrens}
53791ebeefahrens
538b1b8ab3llingboolean_t
539990b485llingzfs_prop_delegatable(zfs_prop_t prop)
540fa9e406ahrens{
541990b485lling	zprop_desc_t *pd = &zfs_prop_table[prop];
5424201a95Ric Aleshire
5434201a95Ric Aleshire	/* The mlslabel property is never delegatable. */
5444201a95Ric Aleshire	if (prop == ZFS_PROP_MLSLABEL)
5454201a95Ric Aleshire		return (B_FALSE);
5464201a95Ric Aleshire
547990b485lling	return (pd->pd_attr != PROP_READONLY);
548fa9e406ahrens}
549fa9e406ahrens
550fa9e406ahrens/*
551b1b8ab3lling * Given a zfs dataset property name, returns the corresponding property ID.
552b1b8ab3lling */
553b1b8ab3llingzfs_prop_t
554b1b8ab3llingzfs_name_to_prop(const char *propname)
555b1b8ab3lling{
556990b485lling	return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
557b1b8ab3lling}
558b1b8ab3lling
559b1b8ab3lling/*
560e9dbad6eschrock * For user property names, we allow all lowercase alphanumeric characters, plus
561e9dbad6eschrock * a few useful punctuation characters.
562e9dbad6eschrock */
563e9dbad6eschrockstatic int
564e9dbad6eschrockvalid_char(char c)
565e9dbad6eschrock{
566e9dbad6eschrock	return ((c >= 'a' && c <= 'z') ||
567e9dbad6eschrock	    (c >= '0' && c <= '9') ||
568e9dbad6eschrock	    c == '-' || c == '_' || c == '.' || c == ':');
569e9dbad6eschrock}
570e9dbad6eschrock
571e9dbad6eschrock/*
572