1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5906d120cSlling * Common Development and Distribution License (the "License"). 6906d120cSlling * You may not use this file except in compliance with the License. 7fa9e4066Sahrens * 8fa9e4066Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fa9e4066Sahrens * or http://www.opensolaris.org/os/licensing. 10fa9e4066Sahrens * See the License for the specific language governing permissions 11fa9e4066Sahrens * and limitations under the License. 12fa9e4066Sahrens * 13fa9e4066Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14fa9e4066Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fa9e4066Sahrens * If applicable, add the following below this CDDL HEADER, with the 16fa9e4066Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17fa9e4066Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18fa9e4066Sahrens * 19fa9e4066Sahrens * CDDL HEADER END 20fa9e4066Sahrens */ 21fa9e4066Sahrens /* 2227dd1e87SMark Shellenbaum * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23edf345e6SMatthew Ahrens * Copyright (c) 2011, 2014 by Delphix. All rights reserved. 24a6f561b4SSašo Kiselkov * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. 25810e43b2SBill Pijewski * Copyright (c) 2013, Joyent, Inc. All rights reserved. 26c3d26abcSMatthew Ahrens * Copyright (c) 2014 Integros [integros.com] 27fa9e4066Sahrens */ 28fa9e4066Sahrens 2955da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */ 3055da60b9SMark J Musante 31fa9e4066Sahrens #include <sys/zio.h> 32fa9e4066Sahrens #include <sys/spa.h> 33de8267e0Stimh #include <sys/u8_textprep.h> 34fa9e4066Sahrens #include <sys/zfs_acl.h> 35fa9e4066Sahrens #include <sys/zfs_ioctl.h> 36e7437265Sahrens #include <sys/zfs_znode.h> 37fa9e4066Sahrens 38fa9e4066Sahrens #include "zfs_prop.h" 39ecd6cf80Smarks #include "zfs_deleg.h" 40fa9e4066Sahrens 41fa9e4066Sahrens #if defined(_KERNEL) 42fa9e4066Sahrens #include <sys/systm.h> 43fa9e4066Sahrens #else 44fa9e4066Sahrens #include <stdlib.h> 45fa9e4066Sahrens #include <string.h> 46fa9e4066Sahrens #include <ctype.h> 47fa9e4066Sahrens #endif 48fa9e4066Sahrens 49990b4856Slling static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; 50fa9e4066Sahrens 5114843421SMatthew Ahrens /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */ 5214843421SMatthew Ahrens const char *zfs_userquota_prop_prefixes[] = { 5314843421SMatthew Ahrens "userused@", 5414843421SMatthew Ahrens "userquota@", 5514843421SMatthew Ahrens "groupused@", 5614843421SMatthew Ahrens "groupquota@" 5714843421SMatthew Ahrens }; 5814843421SMatthew Ahrens 59990b4856Slling zprop_desc_t * 60990b4856Slling zfs_prop_get_table(void) 6191ebeef5Sahrens { 62990b4856Slling return (zfs_prop_table); 6391ebeef5Sahrens } 6491ebeef5Sahrens 6591ebeef5Sahrens void 6691ebeef5Sahrens zfs_prop_init(void) 6791ebeef5Sahrens { 68990b4856Slling static zprop_index_t checksum_table[] = { 6991ebeef5Sahrens { "on", ZIO_CHECKSUM_ON }, 7091ebeef5Sahrens { "off", ZIO_CHECKSUM_OFF }, 7191ebeef5Sahrens { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, 7291ebeef5Sahrens { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, 7391ebeef5Sahrens { "sha256", ZIO_CHECKSUM_SHA256 }, 74810e43b2SBill Pijewski { "noparity", ZIO_CHECKSUM_NOPARITY }, 7545818ee1SMatthew Ahrens { "sha512", ZIO_CHECKSUM_SHA512 }, 7645818ee1SMatthew Ahrens { "skein", ZIO_CHECKSUM_SKEIN }, 7745818ee1SMatthew Ahrens { "edonr", ZIO_CHECKSUM_EDONR }, 7891ebeef5Sahrens { NULL } 79fa9e4066Sahrens }; 80fa9e4066Sahrens 81b24ab676SJeff Bonwick static zprop_index_t dedup_table[] = { 82b24ab676SJeff Bonwick { "on", ZIO_CHECKSUM_ON }, 83b24ab676SJeff Bonwick { "off", ZIO_CHECKSUM_OFF }, 84b24ab676SJeff Bonwick { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY }, 85b24ab676SJeff Bonwick { "sha256", ZIO_CHECKSUM_SHA256 }, 86b24ab676SJeff Bonwick { "sha256,verify", 87b24ab676SJeff Bonwick ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY }, 8845818ee1SMatthew Ahrens { "sha512", ZIO_CHECKSUM_SHA512 }, 8945818ee1SMatthew Ahrens { "sha512,verify", 9045818ee1SMatthew Ahrens ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY }, 9145818ee1SMatthew Ahrens { "skein", ZIO_CHECKSUM_SKEIN }, 9245818ee1SMatthew Ahrens { "skein,verify", 9345818ee1SMatthew Ahrens ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY }, 9445818ee1SMatthew Ahrens { "edonr,verify", 9545818ee1SMatthew Ahrens ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY }, 96b24ab676SJeff Bonwick { NULL } 97b24ab676SJeff Bonwick }; 98b24ab676SJeff Bonwick 99990b4856Slling static zprop_index_t compress_table[] = { 10091ebeef5Sahrens { "on", ZIO_COMPRESS_ON }, 10191ebeef5Sahrens { "off", ZIO_COMPRESS_OFF }, 10291ebeef5Sahrens { "lzjb", ZIO_COMPRESS_LZJB }, 10391ebeef5Sahrens { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ 10491ebeef5Sahrens { "gzip-1", ZIO_COMPRESS_GZIP_1 }, 10591ebeef5Sahrens { "gzip-2", ZIO_COMPRESS_GZIP_2 }, 10691ebeef5Sahrens { "gzip-3", ZIO_COMPRESS_GZIP_3 }, 10791ebeef5Sahrens { "gzip-4", ZIO_COMPRESS_GZIP_4 }, 10891ebeef5Sahrens { "gzip-5", ZIO_COMPRESS_GZIP_5 }, 10991ebeef5Sahrens { "gzip-6", ZIO_COMPRESS_GZIP_6 }, 11091ebeef5Sahrens { "gzip-7", ZIO_COMPRESS_GZIP_7 }, 11191ebeef5Sahrens { "gzip-8", ZIO_COMPRESS_GZIP_8 }, 11291ebeef5Sahrens { "gzip-9", ZIO_COMPRESS_GZIP_9 }, 113b24ab676SJeff Bonwick { "zle", ZIO_COMPRESS_ZLE }, 114a6f561b4SSašo Kiselkov { "lz4", ZIO_COMPRESS_LZ4 }, 11591ebeef5Sahrens { NULL } 11691ebeef5Sahrens }; 11791ebeef5Sahrens 118990b4856Slling static zprop_index_t snapdir_table[] = { 11991ebeef5Sahrens { "hidden", ZFS_SNAPDIR_HIDDEN }, 12091ebeef5Sahrens { "visible", ZFS_SNAPDIR_VISIBLE }, 12191ebeef5Sahrens { NULL } 12291ebeef5Sahrens }; 12391ebeef5Sahrens 124a3c49ce1SAlbert Lee static zprop_index_t acl_mode_table[] = { 125a3c49ce1SAlbert Lee { "discard", ZFS_ACL_DISCARD }, 126a3c49ce1SAlbert Lee { "groupmask", ZFS_ACL_GROUPMASK }, 127a3c49ce1SAlbert Lee { "passthrough", ZFS_ACL_PASSTHROUGH }, 12871dbfc28SPaul B. Henson { "restricted", ZFS_ACL_RESTRICTED }, 129a3c49ce1SAlbert Lee { NULL } 130a3c49ce1SAlbert Lee }; 131a3c49ce1SAlbert Lee 132990b4856Slling static zprop_index_t acl_inherit_table[] = { 13391ebeef5Sahrens { "discard", ZFS_ACL_DISCARD }, 13491ebeef5Sahrens { "noallow", ZFS_ACL_NOALLOW }, 135b3d141f8Smarks { "restricted", ZFS_ACL_RESTRICTED }, 13691ebeef5Sahrens { "passthrough", ZFS_ACL_PASSTHROUGH }, 137b3d141f8Smarks { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatability */ 138d0f3f37eSMark Shellenbaum { "passthrough-x", ZFS_ACL_PASSTHROUGH_X }, 13991ebeef5Sahrens { NULL } 14091ebeef5Sahrens }; 14191ebeef5Sahrens 142da6c28aaSamw static zprop_index_t case_table[] = { 143da6c28aaSamw { "sensitive", ZFS_CASE_SENSITIVE }, 144da6c28aaSamw { "insensitive", ZFS_CASE_INSENSITIVE }, 145da6c28aaSamw { "mixed", ZFS_CASE_MIXED }, 146da6c28aaSamw { NULL } 147da6c28aaSamw }; 148da6c28aaSamw 149990b4856Slling static zprop_index_t copies_table[] = { 15091ebeef5Sahrens { "1", 1 }, 15191ebeef5Sahrens { "2", 2 }, 15291ebeef5Sahrens { "3", 3 }, 15391ebeef5Sahrens { NULL } 15491ebeef5Sahrens }; 15591ebeef5Sahrens 156de8267e0Stimh /* 157de8267e0Stimh * Use the unique flags we have to send to u8_strcmp() and/or 158de8267e0Stimh * u8_textprep() to represent the various normalization property 159de8267e0Stimh * values. 160de8267e0Stimh */ 161da6c28aaSamw static zprop_index_t normalize_table[] = { 162de8267e0Stimh { "none", 0 }, 163de8267e0Stimh { "formD", U8_TEXTPREP_NFD }, 164de8267e0Stimh { "formKC", U8_TEXTPREP_NFKC }, 165de8267e0Stimh { "formC", U8_TEXTPREP_NFC }, 166de8267e0Stimh { "formKD", U8_TEXTPREP_NFKD }, 167da6c28aaSamw { NULL } 168da6c28aaSamw }; 169da6c28aaSamw 170990b4856Slling static zprop_index_t version_table[] = { 17191ebeef5Sahrens { "1", 1 }, 17291ebeef5Sahrens { "2", 2 }, 173da6c28aaSamw { "3", 3 }, 17414843421SMatthew Ahrens { "4", 4 }, 1750a586ceaSMark Shellenbaum { "5", 5 }, 17691ebeef5Sahrens { "current", ZPL_VERSION }, 17791ebeef5Sahrens { NULL } 17891ebeef5Sahrens }; 17991ebeef5Sahrens 180990b4856Slling static zprop_index_t boolean_table[] = { 181e45ce728Sahrens { "off", 0 }, 182e45ce728Sahrens { "on", 1 }, 183e45ce728Sahrens { NULL } 184e45ce728Sahrens }; 185e45ce728Sahrens 186e09fa4daSNeil Perrin static zprop_index_t logbias_table[] = { 187e09fa4daSNeil Perrin { "latency", ZFS_LOGBIAS_LATENCY }, 188e09fa4daSNeil Perrin { "throughput", ZFS_LOGBIAS_THROUGHPUT }, 189e09fa4daSNeil Perrin { NULL } 190e09fa4daSNeil Perrin }; 191e09fa4daSNeil Perrin 192a227b7f4Shs24103 static zprop_index_t canmount_table[] = { 193a227b7f4Shs24103 { "off", ZFS_CANMOUNT_OFF }, 194a227b7f4Shs24103 { "on", ZFS_CANMOUNT_ON }, 195a227b7f4Shs24103 { "noauto", ZFS_CANMOUNT_NOAUTO }, 196a227b7f4Shs24103 { NULL } 197a227b7f4Shs24103 }; 198a227b7f4Shs24103 1993baa08fcSek110237 static zprop_index_t cache_table[] = { 2003baa08fcSek110237 { "none", ZFS_CACHE_NONE }, 2013baa08fcSek110237 { "metadata", ZFS_CACHE_METADATA }, 2023baa08fcSek110237 { "all", ZFS_CACHE_ALL }, 2033baa08fcSek110237 { NULL } 2043baa08fcSek110237 }; 2053baa08fcSek110237 20655da60b9SMark J Musante static zprop_index_t sync_table[] = { 20755da60b9SMark J Musante { "standard", ZFS_SYNC_STANDARD }, 20855da60b9SMark J Musante { "always", ZFS_SYNC_ALWAYS }, 20955da60b9SMark J Musante { "disabled", ZFS_SYNC_DISABLED }, 21055da60b9SMark J Musante { NULL } 21155da60b9SMark J Musante }; 21255da60b9SMark J Musante 213edf345e6SMatthew Ahrens static zprop_index_t redundant_metadata_table[] = { 214edf345e6SMatthew Ahrens { "all", ZFS_REDUNDANT_METADATA_ALL }, 215edf345e6SMatthew Ahrens { "most", ZFS_REDUNDANT_METADATA_MOST }, 216edf345e6SMatthew Ahrens { NULL } 217edf345e6SMatthew Ahrens }; 218edf345e6SMatthew Ahrens 21991ebeef5Sahrens /* inherit index properties */ 220edf345e6SMatthew Ahrens zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata", 221edf345e6SMatthew Ahrens ZFS_REDUNDANT_METADATA_ALL, 222edf345e6SMatthew Ahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 223edf345e6SMatthew Ahrens "all | most", "REDUND_MD", 224edf345e6SMatthew Ahrens redundant_metadata_table); 22555da60b9SMark J Musante zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD, 22655da60b9SMark J Musante PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 22755da60b9SMark J Musante "standard | always | disabled", "SYNC", 22855da60b9SMark J Musante sync_table); 22983d7f9feSTom Erickson zprop_register_index(ZFS_PROP_CHECKSUM, "checksum", 23083d7f9feSTom Erickson ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | 23183d7f9feSTom Erickson ZFS_TYPE_VOLUME, 23245818ee1SMatthew Ahrens "on | off | fletcher2 | fletcher4 | sha256 | sha512 | " 23345818ee1SMatthew Ahrens "skein | edonr", "CHECKSUM", checksum_table); 23483d7f9feSTom Erickson zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF, 235b24ab676SJeff Bonwick PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 23645818ee1SMatthew Ahrens "on | off | verify | sha256[,verify], sha512[,verify], " 23745818ee1SMatthew Ahrens "skein[,verify], edonr,verify", "DEDUP", dedup_table); 23883d7f9feSTom Erickson zprop_register_index(ZFS_PROP_COMPRESSION, "compression", 239e45ce728Sahrens ZIO_COMPRESS_DEFAULT, PROP_INHERIT, 240e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 241a6f561b4SSašo Kiselkov "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", 242a6f561b4SSašo Kiselkov "COMPRESS", compress_table); 24383d7f9feSTom Erickson zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, 244e45ce728Sahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 245e45ce728Sahrens "hidden | visible", "SNAPDIR", snapdir_table); 246a3c49ce1SAlbert Lee zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD, 247a3c49ce1SAlbert Lee PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 24871dbfc28SPaul B. Henson "discard | groupmask | passthrough | restricted", "ACLMODE", 24971dbfc28SPaul B. Henson acl_mode_table); 25083d7f9feSTom Erickson zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit", 25183d7f9feSTom Erickson ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 252d0f3f37eSMark Shellenbaum "discard | noallow | restricted | passthrough | passthrough-x", 253b3d141f8Smarks "ACLINHERIT", acl_inherit_table); 25483d7f9feSTom Erickson zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT, 25583d7f9feSTom Erickson ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 25691ebeef5Sahrens "1 | 2 | 3", "COPIES", copies_table); 25783d7f9feSTom Erickson zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", 2583baa08fcSek110237 ZFS_CACHE_ALL, PROP_INHERIT, 2593baa08fcSek110237 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 2603baa08fcSek110237 "all | none | metadata", "PRIMARYCACHE", cache_table); 26183d7f9feSTom Erickson zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", 2623baa08fcSek110237 ZFS_CACHE_ALL, PROP_INHERIT, 2633baa08fcSek110237 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 2643baa08fcSek110237 "all | none | metadata", "SECONDARYCACHE", cache_table); 26583d7f9feSTom Erickson zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY, 266e09fa4daSNeil Perrin PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 267e09fa4daSNeil Perrin "latency | throughput", "LOGBIAS", logbias_table); 268e45ce728Sahrens 269e45ce728Sahrens /* inherit index (boolean) properties */ 27083d7f9feSTom Erickson zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, 271e45ce728Sahrens ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); 27283d7f9feSTom Erickson zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, 273e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", 274e45ce728Sahrens boolean_table); 27583d7f9feSTom Erickson zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, 276e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", 277e45ce728Sahrens boolean_table); 278*1a4cea1bSArne Jansen zprop_register_index(ZFS_PROP_FOLLOW, "follow", 1, PROP_INHERIT, 279*1a4cea1bSArne Jansen ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "FOLLOW", 280*1a4cea1bSArne Jansen boolean_table); 28183d7f9feSTom Erickson zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, 282e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", 283e45ce728Sahrens boolean_table); 28483d7f9feSTom Erickson zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, 285e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", 286e45ce728Sahrens boolean_table); 28783d7f9feSTom Erickson zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT, 288e45ce728Sahrens ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table); 28983d7f9feSTom Erickson zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT, 290e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR", 291e45ce728Sahrens boolean_table); 29283d7f9feSTom Erickson zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, 293da6c28aaSamw ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", 294da6c28aaSamw boolean_table); 29583d7f9feSTom Erickson zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT, 296da6c28aaSamw ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND", 297da6c28aaSamw boolean_table); 298e45ce728Sahrens 299e45ce728Sahrens /* default index properties */ 30083d7f9feSTom Erickson zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, 30191ebeef5Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 30219b94df9SMatthew Ahrens "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table); 30383d7f9feSTom Erickson zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, 304a227b7f4Shs24103 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", 305a227b7f4Shs24103 "CANMOUNT", canmount_table); 306e45ce728Sahrens 307e45ce728Sahrens /* readonly index (boolean) properties */ 30883d7f9feSTom Erickson zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, 309990b4856Slling ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); 31083d7f9feSTom Erickson zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0, 311842727c2SChris Kirby PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY", 312842727c2SChris Kirby boolean_table); 313e45ce728Sahrens 314da6c28aaSamw /* set once index properties */ 31583d7f9feSTom Erickson zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0, 316da6c28aaSamw PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 317da6c28aaSamw "none | formC | formD | formKC | formKD", "NORMALIZATION", 318da6c28aaSamw normalize_table); 31983d7f9feSTom Erickson zprop_register_index(ZFS_PROP_CASE, "casesensitivity", 32083d7f9feSTom Erickson ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM | 32183d7f9feSTom Erickson ZFS_TYPE_SNAPSHOT, 322da6c28aaSamw "sensitive | insensitive | mixed", "CASE", case_table); 323da6c28aaSamw 324da6c28aaSamw /* set once index (boolean) properties */ 32583d7f9feSTom Erickson zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, 326da6c28aaSamw ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 327da6c28aaSamw "on | off", "UTF8ONLY", boolean_table); 328da6c28aaSamw 32991ebeef5Sahrens /* string properties */ 33083d7f9feSTom Erickson zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, 33191ebeef5Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN"); 33219b94df9SMatthew Ahrens zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY, 33319b94df9SMatthew Ahrens ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES"); 33483d7f9feSTom Erickson zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", 33583d7f9feSTom Erickson PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", 33683d7f9feSTom Erickson "MOUNTPOINT"); 33783d7f9feSTom Erickson zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", 33883d7f9feSTom Erickson PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", 33983d7f9feSTom Erickson "SHARENFS"); 34083d7f9feSTom Erickson zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, 34178f17100SMatthew Ahrens ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, 34278f17100SMatthew Ahrens "filesystem | volume | snapshot | bookmark", "TYPE"); 34383d7f9feSTom Erickson zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", 34483d7f9feSTom Erickson PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 34583d7f9feSTom Erickson "on | off | sharemgr(1M) options", "SHARESMB"); 34683d7f9feSTom Erickson zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel", 34783d7f9feSTom Erickson ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET, 34883d7f9feSTom Erickson "<sensitivity label>", "MLSLABEL"); 3499c3fd121SMatthew Ahrens zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN, 3509c3fd121SMatthew Ahrens "receive_resume_token", 3519c3fd121SMatthew Ahrens NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 3529c3fd121SMatthew Ahrens "<string token>", "RESUMETOK"); 35391ebeef5Sahrens 35491ebeef5Sahrens /* readonly number properties */ 35583d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, 356990b4856Slling ZFS_TYPE_DATASET, "<size>", "USED"); 35783d7f9feSTom Erickson zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, 358990b4856Slling ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL"); 35983d7f9feSTom Erickson zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0, 36083d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER"); 36183d7f9feSTom Erickson zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, 362990b4856Slling PROP_READONLY, ZFS_TYPE_DATASET, 36391ebeef5Sahrens "<1.00x or higher if compressed>", "RATIO"); 364187d6ac0SMatt Ahrens zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0, 365187d6ac0SMatt Ahrens PROP_READONLY, ZFS_TYPE_DATASET, 366187d6ac0SMatt Ahrens "<1.00x or higher if compressed>", "REFRATIO"); 36783d7f9feSTom Erickson zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 368c1449561SEric Taylor ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME, 369da6c28aaSamw ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK"); 37083d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, 37183d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 37283d7f9feSTom Erickson "USEDSNAP"); 37383d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, 37483d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 37583d7f9feSTom Erickson "USEDDS"); 37683d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, 37783d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 37883d7f9feSTom Erickson "USEDCHILD"); 37983d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, 38074e7dc98SMatthew Ahrens PROP_READONLY, 38174e7dc98SMatthew Ahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV"); 38283d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY, 383842727c2SChris Kirby ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS"); 38419b94df9SMatthew Ahrens zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY, 38519b94df9SMatthew Ahrens ZFS_TYPE_DATASET, "<size>", "WRITTEN"); 38677372cb0SMatthew Ahrens zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0, 38777372cb0SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LUSED"); 38877372cb0SMatthew Ahrens zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced", 38977372cb0SMatthew Ahrens 0, PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LREFER"); 39091ebeef5Sahrens 39191ebeef5Sahrens /* default number properties */ 39283d7f9feSTom Erickson zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, 39391ebeef5Sahrens ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA"); 39483d7f9feSTom Erickson zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0, 39583d7f9feSTom Erickson PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 39683d7f9feSTom Erickson "<size> | none", "RESERV"); 39783d7f9feSTom Erickson zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, 39891ebeef5Sahrens ZFS_TYPE_VOLUME, "<size>", "VOLSIZE"); 39983d7f9feSTom Erickson zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, 400a9799022Sck153898 ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA"); 40183d7f9feSTom Erickson zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, 402a9799022Sck153898 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 403a9799022Sck153898 "<size> | none", "REFRESERV"); 404a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit", 405a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, 406a2afb611SJerry Jelinek "<count> | none", "FSLIMIT"); 407a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit", 408a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 409a2afb611SJerry Jelinek "<count> | none", "SSLIMIT"); 410a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count", 411a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, 412a2afb611SJerry Jelinek "<count>", "FSCOUNT"); 413a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count", 414a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 415a2afb611SJerry Jelinek "<count>", "SSCOUNT"); 41691ebeef5Sahrens 41791ebeef5Sahrens /* inherit number properties */ 41883d7f9feSTom Erickson zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize", 419b5152584SMatthew Ahrens SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT, 420b5152584SMatthew Ahrens ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE"); 42191ebeef5Sahrens 42291ebeef5Sahrens /* hidden properties */ 42383d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER, 42478f17100SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "CREATETXG"); 42583d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, 426b24ab676SJeff Bonwick PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES"); 42783d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, 42878f17100SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME"); 42983d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", 43083d7f9feSTom Erickson PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); 43183d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu", 432478ed9adSEric Taylor PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, 433478ed9adSEric Taylor "STMF_SBD_LU"); 43483d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, 43578f17100SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "GUID"); 43683d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting", 437b24ab676SJeff Bonwick PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, 438b24ab676SJeff Bonwick "USERACCOUNTING"); 43983d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER, 440b24ab676SJeff Bonwick PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE"); 44183d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER, 4421d713200SEric Schrock PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID"); 443ca48f36fSKeith M Wesolowski zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent", 444ca48f36fSKeith M Wesolowski PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT"); 445b461c746SMatthew Ahrens zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING, 446b461c746SMatthew Ahrens PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP"); 44791ebeef5Sahrens 44891ebeef5Sahrens /* oddball properties */ 44983d7f9feSTom Erickson zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, 45078f17100SMatthew Ahrens NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, 45191ebeef5Sahrens "<date>", "CREATION", B_FALSE, B_TRUE, NULL); 45291ebeef5Sahrens } 45391ebeef5Sahrens 454b1b8ab34Slling boolean_t 455990b4856Slling zfs_prop_delegatable(zfs_prop_t prop) 456b1b8ab34Slling { 457990b4856Slling zprop_desc_t *pd = &zfs_prop_table[prop]; 4584201a95eSRic Aleshire 4594201a95eSRic Aleshire /* The mlslabel property is never delegatable. */ 4604201a95eSRic Aleshire if (prop == ZFS_PROP_MLSLABEL) 4614201a95eSRic Aleshire return (B_FALSE); 4624201a95eSRic Aleshire 463990b4856Slling return (pd->pd_attr != PROP_READONLY); 464b1b8ab34Slling } 465b1b8ab34Slling 466b1b8ab34Slling /* 467b1b8ab34Slling * Given a zfs dataset property name, returns the corresponding property ID. 468fa9e4066Sahrens */ 469fa9e4066Sahrens zfs_prop_t 470fa9e4066Sahrens zfs_name_to_prop(const char *propname) 471fa9e4066Sahrens { 472990b4856Slling return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); 473b1b8ab34Slling } 474fa9e4066Sahrens 475fa9e4066Sahrens /* 476e9dbad6fSeschrock * For user property names, we allow all lowercase alphanumeric characters, plus 477e9dbad6fSeschrock * a few useful punctuation characters. 478e9dbad6fSeschrock */ 479e9dbad6fSeschrock static int 480e9dbad6fSeschrock valid_char(char c) 481e9dbad6fSeschrock { 482e9dbad6fSeschrock return ((c >= 'a' && c <= 'z') || 483e9dbad6fSeschrock (c >= '0' && c <= '9') || 484e9dbad6fSeschrock c == '-' || c == '_' || c == '.' || c == ':'); 485e9dbad6fSeschrock } 486e9dbad6fSeschrock 487e9dbad6fSeschrock /* 488e9dbad6fSeschrock * Returns true if this is a valid user-defined property (one with a ':'). 489e9dbad6fSeschrock */ 490e9dbad6fSeschrock boolean_t 491e9dbad6fSeschrock zfs_prop_user(const char *name) 492e9dbad6fSeschrock { 493e9dbad6fSeschrock int i; 494e9dbad6fSeschrock char c; 495e9dbad6fSeschrock boolean_t foundsep = B_FALSE; 496e9dbad6fSeschrock 497e9dbad6fSeschrock for (i = 0; i < strlen(name); i++) { 498e9dbad6fSeschrock c = name[i]; 499e9dbad6fSeschrock if (!valid_char(c)) 500e9dbad6fSeschrock return (B_FALSE); 501e9dbad6fSeschrock if (c == ':') 502e9dbad6fSeschrock foundsep = B_TRUE; 503e9dbad6fSeschrock } 504e9dbad6fSeschrock 505e9dbad6fSeschrock if (!foundsep) 506e9dbad6fSeschrock return (B_FALSE); 507e9dbad6fSeschrock 508e9dbad6fSeschrock return (B_TRUE); 509e9dbad6fSeschrock } 510e9dbad6fSeschrock 511e9dbad6fSeschrock /* 51214843421SMatthew Ahrens * Returns true if this is a valid userspace-type property (one with a '@'). 51314843421SMatthew Ahrens * Note that after the @, any character is valid (eg, another @, for SID 51414843421SMatthew Ahrens * user@domain). 51514843421SMatthew Ahrens */ 51614843421SMatthew Ahrens boolean_t 51714843421SMatthew Ahrens zfs_prop_userquota(const char *name) 51814843421SMatthew Ahrens { 51914843421SMatthew Ahrens zfs_userquota_prop_t prop; 52014843421SMatthew Ahrens 52114843421SMatthew Ahrens for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) { 52214843421SMatthew Ahrens if (strncmp(name, zfs_userquota_prop_prefixes[prop], 52314843421SMatthew Ahrens strlen(zfs_userquota_prop_prefixes[prop])) == 0) { 52414843421SMatthew Ahrens return (B_TRUE); 52514843421SMatthew Ahrens } 52614843421SMatthew Ahrens } 52714843421SMatthew Ahrens 52814843421SMatthew Ahrens return (B_FALSE); 52914843421SMatthew Ahrens } 53014843421SMatthew Ahrens 53114843421SMatthew Ahrens /* 53219b94df9SMatthew Ahrens * Returns true if this is a valid written@ property. 53319b94df9SMatthew Ahrens * Note that after the @, any character is valid (eg, another @, for 53419b94df9SMatthew Ahrens * written@pool/fs@origin). 53519b94df9SMatthew Ahrens */ 53619b94df9SMatthew Ahrens boolean_t 53719b94df9SMatthew Ahrens zfs_prop_written(const char *name) 53819b94df9SMatthew Ahrens { 53919b94df9SMatthew Ahrens static const char *prefix = "written@"; 54019b94df9SMatthew Ahrens return (strncmp(name, prefix, strlen(prefix)) == 0); 54119b94df9SMatthew Ahrens } 54219b94df9SMatthew Ahrens 54319b94df9SMatthew Ahrens /* 544990b4856Slling * Tables of index types, plus functions to convert between the user view 545990b4856Slling * (strings) and internal representation (uint64_t). 546fa9e4066Sahrens */ 547990b4856Slling int 548990b4856Slling zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) 549fa9e4066Sahrens { 550990b4856Slling return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); 551990b4856Slling } 552990b4856Slling 553990b4856Slling int 554990b4856Slling zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) 555990b4856Slling { 556990b4856Slling return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); 557990b4856Slling } 558990b4856Slling 559b24ab676SJeff Bonwick uint64_t 560b24ab676SJeff Bonwick zfs_prop_random_value(zfs_prop_t prop, uint64_t seed) 561b24ab676SJeff Bonwick { 562b24ab676SJeff Bonwick return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET)); 563b24ab676SJeff Bonwick } 564b24ab676SJeff Bonwick 565990b4856Slling /* 566990b4856Slling * Returns TRUE if the property applies to any of the given dataset types. 567990b4856Slling */ 5684853e976Sgw25295 boolean_t 569990b4856Slling zfs_prop_valid_for_type(int prop, zfs_type_t types) 570990b4856Slling { 571990b4856Slling return (zprop_valid_for_type(prop, types)); 572990b4856Slling } 573990b4856Slling 574990b4856Slling zprop_type_t 575990b4856Slling zfs_prop_get_type(zfs_prop_t prop) 576990b4856Slling { 577990b4856Slling return (zfs_prop_table[prop].pd_proptype); 578990b4856Slling } 579990b4856Slling 580990b4856Slling /* 581990b4856Slling * Returns TRUE if the property is readonly. 582990b4856Slling */ 583990b4856Slling boolean_t 584990b4856Slling zfs_prop_readonly(zfs_prop_t prop) 585990b4856Slling { 586da6c28aaSamw return (zfs_prop_table[prop].pd_attr == PROP_READONLY || 587da6c28aaSamw zfs_prop_table[prop].pd_attr == PROP_ONETIME); 588da6c28aaSamw } 589da6c28aaSamw 590da6c28aaSamw /* 591da6c28aaSamw * Returns TRUE if the property is only allowed to be set once. 592da6c28aaSamw */ 593da6c28aaSamw boolean_t 594da6c28aaSamw zfs_prop_setonce(zfs_prop_t prop) 595da6c28aaSamw { 596da6c28aaSamw return (zfs_prop_table[prop].pd_attr == PROP_ONETIME); 597fa9e4066Sahrens } 598fa9e4066Sahrens 5993d7072f8Seschrock const char * 600990b4856Slling zfs_prop_default_string(zfs_prop_t prop) 6013d7072f8Seschrock { 6023d7072f8Seschrock return (zfs_prop_table[prop].pd_strdefault); 6033d7072f8Seschrock } 6043d7072f8Seschrock 605fa9e4066Sahrens uint64_t 606fa9e4066Sahrens zfs_prop_default_numeric(zfs_prop_t prop) 607fa9e4066Sahrens { 608fa9e4066Sahrens return (zfs_prop_table[prop].pd_numdefault); 609fa9e4066Sahrens } 610fa9e4066Sahrens 611fa9e4066Sahrens /* 612b1b8ab34Slling * Given a dataset property ID, returns the corresponding name. 6133d7072f8Seschrock * Assuming the zfs dataset property ID is valid. 614fa9e4066Sahrens */ 615fa9e4066Sahrens const char * 616fa9e4066Sahrens zfs_prop_to_name(zfs_prop_t prop) 617fa9e4066Sahrens { 618fa9e4066Sahrens return (zfs_prop_table[prop].pd_name); 619fa9e4066Sahrens } 620fa9e4066Sahrens 621fa9e4066Sahrens /* 622fa9e4066Sahrens * Returns TRUE if the property is inheritable. 623fa9e4066Sahrens */ 624990b4856Slling boolean_t 625fa9e4066Sahrens zfs_prop_inheritable(zfs_prop_t prop) 626fa9e4066Sahrens { 627da6c28aaSamw return (zfs_prop_table[prop].pd_attr == PROP_INHERIT || 628da6c28aaSamw zfs_prop_table[prop].pd_attr == PROP_ONETIME); 629e9dbad6fSeschrock } 630e9dbad6fSeschrock 631acd76fe5Seschrock #ifndef _KERNEL 632acd76fe5Seschrock 633fa9e4066Sahrens /* 634fa9e4066Sahrens * Returns a string describing the set of acceptable values for the given 635b1b8ab34Slling * zfs property, or NULL if it cannot be set. 636fa9e4066Sahrens */ 637fa9e4066Sahrens const char * 638fa9e4066Sahrens zfs_prop_values(zfs_prop_t prop) 639fa9e4066Sahrens { 640fa9e4066Sahrens return (zfs_prop_table[prop].pd_values); 641fa9e4066Sahrens } 642fa9e4066Sahrens 643fa9e4066Sahrens /* 644fa9e4066Sahrens * Returns TRUE if this property is a string type. Note that index types 645fa9e4066Sahrens * (compression, checksum) are treated as strings in userland, even though they 646fa9e4066Sahrens * are stored numerically on disk. 647fa9e4066Sahrens */ 648fa9e4066Sahrens int 649fa9e4066Sahrens zfs_prop_is_string(zfs_prop_t prop) 650fa9e4066Sahrens { 65191ebeef5Sahrens return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || 65291ebeef5Sahrens zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); 653fa9e4066Sahrens } 654fa9e4066Sahrens 655fa9e4066Sahrens /* 656fa9e4066Sahrens * Returns the column header for the given property. Used only in 657fa9e4066Sahrens * 'zfs list -o', but centralized here with the other property information. 658fa9e4066Sahrens */ 659fa9e4066Sahrens const char * 660fa9e4066Sahrens zfs_prop_column_name(zfs_prop_t prop) 661fa9e4066Sahrens { 662fa9e4066Sahrens return (zfs_prop_table[prop].pd_colname); 663fa9e4066Sahrens } 664fa9e4066Sahrens 665fa9e4066Sahrens /* 666e9dbad6fSeschrock * Returns whether the given property should be displayed right-justified for 667e9dbad6fSeschrock * 'zfs list'. 668fa9e4066Sahrens */ 669e9dbad6fSeschrock boolean_t 670e9dbad6fSeschrock zfs_prop_align_right(zfs_prop_t prop) 671fa9e4066Sahrens { 672e9dbad6fSeschrock return (zfs_prop_table[prop].pd_rightalign); 673fa9e4066Sahrens } 674da6c28aaSamw 675fa9e4066Sahrens #endif 676