zfs_prop.c revision 8ac09fcebf848c31516b15ce92861de4b2f514e8
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * CDDL HEADER START
20c794b39650d115e17a15983b6b82e46238cf45gavinm *
20c794b39650d115e17a15983b6b82e46238cf45gavinm * The contents of this file are subject to the terms of the
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Common Development and Distribution License (the "License").
20c794b39650d115e17a15983b6b82e46238cf45gavinm * You may not use this file except in compliance with the License.
20c794b39650d115e17a15983b6b82e46238cf45gavinm *
20c794b39650d115e17a15983b6b82e46238cf45gavinm * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
20c794b39650d115e17a15983b6b82e46238cf45gavinm * or http://www.opensolaris.org/os/licensing.
20c794b39650d115e17a15983b6b82e46238cf45gavinm * See the License for the specific language governing permissions
20c794b39650d115e17a15983b6b82e46238cf45gavinm * and limitations under the License.
20c794b39650d115e17a15983b6b82e46238cf45gavinm *
20c794b39650d115e17a15983b6b82e46238cf45gavinm * When distributing Covered Code, include this CDDL HEADER in each
20c794b39650d115e17a15983b6b82e46238cf45gavinm * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20c794b39650d115e17a15983b6b82e46238cf45gavinm * If applicable, add the following below this CDDL HEADER, with the
20c794b39650d115e17a15983b6b82e46238cf45gavinm * fields enclosed by brackets "[]" replaced with your own identifying
20c794b39650d115e17a15983b6b82e46238cf45gavinm * information: Portions Copyright [yyyy] [name of copyright owner]
20c794b39650d115e17a15983b6b82e46238cf45gavinm *
20c794b39650d115e17a15983b6b82e46238cf45gavinm * CDDL HEADER END
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan * Copyright (c) 2011 by Delphix. All rights reserved.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/* Portions Copyright 2010 Robert Milkowski */
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <sys/zio.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <sys/spa.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <sys/u8_textprep.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <sys/zfs_acl.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <sys/zfs_ioctl.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <sys/zfs_znode.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include "zfs_prop.h"
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include "zfs_deleg.h"
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm#if defined(_KERNEL)
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <sys/systm.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#else
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <stdlib.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <string.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#include <ctype.h>
20c794b39650d115e17a15983b6b82e46238cf45gavinm#endif
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmstatic zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier/* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
20c794b39650d115e17a15983b6b82e46238cf45gavinmconst char *zfs_userquota_prop_prefixes[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm "userused@",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "userquota@",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "groupused@",
25f476773dea2a0ee593dcf662a38d5f02487196gavinm "groupquota@"
20c794b39650d115e17a15983b6b82e46238cf45gavinm};
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmzprop_desc_t *
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_get_table(void)
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier{
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier return (zfs_prop_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmvoid
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_init(void)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t checksum_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "on", ZIO_CHECKSUM_ON },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "off", ZIO_CHECKSUM_OFF },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "sha256", ZIO_CHECKSUM_SHA256 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t dedup_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "on", ZIO_CHECKSUM_ON },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "off", ZIO_CHECKSUM_OFF },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "sha256", ZIO_CHECKSUM_SHA256 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "sha256,verify",
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm { NULL }
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm };
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm static zprop_index_t compress_table[] = {
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm { "on", ZIO_COMPRESS_ON },
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm { "off", ZIO_COMPRESS_OFF },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "lzjb", ZIO_COMPRESS_LZJB },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-1", ZIO_COMPRESS_GZIP_1 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-2", ZIO_COMPRESS_GZIP_2 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-3", ZIO_COMPRESS_GZIP_3 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-4", ZIO_COMPRESS_GZIP_4 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-5", ZIO_COMPRESS_GZIP_5 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-6", ZIO_COMPRESS_GZIP_6 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-7", ZIO_COMPRESS_GZIP_7 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-8", ZIO_COMPRESS_GZIP_8 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "gzip-9", ZIO_COMPRESS_GZIP_9 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "zle", ZIO_COMPRESS_ZLE },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
25f476773dea2a0ee593dcf662a38d5f02487196gavinm
25f476773dea2a0ee593dcf662a38d5f02487196gavinm static zprop_index_t snapdir_table[] = {
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "hidden", ZFS_SNAPDIR_HIDDEN },
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "visible", ZFS_SNAPDIR_VISIBLE },
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm { NULL }
25f476773dea2a0ee593dcf662a38d5f02487196gavinm };
25f476773dea2a0ee593dcf662a38d5f02487196gavinm
25f476773dea2a0ee593dcf662a38d5f02487196gavinm static zprop_index_t acl_mode_table[] = {
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "discard", ZFS_ACL_DISCARD },
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "groupmask", ZFS_ACL_GROUPMASK },
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "passthrough", ZFS_ACL_PASSTHROUGH },
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm { NULL }
25f476773dea2a0ee593dcf662a38d5f02487196gavinm };
25f476773dea2a0ee593dcf662a38d5f02487196gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t acl_inherit_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "discard", ZFS_ACL_DISCARD },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "noallow", ZFS_ACL_NOALLOW },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "restricted", ZFS_ACL_RESTRICTED },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "passthrough", ZFS_ACL_PASSTHROUGH },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatability */
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t case_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "sensitive", ZFS_CASE_SENSITIVE },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "insensitive", ZFS_CASE_INSENSITIVE },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "mixed", ZFS_CASE_MIXED },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
25f476773dea2a0ee593dcf662a38d5f02487196gavinm
25f476773dea2a0ee593dcf662a38d5f02487196gavinm static zprop_index_t copies_table[] = {
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "1", 1 },
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "2", 2 },
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { "3", 3 },
25f476773dea2a0ee593dcf662a38d5f02487196gavinm { NULL }
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan };
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan /*
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan * Use the unique flags we have to send to u8_strcmp() and/or
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan * u8_textprep() to represent the various normalization property
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan * values.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t normalize_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "none", 0 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "formD", U8_TEXTPREP_NFD },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "formKC", U8_TEXTPREP_NFKC },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "formC", U8_TEXTPREP_NFC },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "formKD", U8_TEXTPREP_NFKD },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t version_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "1", 1 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "2", 2 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "3", 3 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "4", 4 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "5", 5 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "current", ZPL_VERSION },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t boolean_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "off", 0 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "on", 1 },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t logbias_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "latency", ZFS_LOGBIAS_LATENCY },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "throughput", ZFS_LOGBIAS_THROUGHPUT },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t canmount_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "off", ZFS_CANMOUNT_OFF },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "on", ZFS_CANMOUNT_ON },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "noauto", ZFS_CANMOUNT_NOAUTO },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t cache_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "none", ZFS_CACHE_NONE },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "metadata", ZFS_CACHE_METADATA },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "all", ZFS_CACHE_ALL },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm static zprop_index_t sync_table[] = {
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "standard", ZFS_SYNC_STANDARD },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "always", ZFS_SYNC_ALWAYS },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { "disabled", ZFS_SYNC_DISABLED },
20c794b39650d115e17a15983b6b82e46238cf45gavinm { NULL }
20c794b39650d115e17a15983b6b82e46238cf45gavinm };
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* inherit index properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "standard | always | disabled", "SYNC",
20c794b39650d115e17a15983b6b82e46238cf45gavinm sync_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
20c794b39650d115e17a15983b6b82e46238cf45gavinm checksum_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "on | off | verify | sha256[,verify]", "DEDUP",
20c794b39650d115e17a15983b6b82e46238cf45gavinm dedup_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "on | off | lzjb | gzip | gzip-[1-9] | zle", "COMPRESS",
20c794b39650d115e17a15983b6b82e46238cf45gavinm compress_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "hidden | visible", "SNAPDIR", snapdir_table);
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "discard | groupmask | passthrough", "ACLMODE", acl_mode_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan "discard | noallow | restricted | passthrough | passthrough-x",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "ACLINHERIT", acl_inherit_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "1 | 2 | 3", "COPIES", copies_table);
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_CACHE_ALL, PROP_INHERIT,
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "all | none | metadata", "PRIMARYCACHE", cache_table);
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_CACHE_ALL, PROP_INHERIT,
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "all | none | metadata", "SECONDARYCACHE", cache_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan "latency | throughput", "LOGBIAS", logbias_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan /* inherit index (boolean) properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* default index properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "1 | 2 | 3 | 4 | current", "VERSION", version_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "CANMOUNT", canmount_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* readonly index (boolean) properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* set once index properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "none | formC | formD | formKC | formKD", "NORMALIZATION",
20c794b39650d115e17a15983b6b82e46238cf45gavinm normalize_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_SNAPSHOT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "sensitive | insensitive | mixed", "CASE", case_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan /* set once index (boolean) properties */
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "on | off", "UTF8ONLY", boolean_table);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* string properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "MOUNTPOINT");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "SHARENFS");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan "on | off | sharemgr(1M) options", "SHARESMB");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "<sensitivity label>", "MLSLABEL");
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* readonly number properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_DATASET, "<size>", "USED");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_DATASET,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "<1.00x or higher if compressed>", "RATIO");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_DATASET,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "<1.00x or higher if compressed>", "REFRATIO");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "USEDSNAP");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "USEDDS");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
20c794b39650d115e17a15983b6b82e46238cf45gavinm "USEDCHILD");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* default number properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan "<size> | none", "RESERV");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "<size> | none", "REFRESERV");
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* inherit number properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
20c794b39650d115e17a15983b6b82e46238cf45gavinm SPA_MAXBLOCKSIZE, PROP_INHERIT,
20c794b39650d115e17a15983b6b82e46238cf45gavinm ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE");
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* hidden properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_DATASET, "NAME");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "STMF_SBD_LU");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_DATASET, "GUID");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "USERACCOUNTING");
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
20c794b39650d115e17a15983b6b82e46238cf45gavinm PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* oddball properties */
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
20c794b39650d115e17a15983b6b82e46238cf45gavinm NULL, PROP_READONLY, ZFS_TYPE_DATASET,
20c794b39650d115e17a15983b6b82e46238cf45gavinm "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesanboolean_t
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesanzfs_prop_delegatable(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm zprop_desc_t *pd = &zfs_prop_table[prop];
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm /* The mlslabel property is never delegatable. */
20c794b39650d115e17a15983b6b82e46238cf45gavinm if (prop == ZFS_PROP_MLSLABEL)
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (B_FALSE);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (pd->pd_attr != PROP_READONLY);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Given a zfs dataset property name, returns the corresponding property ID.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_name_to_prop(const char *propname)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * For user property names, we allow all lowercase alphanumeric characters, plus
20c794b39650d115e17a15983b6b82e46238cf45gavinm * a few useful punctuation characters.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmstatic int
20c794b39650d115e17a15983b6b82e46238cf45gavinmvalid_char(char c)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return ((c >= 'a' && c <= 'z') ||
20c794b39650d115e17a15983b6b82e46238cf45gavinm (c >= '0' && c <= '9') ||
20c794b39650d115e17a15983b6b82e46238cf45gavinm c == '-' || c == '_' || c == '.' || c == ':');
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns true if this is a valid user-defined property (one with a ':').
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmboolean_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_user(const char *name)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm int i;
20c794b39650d115e17a15983b6b82e46238cf45gavinm char c;
20c794b39650d115e17a15983b6b82e46238cf45gavinm boolean_t foundsep = B_FALSE;
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm for (i = 0; i < strlen(name); i++) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm c = name[i];
20c794b39650d115e17a15983b6b82e46238cf45gavinm if (!valid_char(c))
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (B_FALSE);
20c794b39650d115e17a15983b6b82e46238cf45gavinm if (c == ':')
20c794b39650d115e17a15983b6b82e46238cf45gavinm foundsep = B_TRUE;
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm if (!foundsep)
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (B_FALSE);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan return (B_TRUE);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns true if this is a valid userspace-type property (one with a '@').
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Note that after the @, any character is valid (eg, another @, for SID
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla * user@domain).
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla */
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvillaboolean_t
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvillazfs_prop_userquota(const char *name)
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla{
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla zfs_userquota_prop_t prop;
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla if (strncmp(name, zfs_userquota_prop_prefixes[prop],
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla return (B_TRUE);
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan }
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan }
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan return (B_FALSE);
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla}
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan/*
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla * Tables of index types, plus functions to convert between the user view
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla * (strings) and internal representation (uint64_t).
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla */
20c794b39650d115e17a15983b6b82e46238cf45gavinmint
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmint
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesanuint64_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
a24e89c4a1eec8361718d94a6275e6720643284eKuriakose Kuruvilla/*
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan * Returns TRUE if the property applies to any of the given dataset types.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmboolean_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_valid_for_type(int prop, zfs_type_t types)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zprop_valid_for_type(prop, types));
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmzprop_type_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_get_type(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_proptype);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns TRUE if the property is readonly.
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan */
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesanboolean_t
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesanzfs_prop_readonly(zfs_prop_t prop)
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan{
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan zfs_prop_table[prop].pd_attr == PROP_ONETIME);
a3c4695861e3f0a8d3706f77ccd53683cca48d67gavinm}
a3c4695861e3f0a8d3706f77ccd53683cca48d67gavinm
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns TRUE if the property is only allowed to be set once.
8031591d3cc3c82e97f4b60ea22d671525077b15Srihari Venkatesan */
20c794b39650d115e17a15983b6b82e46238cf45gavinmboolean_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_setonce(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_attr == PROP_ONETIME);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmconst char *
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_default_string(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_strdefault);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmuint64_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_default_numeric(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_numdefault);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Given a dataset property ID, returns the corresponding name.
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Assuming the zfs dataset property ID is valid.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmconst char *
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_to_name(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_name);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns TRUE if the property is inheritable.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmboolean_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_inheritable(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
20c794b39650d115e17a15983b6b82e46238cf45gavinm zfs_prop_table[prop].pd_attr == PROP_ONETIME);
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm}
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm#ifndef _KERNEL
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns a string describing the set of acceptable values for the given
20c794b39650d115e17a15983b6b82e46238cf45gavinm * zfs property, or NULL if it cannot be set.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesanconst char *
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinmzfs_prop_values(zfs_prop_t prop)
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan{
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm return (zfs_prop_table[prop].pd_values);
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm}
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm/*
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm * Returns TRUE if this property is a string type. Note that index types
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm * (compression, checksum) are treated as strings in userland, even though they
20c794b39650d115e17a15983b6b82e46238cf45gavinm * are stored numerically on disk.
a4e4e13f4001644f2f960e3be0056c22b3a40fd1gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmint
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_is_string(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
20c794b39650d115e17a15983b6b82e46238cf45gavinm zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns the column header for the given property. Used only in
5667185bc023b9742cb2480659d7673fa9ac8050Srihari Venkatesan * 'zfs list -o', but centralized here with the other property information.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmconst char *
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_column_name(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_colname);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm/*
20c794b39650d115e17a15983b6b82e46238cf45gavinm * Returns whether the given property should be displayed right-justified for
20c794b39650d115e17a15983b6b82e46238cf45gavinm * 'zfs list'.
20c794b39650d115e17a15983b6b82e46238cf45gavinm */
20c794b39650d115e17a15983b6b82e46238cf45gavinmboolean_t
20c794b39650d115e17a15983b6b82e46238cf45gavinmzfs_prop_align_right(zfs_prop_t prop)
20c794b39650d115e17a15983b6b82e46238cf45gavinm{
20c794b39650d115e17a15983b6b82e46238cf45gavinm return (zfs_prop_table[prop].pd_rightalign);
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm#endif
20c794b39650d115e17a15983b6b82e46238cf45gavinm