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 /* 2239c23413Seschrock * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23fa9e4066Sahrens * Use is subject to license terms. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 27fa9e4066Sahrens 28fa9e4066Sahrens #include <sys/zio.h> 29fa9e4066Sahrens #include <sys/spa.h> 30fa9e4066Sahrens #include <sys/zfs_acl.h> 31fa9e4066Sahrens #include <sys/zfs_ioctl.h> 32e7437265Sahrens #include <sys/zfs_znode.h> 33fa9e4066Sahrens 34fa9e4066Sahrens #include "zfs_prop.h" 35ecd6cf80Smarks #include "zfs_deleg.h" 36fa9e4066Sahrens 37fa9e4066Sahrens #if defined(_KERNEL) 38fa9e4066Sahrens #include <sys/systm.h> 39fa9e4066Sahrens #else 40fa9e4066Sahrens #include <stdlib.h> 41fa9e4066Sahrens #include <string.h> 42fa9e4066Sahrens #include <ctype.h> 43fa9e4066Sahrens #endif 44fa9e4066Sahrens 45*990b4856Slling static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; 46fa9e4066Sahrens 47*990b4856Slling zprop_desc_t * 48*990b4856Slling zfs_prop_get_table(void) 4991ebeef5Sahrens { 50*990b4856Slling return (zfs_prop_table); 5191ebeef5Sahrens } 5291ebeef5Sahrens 5391ebeef5Sahrens void 5491ebeef5Sahrens zfs_prop_init(void) 5591ebeef5Sahrens { 56*990b4856Slling static zprop_index_t checksum_table[] = { 5791ebeef5Sahrens { "on", ZIO_CHECKSUM_ON }, 5891ebeef5Sahrens { "off", ZIO_CHECKSUM_OFF }, 5991ebeef5Sahrens { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, 6091ebeef5Sahrens { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, 6191ebeef5Sahrens { "sha256", ZIO_CHECKSUM_SHA256 }, 6291ebeef5Sahrens { NULL } 63fa9e4066Sahrens }; 64fa9e4066Sahrens 65*990b4856Slling static zprop_index_t compress_table[] = { 6691ebeef5Sahrens { "on", ZIO_COMPRESS_ON }, 6791ebeef5Sahrens { "off", ZIO_COMPRESS_OFF }, 6891ebeef5Sahrens { "lzjb", ZIO_COMPRESS_LZJB }, 6991ebeef5Sahrens { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ 7091ebeef5Sahrens { "gzip-1", ZIO_COMPRESS_GZIP_1 }, 7191ebeef5Sahrens { "gzip-2", ZIO_COMPRESS_GZIP_2 }, 7291ebeef5Sahrens { "gzip-3", ZIO_COMPRESS_GZIP_3 }, 7391ebeef5Sahrens { "gzip-4", ZIO_COMPRESS_GZIP_4 }, 7491ebeef5Sahrens { "gzip-5", ZIO_COMPRESS_GZIP_5 }, 7591ebeef5Sahrens { "gzip-6", ZIO_COMPRESS_GZIP_6 }, 7691ebeef5Sahrens { "gzip-7", ZIO_COMPRESS_GZIP_7 }, 7791ebeef5Sahrens { "gzip-8", ZIO_COMPRESS_GZIP_8 }, 7891ebeef5Sahrens { "gzip-9", ZIO_COMPRESS_GZIP_9 }, 7991ebeef5Sahrens { NULL } 8091ebeef5Sahrens }; 8191ebeef5Sahrens 82*990b4856Slling static zprop_index_t snapdir_table[] = { 8391ebeef5Sahrens { "hidden", ZFS_SNAPDIR_HIDDEN }, 8491ebeef5Sahrens { "visible", ZFS_SNAPDIR_VISIBLE }, 8591ebeef5Sahrens { NULL } 8691ebeef5Sahrens }; 8791ebeef5Sahrens 88*990b4856Slling static zprop_index_t acl_mode_table[] = { 8991ebeef5Sahrens { "discard", ZFS_ACL_DISCARD }, 9091ebeef5Sahrens { "groupmask", ZFS_ACL_GROUPMASK }, 9191ebeef5Sahrens { "passthrough", ZFS_ACL_PASSTHROUGH }, 9291ebeef5Sahrens { NULL } 9391ebeef5Sahrens }; 9491ebeef5Sahrens 95*990b4856Slling static zprop_index_t acl_inherit_table[] = { 9691ebeef5Sahrens { "discard", ZFS_ACL_DISCARD }, 9791ebeef5Sahrens { "noallow", ZFS_ACL_NOALLOW }, 9891ebeef5Sahrens { "secure", ZFS_ACL_SECURE }, 9991ebeef5Sahrens { "passthrough", ZFS_ACL_PASSTHROUGH }, 10091ebeef5Sahrens { NULL } 10191ebeef5Sahrens }; 10291ebeef5Sahrens 103*990b4856Slling static zprop_index_t copies_table[] = { 10491ebeef5Sahrens { "1", 1 }, 10591ebeef5Sahrens { "2", 2 }, 10691ebeef5Sahrens { "3", 3 }, 10791ebeef5Sahrens { NULL } 10891ebeef5Sahrens }; 10991ebeef5Sahrens 110*990b4856Slling static zprop_index_t version_table[] = { 11191ebeef5Sahrens { "1", 1 }, 11291ebeef5Sahrens { "2", 2 }, 11391ebeef5Sahrens { "current", ZPL_VERSION }, 11491ebeef5Sahrens { NULL } 11591ebeef5Sahrens }; 11691ebeef5Sahrens 117*990b4856Slling static zprop_index_t boolean_table[] = { 118e45ce728Sahrens { "off", 0 }, 119e45ce728Sahrens { "on", 1 }, 120e45ce728Sahrens { NULL } 121e45ce728Sahrens }; 122e45ce728Sahrens 12391ebeef5Sahrens /* inherit index properties */ 12491ebeef5Sahrens register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT, 125e45ce728Sahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 12691ebeef5Sahrens "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM", 12791ebeef5Sahrens checksum_table); 12891ebeef5Sahrens register_index(ZFS_PROP_COMPRESSION, "compression", 129e45ce728Sahrens ZIO_COMPRESS_DEFAULT, PROP_INHERIT, 130e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 13191ebeef5Sahrens "on | off | lzjb | gzip | gzip-[1-9]", "COMPRESS", compress_table); 13291ebeef5Sahrens register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, 133e45ce728Sahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 134e45ce728Sahrens "hidden | visible", "SNAPDIR", snapdir_table); 13591ebeef5Sahrens register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_GROUPMASK, 136e45ce728Sahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 137*990b4856Slling "discard | groupmask | passthrough", "ACLMODE", acl_mode_table); 13891ebeef5Sahrens register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_SECURE, 139e45ce728Sahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 14091ebeef5Sahrens "discard | noallow | secure | passthrough", "ACLINHERIT", 14191ebeef5Sahrens acl_inherit_table); 14291ebeef5Sahrens register_index(ZFS_PROP_COPIES, "copies", 1, 143e45ce728Sahrens PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 14491ebeef5Sahrens "1 | 2 | 3", "COPIES", copies_table); 145e45ce728Sahrens 146e45ce728Sahrens /* inherit index (boolean) properties */ 147e45ce728Sahrens register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, 148e45ce728Sahrens ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); 149e45ce728Sahrens register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, 150e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", 151e45ce728Sahrens boolean_table); 152e45ce728Sahrens register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, 153e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", 154e45ce728Sahrens boolean_table); 155e45ce728Sahrens register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, 156e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", 157e45ce728Sahrens boolean_table); 158e45ce728Sahrens register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, 159e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", 160e45ce728Sahrens boolean_table); 161e45ce728Sahrens register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT, 162e45ce728Sahrens ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table); 163e45ce728Sahrens register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT, 164e45ce728Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR", 165e45ce728Sahrens boolean_table); 166e45ce728Sahrens 167e45ce728Sahrens /* default index properties */ 168e45ce728Sahrens register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, 16991ebeef5Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 17091ebeef5Sahrens "1 | 2 | current", "VERSION", version_table); 17191ebeef5Sahrens 172e45ce728Sahrens /* default index (boolean) properties */ 173e45ce728Sahrens register_index(ZFS_PROP_CANMOUNT, "canmount", 1, PROP_DEFAULT, 174e45ce728Sahrens ZFS_TYPE_FILESYSTEM, "on | off", "CANMOUNT", boolean_table); 175e45ce728Sahrens 176e45ce728Sahrens /* readonly index (boolean) properties */ 177e45ce728Sahrens register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, 178*990b4856Slling ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); 179e45ce728Sahrens 18091ebeef5Sahrens /* string properties */ 18191ebeef5Sahrens register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, 18291ebeef5Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN"); 18391ebeef5Sahrens register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT, 18491ebeef5Sahrens ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", "MOUNTPOINT"); 18591ebeef5Sahrens register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT, 18691ebeef5Sahrens ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", "SHARENFS"); 18791ebeef5Sahrens register_string(ZFS_PROP_SHAREISCSI, "shareiscsi", "off", PROP_INHERIT, 188*990b4856Slling ZFS_TYPE_DATASET, "on | off | type=<type>", "SHAREISCSI"); 18991ebeef5Sahrens register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, 190*990b4856Slling ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE"); 19191ebeef5Sahrens 19291ebeef5Sahrens /* readonly number properties */ 19391ebeef5Sahrens register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, 194*990b4856Slling ZFS_TYPE_DATASET, "<size>", "USED"); 19591ebeef5Sahrens register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, 196*990b4856Slling ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL"); 19791ebeef5Sahrens register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY, 198*990b4856Slling ZFS_TYPE_DATASET, "<size>", "REFER"); 19991ebeef5Sahrens register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, 200*990b4856Slling PROP_READONLY, ZFS_TYPE_DATASET, 20191ebeef5Sahrens "<1.00x or higher if compressed>", "RATIO"); 20291ebeef5Sahrens register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 8192, 203*990b4856Slling PROP_READONLY, ZFS_TYPE_VOLUME, 204*990b4856Slling "512 to 128k, power of 2", "VOLBLOCK"); 20591ebeef5Sahrens 20691ebeef5Sahrens /* default number properties */ 20791ebeef5Sahrens register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, 20891ebeef5Sahrens ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA"); 20991ebeef5Sahrens register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT, 21091ebeef5Sahrens ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size> | none", "RESERV"); 21191ebeef5Sahrens register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, 21291ebeef5Sahrens ZFS_TYPE_VOLUME, "<size>", "VOLSIZE"); 21391ebeef5Sahrens 21491ebeef5Sahrens /* inherit number properties */ 21591ebeef5Sahrens register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_MAXBLOCKSIZE, 21691ebeef5Sahrens PROP_INHERIT, 21791ebeef5Sahrens ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE"); 21891ebeef5Sahrens 21991ebeef5Sahrens /* hidden properties */ 22091ebeef5Sahrens register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER, 221*990b4856Slling PROP_READONLY, ZFS_TYPE_DATASET, NULL); 22291ebeef5Sahrens register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, 22391ebeef5Sahrens PROP_READONLY, ZFS_TYPE_SNAPSHOT, NULL); 22491ebeef5Sahrens register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, 225*990b4856Slling PROP_READONLY, ZFS_TYPE_DATASET, "NAME"); 22691ebeef5Sahrens register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING, 22791ebeef5Sahrens PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); 22891ebeef5Sahrens 22991ebeef5Sahrens /* oddball properties */ 23091ebeef5Sahrens register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL, 231*990b4856Slling PROP_READONLY, ZFS_TYPE_DATASET, 23291ebeef5Sahrens "<date>", "CREATION", B_FALSE, B_TRUE, NULL); 23391ebeef5Sahrens } 23491ebeef5Sahrens 235b1b8ab34Slling boolean_t 236*990b4856Slling zfs_prop_delegatable(zfs_prop_t prop) 237b1b8ab34Slling { 238*990b4856Slling zprop_desc_t *pd = &zfs_prop_table[prop]; 239*990b4856Slling return (pd->pd_attr != PROP_READONLY); 240b1b8ab34Slling } 241b1b8ab34Slling 242b1b8ab34Slling /* 243b1b8ab34Slling * Given a zfs dataset property name, returns the corresponding property ID. 244fa9e4066Sahrens */ 245fa9e4066Sahrens zfs_prop_t 246fa9e4066Sahrens zfs_name_to_prop(const char *propname) 247fa9e4066Sahrens { 248*990b4856Slling return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); 249b1b8ab34Slling } 250fa9e4066Sahrens 251ecd6cf80Smarks 252fa9e4066Sahrens /* 253e9dbad6fSeschrock * For user property names, we allow all lowercase alphanumeric characters, plus 254e9dbad6fSeschrock * a few useful punctuation characters. 255e9dbad6fSeschrock */ 256e9dbad6fSeschrock static int 257e9dbad6fSeschrock valid_char(char c) 258e9dbad6fSeschrock { 259e9dbad6fSeschrock return ((c >= 'a' && c <= 'z') || 260e9dbad6fSeschrock (c >= '0' && c <= '9') || 261e9dbad6fSeschrock c == '-' || c == '_' || c == '.' || c == ':'); 262e9dbad6fSeschrock } 263e9dbad6fSeschrock 264e9dbad6fSeschrock /* 265e9dbad6fSeschrock * Returns true if this is a valid user-defined property (one with a ':'). 266e9dbad6fSeschrock */ 267e9dbad6fSeschrock boolean_t 268e9dbad6fSeschrock zfs_prop_user(const char *name) 269e9dbad6fSeschrock { 270e9dbad6fSeschrock int i; 271e9dbad6fSeschrock char c; 272e9dbad6fSeschrock boolean_t foundsep = B_FALSE; 273e9dbad6fSeschrock 274e9dbad6fSeschrock for (i = 0; i < strlen(name); i++) { 275e9dbad6fSeschrock c = name[i]; 276e9dbad6fSeschrock if (!valid_char(c)) 277e9dbad6fSeschrock return (B_FALSE); 278e9dbad6fSeschrock if (c == ':') 279e9dbad6fSeschrock foundsep = B_TRUE; 280e9dbad6fSeschrock } 281e9dbad6fSeschrock 282e9dbad6fSeschrock if (!foundsep) 283e9dbad6fSeschrock return (B_FALSE); 284e9dbad6fSeschrock 285e9dbad6fSeschrock return (B_TRUE); 286e9dbad6fSeschrock } 287e9dbad6fSeschrock 288e9dbad6fSeschrock /* 289*990b4856Slling * Tables of index types, plus functions to convert between the user view 290*990b4856Slling * (strings) and internal representation (uint64_t). 291fa9e4066Sahrens */ 292*990b4856Slling int 293*990b4856Slling zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) 294fa9e4066Sahrens { 295*990b4856Slling return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); 296*990b4856Slling } 297*990b4856Slling 298*990b4856Slling int 299*990b4856Slling zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) 300*990b4856Slling { 301*990b4856Slling return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); 302*990b4856Slling } 303*990b4856Slling 304*990b4856Slling /* 305*990b4856Slling * Returns TRUE if the property applies to any of the given dataset types. 306*990b4856Slling */ 307*990b4856Slling int 308*990b4856Slling zfs_prop_valid_for_type(int prop, zfs_type_t types) 309*990b4856Slling { 310*990b4856Slling return (zprop_valid_for_type(prop, types)); 311*990b4856Slling } 312*990b4856Slling 313*990b4856Slling zprop_type_t 314*990b4856Slling zfs_prop_get_type(zfs_prop_t prop) 315*990b4856Slling { 316*990b4856Slling return (zfs_prop_table[prop].pd_proptype); 317*990b4856Slling } 318*990b4856Slling 319*990b4856Slling /* 320*990b4856Slling * Returns TRUE if the property is readonly. 321*990b4856Slling */ 322*990b4856Slling boolean_t 323*990b4856Slling zfs_prop_readonly(zfs_prop_t prop) 324*990b4856Slling { 325*990b4856Slling return (zfs_prop_table[prop].pd_attr == PROP_READONLY); 326fa9e4066Sahrens } 327fa9e4066Sahrens 3283d7072f8Seschrock const char * 329*990b4856Slling zfs_prop_default_string(zfs_prop_t prop) 3303d7072f8Seschrock { 3313d7072f8Seschrock return (zfs_prop_table[prop].pd_strdefault); 3323d7072f8Seschrock } 3333d7072f8Seschrock 334fa9e4066Sahrens uint64_t 335fa9e4066Sahrens zfs_prop_default_numeric(zfs_prop_t prop) 336fa9e4066Sahrens { 337fa9e4066Sahrens return (zfs_prop_table[prop].pd_numdefault); 338fa9e4066Sahrens } 339fa9e4066Sahrens 340fa9e4066Sahrens /* 341b1b8ab34Slling * Given a dataset property ID, returns the corresponding name. 3423d7072f8Seschrock * Assuming the zfs dataset property ID is valid. 343fa9e4066Sahrens */ 344fa9e4066Sahrens const char * 345fa9e4066Sahrens zfs_prop_to_name(zfs_prop_t prop) 346fa9e4066Sahrens { 347fa9e4066Sahrens return (zfs_prop_table[prop].pd_name); 348fa9e4066Sahrens } 349fa9e4066Sahrens 350fa9e4066Sahrens /* 351fa9e4066Sahrens * Returns TRUE if the property is inheritable. 352fa9e4066Sahrens */ 353*990b4856Slling boolean_t 354fa9e4066Sahrens zfs_prop_inheritable(zfs_prop_t prop) 355fa9e4066Sahrens { 35691ebeef5Sahrens return (zfs_prop_table[prop].pd_attr == PROP_INHERIT); 357e9dbad6fSeschrock } 358e9dbad6fSeschrock 359acd76fe5Seschrock #ifndef _KERNEL 360acd76fe5Seschrock 361fa9e4066Sahrens /* 362fa9e4066Sahrens * Returns a string describing the set of acceptable values for the given 363b1b8ab34Slling * zfs property, or NULL if it cannot be set. 364fa9e4066Sahrens */ 365fa9e4066Sahrens const char * 366fa9e4066Sahrens zfs_prop_values(zfs_prop_t prop) 367fa9e4066Sahrens { 368fa9e4066Sahrens return (zfs_prop_table[prop].pd_values); 369fa9e4066Sahrens } 370fa9e4066Sahrens 371fa9e4066Sahrens /* 372fa9e4066Sahrens * Returns TRUE if this property is a string type. Note that index types 373fa9e4066Sahrens * (compression, checksum) are treated as strings in userland, even though they 374fa9e4066Sahrens * are stored numerically on disk. 375fa9e4066Sahrens */ 376fa9e4066Sahrens int 377fa9e4066Sahrens zfs_prop_is_string(zfs_prop_t prop) 378fa9e4066Sahrens { 37991ebeef5Sahrens return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || 38091ebeef5Sahrens zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); 381fa9e4066Sahrens } 382fa9e4066Sahrens 383fa9e4066Sahrens /* 384fa9e4066Sahrens * Returns the column header for the given property. Used only in 385fa9e4066Sahrens * 'zfs list -o', but centralized here with the other property information. 386fa9e4066Sahrens */ 387fa9e4066Sahrens const char * 388fa9e4066Sahrens zfs_prop_column_name(zfs_prop_t prop) 389fa9e4066Sahrens { 390fa9e4066Sahrens return (zfs_prop_table[prop].pd_colname); 391fa9e4066Sahrens } 392fa9e4066Sahrens 393fa9e4066Sahrens /* 394e9dbad6fSeschrock * Returns whether the given property should be displayed right-justified for 395e9dbad6fSeschrock * 'zfs list'. 396fa9e4066Sahrens */ 397e9dbad6fSeschrock boolean_t 398e9dbad6fSeschrock zfs_prop_align_right(zfs_prop_t prop) 399fa9e4066Sahrens { 400e9dbad6fSeschrock return (zfs_prop_table[prop].pd_rightalign); 401fa9e4066Sahrens } 402fa9e4066Sahrens #endif 403