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. 26fa9e4066Sahrens */ 27fa9e4066Sahrens 2855da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */ 2955da60b9SMark J Musante 30fa9e4066Sahrens #include <sys/zio.h> 31fa9e4066Sahrens #include <sys/spa.h> 32de8267e0Stimh #include <sys/u8_textprep.h> 33fa9e4066Sahrens #include <sys/zfs_acl.h> 34fa9e4066Sahrens #include <sys/zfs_ioctl.h> 35e7437265Sahrens #include <sys/zfs_znode.h> 36fa9e4066Sahrens 37fa9e4066Sahrens #include "zfs_prop.h" 38ecd6cf80Smarks #include "zfs_deleg.h" 39fa9e4066Sahrens 40fa9e4066Sahrens #if defined(_KERNEL) 41fa9e4066Sahrens #include <sys/systm.h> 42fa9e4066Sahrens #else 43fa9e4066Sahrens #include <stdlib.h> 44fa9e4066Sahrens #include <string.h> 45fa9e4066Sahrens #include <ctype.h> 46fa9e4066Sahrens #endif 47fa9e4066Sahrens 48990b4856Slling static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; 4991ebeef5Sahrens 5014843421SMatthew Ahrens /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */ 5114843421SMatthew Ahrens const char *zfs_userquota_prop_prefixes[] = { 5214843421SMatthew Ahrens "userused@", 5314843421SMatthew Ahrens "userquota@", 5414843421SMatthew Ahrens "groupused@", 5514843421SMatthew Ahrens "groupquota@" 5614843421SMatthew Ahrens }; 5714843421SMatthew Ahrens 58990b4856Slling zprop_desc_t * 59990b4856Slling zfs_prop_get_table(void) 6091ebeef5Sahrens { 61990b4856Slling return (zfs_prop_table); 6291ebeef5Sahrens } 6391ebeef5Sahrens 6491ebeef5Sahrens void 6591ebeef5Sahrens zfs_prop_init(void) 6691ebeef5Sahrens { 67990b4856Slling static zprop_index_t checksum_table[] = { 6891ebeef5Sahrens { "on", ZIO_CHECKSUM_ON }, 6991ebeef5Sahrens { "off", ZIO_CHECKSUM_OFF }, 7091ebeef5Sahrens { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, 7191ebeef5Sahrens { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, 7291ebeef5Sahrens { "sha256", ZIO_CHECKSUM_SHA256 }, 73810e43b2SBill Pijewski { "noparity", ZIO_CHECKSUM_NOPARITY }, 7445818ee1SMatthew Ahrens { "sha512", ZIO_CHECKSUM_SHA512 }, 7545818ee1SMatthew Ahrens { "skein", ZIO_CHECKSUM_SKEIN }, 7645818ee1SMatthew Ahrens { "edonr", ZIO_CHECKSUM_EDONR }, 7791ebeef5Sahrens { NULL } 7891ebeef5Sahrens }; 7991ebeef5Sahrens 80b24ab676SJeff Bonwick static zprop_index_t dedup_table[] = { 81b24ab676SJeff Bonwick { "on", ZIO_CHECKSUM_ON }, 82b24ab676SJeff Bonwick { "off", ZIO_CHECKSUM_OFF }, 83b24ab676SJeff Bonwick { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY }, 84b24ab676SJeff Bonwick { "sha256", ZIO_CHECKSUM_SHA256 }, 85b24ab676SJeff Bonwick { "sha256,verify", 86b24ab676SJeff Bonwick ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY }, 8745818ee1SMatthew Ahrens { "sha512", ZIO_CHECKSUM_SHA512 }, 8845818ee1SMatthew Ahrens { "sha512,verify", 8945818ee1SMatthew Ahrens ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY }, 9045818ee1SMatthew Ahrens { "skein", ZIO_CHECKSUM_SKEIN }, 9145818ee1SMatthew Ahrens { "skein,verify", 9245818ee1SMatthew Ahrens ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY }, 9345818ee1SMatthew Ahrens { "edonr,verify", 9445818ee1SMatthew Ahrens ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY }, 95b24ab676SJeff Bonwick { NULL } 96b24ab676SJeff Bonwick }; 97b24ab676SJeff Bonwick 98990b4856Slling static zprop_index_t compress_table[] = { 9991ebeef5Sahrens { "on", ZIO_COMPRESS_ON }, 10091ebeef5Sahrens { "off", ZIO_COMPRESS_OFF }, 10191ebeef5Sahrens { "lzjb", ZIO_COMPRESS_LZJB }, 10291ebeef5Sahrens { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ 10391ebeef5Sahrens { "gzip-1", ZIO_COMPRESS_GZIP_1 }, 10491ebeef5Sahrens { "gzip-2", ZIO_COMPRESS_GZIP_2 }, 10591ebeef5Sahrens { "gzip-3", ZIO_COMPRESS_GZIP_3 }, 10691ebeef5Sahrens { "gzip-4", ZIO_COMPRESS_GZIP_4 }, 10791ebeef5Sahrens { "gzip-5", ZIO_COMPRESS_GZIP_5 }, 10891ebeef5Sahrens { "gzip-6", ZIO_COMPRESS_GZIP_6 }, 10991ebeef5Sahrens { "gzip-7", ZIO_COMPRESS_GZIP_7 }, 11091ebeef5Sahrens { "gzip-8", ZIO_COMPRESS_GZIP_8 }, 11191ebeef5Sahrens { "gzip-9", ZIO_COMPRESS_GZIP_9 }, 112b24ab676SJeff Bonwick { "zle", ZIO_COMPRESS_ZLE }, 113a6f561b4SSašo Kiselkov { "lz4", ZIO_COMPRESS_LZ4 }, 11491ebeef5Sahrens { NULL } 11591ebeef5Sahrens }; 11691ebeef5Sahrens 117990b4856Slling static zprop_index_t snapdir_table[] = { 11891ebeef5Sahrens { "hidden", ZFS_SNAPDIR_HIDDEN }, 11991ebeef5Sahrens { "visible", ZFS_SNAPDIR_VISIBLE }, 12091ebeef5Sahrens { NULL } 12191ebeef5Sahrens }; 12291ebeef5Sahrens 123a3c49ce1SAlbert Lee static zprop_index_t acl_mode_table[] = { 124a3c49ce1SAlbert Lee { "discard", ZFS_ACL_DISCARD }, 125a3c49ce1SAlbert Lee { "groupmask", ZFS_ACL_GROUPMASK }, 126a3c49ce1SAlbert Lee { "passthrough", ZFS_ACL_PASSTHROUGH }, 12771dbfc28SPaul B. Henson { "restricted", ZFS_ACL_RESTRICTED }, 128a3c49ce1SAlbert Lee { NULL } 129a3c49ce1SAlbert Lee }; 130a3c49ce1SAlbert Lee 131990b4856Slling static zprop_index_t acl_inherit_table[] = { 13291ebeef5Sahrens { "discard", ZFS_ACL_DISCARD }, 13391ebeef5Sahrens { "noallow", ZFS_ACL_NOALLOW }, 134b3d141f8Smarks { "restricted", ZFS_ACL_RESTRICTED }, 13591ebeef5Sahrens { "passthrough", ZFS_ACL_PASSTHROUGH }, 136b3d141f8Smarks { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatability */ 137d0f3f37eSMark Shellenbaum { "passthrough-x", ZFS_ACL_PASSTHROUGH_X }, 13891ebeef5Sahrens { NULL } 13991ebeef5Sahrens }; 14091ebeef5Sahrens 141da6c28aaSamw static zprop_index_t case_table[] = { 142da6c28aaSamw { "sensitive", ZFS_CASE_SENSITIVE }, 143da6c28aaSamw { "insensitive", ZFS_CASE_INSENSITIVE }, 144da6c28aaSamw { "mixed", ZFS_CASE_MIXED }, 145da6c28aaSamw { NULL } 146da6c28aaSamw }; 147da6c28aaSamw 148990b4856Slling static zprop_index_t copies_table[] = { 14991ebeef5Sahrens { "1", 1 }, 15091ebeef5Sahrens { "2", 2 }, 15191ebeef5Sahrens { "3", 3 }, 15291ebeef5Sahrens { NULL } 15391ebeef5Sahrens }; 15491ebeef5Sahrens 155de8267e0Stimh /* 156de8267e0Stimh * Use the unique flags we have to send to u8_strcmp() and/or 157de8267e0Stimh * u8_textprep() to represent the various normalization property 158de8267e0Stimh * values. 159de8267e0Stimh */ 160da6c28aaSamw static zprop_index_t normalize_table[] = { 161de8267e0Stimh { "none", 0 }, 162de8267e0Stimh { "formD", U8_TEXTPREP_NFD }, 163de8267e0Stimh { "formKC", U8_TEXTPREP_NFKC }, 164de8267e0Stimh { "formC", U8_TEXTPREP_NFC }, 165de8267e0Stimh { "formKD", U8_TEXTPREP_NFKD }, 166da6c28aaSamw { NULL } 167da6c28aaSamw }; 168da6c28aaSamw 169990b4856Slling static zprop_index_t version_table[] = { 17091ebeef5Sahrens { "1", 1 }, 17191ebeef5Sahrens { "2", 2 }, 172da6c28aaSamw { "3", 3 }, 17314843421SMatthew Ahrens { "4", 4 }, 1740a586ceaSMark Shellenbaum { "5", 5 }, 17591ebeef5Sahrens { "current", ZPL_VERSION }, 17691ebeef5Sahrens { NULL } 17791ebeef5Sahrens }; 17891ebeef5Sahrens 179990b4856Slling static zprop_index_t boolean_table[] = { 180e45ce728Sahrens { "off", 0 }, 181e45ce728Sahrens { "on", 1 }, 182e45ce728Sahrens { NULL } 183e45ce728Sahrens }; 184e45ce728Sahrens 185e09fa4daSNeil Perrin static zprop_index_t logbias_table[] = { 186e09fa4daSNeil Perrin { "latency", ZFS_LOGBIAS_LATENCY }, 187e09fa4daSNeil Perrin { "throughput", ZFS_LOGBIAS_THROUGHPUT }, 188e09fa4daSNeil Perrin { NULL } 189e09fa4daSNeil Perrin }; 190e09fa4daSNeil Perrin 191a227b7f4Shs static zprop_index_t canmount_table[] = { 192a227b7f4Shs { "off", ZFS_CANMOUNT_OFF }, 193a227b7f4Shs { "on", ZFS_CANMOUNT_ON }, 194a227b7f4Shs { "noauto", ZFS_CANMOUNT_NOAUTO }, 195a227b7f4Shs { NULL } 196a227b7f4Shs }; 197a227b7f4Shs 1983baa08fcSek static zprop_index_t cache_table[] = { 1993baa08fcSek { "none", ZFS_CACHE_NONE }, 2003baa08fcSek { "metadata", ZFS_CACHE_METADATA }, 2013baa08fcSek { "all", ZFS_CACHE_ALL }, 2023baa08fcSek { NULL } 2033baa08fcSek }; 2043baa08fcSek 20555da60b9SMark J Musante static zprop_index_t sync_table[] = { 20655da60b9SMark J Musante { "standard", ZFS_SYNC_STANDARD }, 20755da60b9SMark J Musante { "always", ZFS_SYNC_ALWAYS }, 20855da60b9SMark J Musante { "disabled", ZFS_SYNC_DISABLED }, 20955da60b9SMark J Musante { NULL } 21055da60b9SMark J Musante }; 21155da60b9SMark J Musante 212edf345e6SMatthew Ahrens static zprop_index_t redundant_metadata_table[] = { 213edf345e6SMatthew Ahrens { "all", ZFS_REDUNDANT_METADATA_ALL }, 214edf345e6SMatthew Ahrens { "most", ZFS_REDUNDANT_METADATA_MOST }, 215edf345e6SMatthew Ahrens { NULL } 216edf345e6SMatthew Ahrens }; 217edf345e6SMatthew Ahrens 21891ebeef5Sahrens /* inherit index properties */ 219edf345e6SMatthew Ahrens zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata", 220edf345e6SMatthew Ahrens ZFS_REDUNDANT_METADATA_ALL, 221edf345e6SMatthew Ahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 222edf345e6SMatthew Ahrens "all | most", "REDUND_MD", 223edf345e6SMatthew Ahrens redundant_metadata_table); 22455da60b9SMark J Musante zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD, 22555da60b9SMark J Musante PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 22655da60b9SMark J Musante "standard | always | disabled", "SYNC", 22755da60b9SMark J Musante sync_table); 22883d7f9feSTom Erickson zprop_register_index(ZFS_PROP_CHECKSUM, "checksum", 22983d7f9feSTom Erickson ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM | 23083d7f9feSTom Erickson ZFS_TYPE_VOLUME, 23145818ee1SMatthew Ahrens "on | off | fletcher2 | fletcher4 | sha256 | sha512 | " 23245818ee1SMatthew Ahrens "skein | edonr", "CHECKSUM", checksum_table); 23383d7f9feSTom Erickson zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF, 234b24ab676SJeff Bonwick PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 23545818ee1SMatthew Ahrens "on | off | verify | sha256[,verify], sha512[,verify], " 23645818ee1SMatthew Ahrens "skein[,verify], edonr,verify", "DEDUP", dedup_table); 23783d7f9feSTom Erickson zprop_register_index(ZFS_PROP_COMPRESSION, "compression", 238e45ce728Sahrens ZIO_COMPRESS_DEFAULT, PROP_INHERIT, 239e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 240a6f561b4SSašo Kiselkov "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", 241a6f561b4SSašo Kiselkov "COMPRESS", compress_table); 24283d7f9feSTom Erickson zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, 243e45ce728Sahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 244e45ce728Sahrens "hidden | visible", "SNAPDIR", snapdir_table); 245a3c49ce1SAlbert Lee zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD, 246a3c49ce1SAlbert Lee PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 24771dbfc28SPaul B. Henson "discard | groupmask | passthrough | restricted", "ACLMODE", 24871dbfc28SPaul B. Henson acl_mode_table); 24983d7f9feSTom Erickson zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit", 25083d7f9feSTom Erickson ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 251d0f3f37eSMark Shellenbaum "discard | noallow | restricted | passthrough | passthrough-x", 252b3d141f8Smarks "ACLINHERIT", acl_inherit_table); 25383d7f9feSTom Erickson zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT, 25483d7f9feSTom Erickson ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 25591ebeef5Sahrens "1 | 2 | 3", "COPIES", copies_table); 25683d7f9feSTom Erickson zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", 2573baa08fcSek ZFS_CACHE_ALL, PROP_INHERIT, 2583baa08fcSek ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 2593baa08fcSek "all | none | metadata", "PRIMARYCACHE", cache_table); 26083d7f9feSTom Erickson zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", 2613baa08fcSek ZFS_CACHE_ALL, PROP_INHERIT, 2623baa08fcSek ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 2633baa08fcSek "all | none | metadata", "SECONDARYCACHE", cache_table); 26483d7f9feSTom Erickson zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY, 265e09fa4daSNeil Perrin PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 266e09fa4daSNeil Perrin "latency | throughput", "LOGBIAS", logbias_table); 267e45ce728Sahrens 268e45ce728Sahrens /* inherit index (boolean) properties */ 26983d7f9feSTom Erickson zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, 270e45ce728Sahrens ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); 27183d7f9feSTom Erickson zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, 272e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", 273e45ce728Sahrens boolean_table); 27483d7f9feSTom Erickson zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, 275e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", 276e45ce728Sahrens boolean_table); 27783d7f9feSTom Erickson zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, 278e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", 279e45ce728Sahrens boolean_table); 28083d7f9feSTom Erickson zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, 281e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", 282e45ce728Sahrens boolean_table); 28383d7f9feSTom Erickson zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT, 284e45ce728Sahrens ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table); 28583d7f9feSTom Erickson zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT, 286e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR", 287e45ce728Sahrens boolean_table); 28883d7f9feSTom Erickson zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, 289da6c28aaSamw ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", 290da6c28aaSamw boolean_table); 29183d7f9feSTom Erickson zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT, 292da6c28aaSamw ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND", 293da6c28aaSamw boolean_table); 294e45ce728Sahrens 295e45ce728Sahrens /* default index properties */ 29683d7f9feSTom Erickson zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, 2977b55fa8eSck ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 29819b94df9SMatthew Ahrens "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table); 29983d7f9feSTom Erickson zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, 300a227b7f4Shs PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", 301a227b7f4Shs "CANMOUNT", canmount_table); 302e45ce728Sahrens 303e45ce728Sahrens /* readonly index (boolean) properties */ 30483d7f9feSTom Erickson zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, 305990b4856Slling ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); 30683d7f9feSTom Erickson zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0, 307842727c2SChris Kirby PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY", 308842727c2SChris Kirby boolean_table); 309e45ce728Sahrens 310da6c28aaSamw /* set once index properties */ 31183d7f9feSTom Erickson zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0, 312da6c28aaSamw PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 313da6c28aaSamw "none | formC | formD | formKC | formKD", "NORMALIZATION", 314da6c28aaSamw normalize_table); 31583d7f9feSTom Erickson zprop_register_index(ZFS_PROP_CASE, "casesensitivity", 31683d7f9feSTom Erickson ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM | 31783d7f9feSTom Erickson ZFS_TYPE_SNAPSHOT, 318da6c28aaSamw "sensitive | insensitive | mixed", "CASE", case_table); 319da6c28aaSamw 320da6c28aaSamw /* set once index (boolean) properties */ 32183d7f9feSTom Erickson zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, 322da6c28aaSamw ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 323da6c28aaSamw "on | off", "UTF8ONLY", boolean_table); 324da6c28aaSamw 32591ebeef5Sahrens /* string properties */ 32683d7f9feSTom Erickson zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, 32791ebeef5Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN"); 32819b94df9SMatthew Ahrens zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY, 32919b94df9SMatthew Ahrens ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES"); 33083d7f9feSTom Erickson zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", 33183d7f9feSTom Erickson PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", 33283d7f9feSTom Erickson "MOUNTPOINT"); 33383d7f9feSTom Erickson zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", 33483d7f9feSTom Erickson PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", 33583d7f9feSTom Erickson "SHARENFS"); 33683d7f9feSTom Erickson zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, 33778f17100SMatthew Ahrens ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, 33878f17100SMatthew Ahrens "filesystem | volume | snapshot | bookmark", "TYPE"); 33983d7f9feSTom Erickson zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", 34083d7f9feSTom Erickson PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 34183d7f9feSTom Erickson "on | off | sharemgr(1M) options", "SHARESMB"); 34283d7f9feSTom Erickson zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel", 34383d7f9feSTom Erickson ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET, 34483d7f9feSTom Erickson "<sensitivity label>", "MLSLABEL"); 345*9c3fd121SMatthew Ahrens zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN, 346*9c3fd121SMatthew Ahrens "receive_resume_token", 347*9c3fd121SMatthew Ahrens NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 348*9c3fd121SMatthew Ahrens "<string token>", "RESUMETOK"); 34991ebeef5Sahrens 35091ebeef5Sahrens /* readonly number properties */ 35183d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, 352990b4856Slling ZFS_TYPE_DATASET, "<size>", "USED"); 35383d7f9feSTom Erickson zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, 354990b4856Slling ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL"); 35583d7f9feSTom Erickson zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0, 35683d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER"); 35783d7f9feSTom Erickson zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, 358990b4856Slling PROP_READONLY, ZFS_TYPE_DATASET, 35991ebeef5Sahrens "<1.00x or higher if compressed>", "RATIO"); 360187d6ac0SMatt Ahrens zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0, 361187d6ac0SMatt Ahrens PROP_READONLY, ZFS_TYPE_DATASET, 362187d6ac0SMatt Ahrens "<1.00x or higher if compressed>", "REFRATIO"); 36383d7f9feSTom Erickson zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 364c1449561SEric Taylor ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME, 365da6c28aaSamw ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK"); 36683d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, 36783d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 36883d7f9feSTom Erickson "USEDSNAP"); 36983d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, 37083d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 37183d7f9feSTom Erickson "USEDDS"); 37283d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, 37383d7f9feSTom Erickson PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", 37483d7f9feSTom Erickson "USEDCHILD"); 37583d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, 37674e7dc98SMatthew Ahrens PROP_READONLY, 37774e7dc98SMatthew Ahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV"); 37883d7f9feSTom Erickson zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY, 379842727c2SChris Kirby ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS"); 38019b94df9SMatthew Ahrens zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY, 38119b94df9SMatthew Ahrens ZFS_TYPE_DATASET, "<size>", "WRITTEN"); 38277372cb0SMatthew Ahrens zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0, 38377372cb0SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LUSED"); 38477372cb0SMatthew Ahrens zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced", 38577372cb0SMatthew Ahrens 0, PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "LREFER"); 38691ebeef5Sahrens 38791ebeef5Sahrens /* default number properties */ 38883d7f9feSTom Erickson zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, 38991ebeef5Sahrens ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA"); 39083d7f9feSTom Erickson zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0, 39183d7f9feSTom Erickson PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 39283d7f9feSTom Erickson "<size> | none", "RESERV"); 39383d7f9feSTom Erickson zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, 39491ebeef5Sahrens ZFS_TYPE_VOLUME, "<size>", "VOLSIZE"); 39583d7f9feSTom Erickson zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, 396a9799022Sck ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA"); 39783d7f9feSTom Erickson zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, 398a9799022Sck PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 399a9799022Sck "<size> | none", "REFRESERV"); 400a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit", 401a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, 402a2afb611SJerry Jelinek "<count> | none", "FSLIMIT"); 403a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit", 404a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 405a2afb611SJerry Jelinek "<count> | none", "SSLIMIT"); 406a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count", 407a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, 408a2afb611SJerry Jelinek "<count>", "FSCOUNT"); 409a2afb611SJerry Jelinek zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count", 410a2afb611SJerry Jelinek UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 411a2afb611SJerry Jelinek "<count>", "SSCOUNT"); 41291ebeef5Sahrens 41391ebeef5Sahrens /* inherit number properties */ 41483d7f9feSTom Erickson zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize", 415b5152584SMatthew Ahrens SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT, 416b5152584SMatthew Ahrens ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE"); 41791ebeef5Sahrens 41891ebeef5Sahrens /* hidden properties */ 41983d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER, 42078f17100SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "CREATETXG"); 42183d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, 422b24ab676SJeff Bonwick PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES"); 42383d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, 42478f17100SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME"); 42583d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", 42683d7f9feSTom Erickson PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); 42783d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu", 428478ed9adSEric Taylor PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, 429478ed9adSEric Taylor "STMF_SBD_LU"); 43083d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, 43178f17100SMatthew Ahrens PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "GUID"); 43283d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting", 433b24ab676SJeff Bonwick PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, 434b24ab676SJeff Bonwick "USERACCOUNTING"); 43583d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER, 436b24ab676SJeff Bonwick PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE"); 43783d7f9feSTom Erickson zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER, 4381d713200SEric Schrock PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID"); 439ca48f36fSKeith M Wesolowski zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent", 440ca48f36fSKeith M Wesolowski PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT"); 441b461c746SMatthew Ahrens zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING, 442b461c746SMatthew Ahrens PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP"); 44391ebeef5Sahrens 44491ebeef5Sahrens /* oddball properties */ 44583d7f9feSTom Erickson zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, 44678f17100SMatthew Ahrens NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, 44791ebeef5Sahrens "<date>", "CREATION", B_FALSE, B_TRUE, NULL); 44891ebeef5Sahrens } 44991ebeef5Sahrens 450b1b8ab34Slling boolean_t 451990b4856Slling zfs_prop_delegatable(zfs_prop_t prop) 452fa9e4066Sahrens { 453990b4856Slling zprop_desc_t *pd = &zfs_prop_table[prop]; 4544201a95eSRic Aleshire 4554201a95eSRic Aleshire /* The mlslabel property is never delegatable. */ 4564201a95eSRic Aleshire if (prop == ZFS_PROP_MLSLABEL) 4574201a95eSRic Aleshire return (B_FALSE); 4584201a95eSRic Aleshire 459990b4856Slling return (pd->pd_attr != PROP_READONLY); 460fa9e4066Sahrens } 461fa9e4066Sahrens 462b1b8ab34Slling /* 463b1b8ab34Slling * Given a zfs dataset property name, returns the corresponding property ID. 464b1b8ab34Slling */ 465b1b8ab34Slling zfs_prop_t 466b1b8ab34Slling zfs_name_to_prop(const char *propname) 467b1b8ab34Slling { 468990b4856Slling return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); 469b1b8ab34Slling } 470b1b8ab34Slling 471e9dbad6fSeschrock /* 472e9dbad6fSeschrock * For user property names, we allow all lowercase alphanumeric characters, plus 473e9dbad6fSeschrock * a few useful punctuation characters. 474e9dbad6fSeschrock */ 475e9dbad6fSeschrock static int 476e9dbad6fSeschrock valid_char(char c) 477e9dbad6fSeschrock { 478e9dbad6fSeschrock return ((c >= 'a' && c <= 'z') || 479e9dbad6fSeschrock (c >= '0' && c <= '9') || 480e9dbad6fSeschrock c == '-' || c == '_' || c == '.' || c == ':'); 481e9dbad6fSeschrock } 482e9dbad6fSeschrock 483e9dbad6fSeschrock /* 484e9dbad6fSeschrock * Returns true if this is a valid user-defined property (one with a ':'). 485e9dbad6fSeschrock */ 486e9dbad6fSeschrock boolean_t 487e9dbad6fSeschrock zfs_prop_user(const char *name) 488e9dbad6fSeschrock { 489e9dbad6fSeschrock int i; 490e9dbad6fSeschrock char c; 491e9dbad6fSeschrock boolean_t foundsep = B_FALSE; 492e9dbad6fSeschrock 493e9dbad6fSeschrock for (i = 0; i < strlen(name); i++) { 494e9dbad6fSeschrock c = name[i]; 495e9dbad6fSeschrock if (!valid_char(c)) 496e9dbad6fSeschrock return (B_FALSE); 497e9dbad6fSeschrock if (c == ':') 498e9dbad6fSeschrock foundsep = B_TRUE; 499e9dbad6fSeschrock } 500e9dbad6fSeschrock 501e9dbad6fSeschrock if (!foundsep) 502e9dbad6fSeschrock return (B_FALSE); 503e9dbad6fSeschrock 504e9dbad6fSeschrock return (B_TRUE); 505e9dbad6fSeschrock } 506e9dbad6fSeschrock 50714843421SMatthew Ahrens /* 50814843421SMatthew Ahrens * Returns true if this is a valid userspace-type property (one with a '@'). 50914843421SMatthew Ahrens * Note that after the @, any character is valid (eg, another @, for SID 51014843421SMatthew Ahrens * user@domain). 51114843421SMatthew Ahrens */ 51214843421SMatthew Ahrens boolean_t 51314843421SMatthew Ahrens zfs_prop_userquota(const char *name) 51414843421SMatthew Ahrens { 51514843421SMatthew Ahrens zfs_userquota_prop_t prop; 51614843421SMatthew Ahrens 51714843421SMatthew Ahrens for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) { 51814843421SMatthew Ahrens if (strncmp(name, zfs_userquota_prop_prefixes[prop], 51914843421SMatthew Ahrens strlen(zfs_userquota_prop_prefixes[prop])) == 0) { 52014843421SMatthew Ahrens return (B_TRUE); 52114843421SMatthew Ahrens } 52214843421SMatthew Ahrens } 52314843421SMatthew Ahrens 52414843421SMatthew Ahrens return (B_FALSE); 52514843421SMatthew Ahrens } 52614843421SMatthew Ahrens 52719b94df9SMatthew Ahrens /* 52819b94df9SMatthew Ahrens * Returns true if this is a valid written@ property. 52919b94df9SMatthew Ahrens * Note that after the @, any character is valid (eg, another @, for 53019b94df9SMatthew Ahrens * written@pool/fs@origin). 53119b94df9SMatthew Ahrens */ 53219b94df9SMatthew Ahrens boolean_t 53319b94df9SMatthew Ahrens zfs_prop_written(const char *name) 53419b94df9SMatthew Ahrens { 53519b94df9SMatthew Ahrens static const char *prefix = "written@"; 53619b94df9SMatthew Ahrens return (strncmp(name, prefix, strlen(prefix)) == 0); 53719b94df9SMatthew Ahrens } 53819b94df9SMatthew Ahrens 539fa9e4066Sahrens /* 540990b4856Slling * Tables of index types, plus functions to convert between the user view 541990b4856Slling * (strings) and internal representation (uint64_t). 542fa9e4066Sahrens */ 543990b4856Slling int 544990b4856Slling zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) 545fa9e4066Sahrens { 546990b4856Slling return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); 547fa9e4066Sahrens } 548fa9e4066Sahrens 549990b4856Slling int 550990b4856Slling zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) 5513d7072f8Seschrock { 552990b4856Slling return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); 5533d7072f8Seschrock } 5543d7072f8Seschrock 555b24ab676SJeff Bonwick uint64_t 556b24ab676SJeff Bonwick zfs_prop_random_value(zfs_prop_t prop, uint64_t seed) 557b24ab676SJeff Bonwick { 558b24ab676SJeff Bonwick return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET)); 559b24ab676SJeff Bonwick } 560b24ab676SJeff Bonwick 561990b4856Slling /* 562990b4856Slling * Returns TRUE if the property applies to any of the given dataset types. 563990b4856Slling */ 5644853e976Sgw boolean_t 565990b4856Slling zfs_prop_valid_for_type(int prop, zfs_type_t types) 566fa9e4066Sahrens { 567990b4856Slling return (zprop_valid_for_type(prop, types)); 568fa9e4066Sahrens } 569fa9e4066Sahrens 570990b4856Slling zprop_type_t 571990b4856Slling zfs_prop_get_type(zfs_prop_t prop) 5723d7072f8Seschrock { 573990b4856Slling return (zfs_prop_table[prop].pd_proptype); 5743d7072f8Seschrock } 5753d7072f8Seschrock 576fa9e4066Sahrens /* 577fa9e4066Sahrens * Returns TRUE if the property is readonly. 578fa9e4066Sahrens */ 579990b4856Slling boolean_t 580fa9e4066Sahrens zfs_prop_readonly(zfs_prop_t prop) 581fa9e4066Sahrens { 582da6c28aaSamw return (zfs_prop_table[prop].pd_attr == PROP_READONLY || 583da6c28aaSamw zfs_prop_table[prop].pd_attr == PROP_ONETIME); 584da6c28aaSamw } 585da6c28aaSamw 586da6c28aaSamw /* 587da6c28aaSamw * Returns TRUE if the property is only allowed to be set once. 588da6c28aaSamw */ 589da6c28aaSamw boolean_t 590da6c28aaSamw zfs_prop_setonce(zfs_prop_t prop) 591da6c28aaSamw { 592da6c28aaSamw return (zfs_prop_table[prop].pd_attr == PROP_ONETIME); 593fa9e4066Sahrens } 594fa9e4066Sahrens 595fa9e4066Sahrens const char * 596990b4856Slling zfs_prop_default_string(zfs_prop_t prop) 597fa9e4066Sahrens { 598990b4856Slling return (zfs_prop_table[prop].pd_strdefault); 599990b4856Slling } 600990b4856Slling 601990b4856Slling uint64_t 602990b4856Slling zfs_prop_default_numeric(zfs_prop_t prop) 603990b4856Slling { 604990b4856Slling return (zfs_prop_table[prop].pd_numdefault); 605fa9e4066Sahrens } 606fa9e4066Sahrens 607b1b8ab34Slling /* 608990b4856Slling * Given a dataset property ID, returns the corresponding name. 609990b4856Slling * Assuming the zfs dataset property ID is valid. 610b1b8ab34Slling */ 611b1b8ab34Slling const char * 612990b4856Slling zfs_prop_to_name(zfs_prop_t prop) 613b1b8ab34Slling { 614b1b8ab34Slling return (zfs_prop_table[prop].pd_name); 615b1b8ab34Slling } 616b1b8ab34Slling 617fa9e4066Sahrens /* 618fa9e4066Sahrens * Returns TRUE if the property is inheritable. 619fa9e4066Sahrens */ 620990b4856Slling boolean_t 621fa9e4066Sahrens zfs_prop_inheritable(zfs_prop_t prop) 622fa9e4066Sahrens { 623da6c28aaSamw return (zfs_prop_table[prop].pd_attr == PROP_INHERIT || 624da6c28aaSamw zfs_prop_table[prop].pd_attr == PROP_ONETIME); 625e9dbad6fSeschrock } 626e9dbad6fSeschrock 627acd76fe5Seschrock #ifndef _KERNEL 628acd76fe5Seschrock 629fa9e4066Sahrens /* 630b1b8ab34Slling * Returns a string describing the set of acceptable values for the given 631b1b8ab34Slling * zfs property, or NULL if it cannot be set. 632fa9e4066Sahrens */ 633b1b8ab34Slling const char * 634b1b8ab34Slling zfs_prop_values(zfs_prop_t prop) 635fa9e4066Sahrens { 636fa9e4066Sahrens return (zfs_prop_table[prop].pd_values); 637fa9e4066Sahrens } 638fa9e4066Sahrens 639fa9e4066Sahrens /* 640fa9e4066Sahrens * Returns TRUE if this property is a string type. Note that index types 641fa9e4066Sahrens * (compression, checksum) are treated as strings in userland, even though they 642fa9e4066Sahrens * are stored numerically on disk. 643fa9e4066Sahrens */ 644fa9e4066Sahrens int 645fa9e4066Sahrens zfs_prop_is_string(zfs_prop_t prop) 646fa9e4066Sahrens { 64791ebeef5Sahrens return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || 64891ebeef5Sahrens zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); 649fa9e4066Sahrens } 650fa9e4066Sahrens 651fa9e4066Sahrens /* 652fa9e4066Sahrens * Returns the column header for the given property. Used only in 653fa9e4066Sahrens * 'zfs list -o', but centralized here with the other property information. 654fa9e4066Sahrens */ 655fa9e4066Sahrens const char * 656fa9e4066Sahrens zfs_prop_column_name(zfs_prop_t prop) 657fa9e4066Sahrens { 658fa9e4066Sahrens return (zfs_prop_table[prop].pd_colname); 659fa9e4066Sahrens } 660fa9e4066Sahrens 661fa9e4066Sahrens /* 662e9dbad6fSeschrock * Returns whether the given property should be displayed right-justified for 663e9dbad6fSeschrock * 'zfs list'. 664fa9e4066Sahrens */ 665e9dbad6fSeschrock boolean_t 666e9dbad6fSeschrock zfs_prop_align_right(zfs_prop_t prop) 667fa9e4066Sahrens { 668e9dbad6fSeschrock return (zfs_prop_table[prop].pd_rightalign); 669fa9e4066Sahrens } 670da6c28aaSamw 671fa9e4066Sahrens #endif 672