1*eda14cbcSMatt Macy /* 2*eda14cbcSMatt Macy * CDDL HEADER START 3*eda14cbcSMatt Macy * 4*eda14cbcSMatt Macy * The contents of this file are subject to the terms of the 5*eda14cbcSMatt Macy * Common Development and Distribution License (the "License"). 6*eda14cbcSMatt Macy * You may not use this file except in compliance with the License. 7*eda14cbcSMatt Macy * 8*eda14cbcSMatt Macy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*eda14cbcSMatt Macy * or http://www.opensolaris.org/os/licensing. 10*eda14cbcSMatt Macy * See the License for the specific language governing permissions 11*eda14cbcSMatt Macy * and limitations under the License. 12*eda14cbcSMatt Macy * 13*eda14cbcSMatt Macy * When distributing Covered Code, include this CDDL HEADER in each 14*eda14cbcSMatt Macy * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*eda14cbcSMatt Macy * If applicable, add the following below this CDDL HEADER, with the 16*eda14cbcSMatt Macy * fields enclosed by brackets "[]" replaced with your own identifying 17*eda14cbcSMatt Macy * information: Portions Copyright [yyyy] [name of copyright owner] 18*eda14cbcSMatt Macy * 19*eda14cbcSMatt Macy * CDDL HEADER END 20*eda14cbcSMatt Macy */ 21*eda14cbcSMatt Macy /* 22*eda14cbcSMatt Macy * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23*eda14cbcSMatt Macy * Use is subject to license terms. 24*eda14cbcSMatt Macy */ 25*eda14cbcSMatt Macy 26*eda14cbcSMatt Macy #ifndef _ZFS_PROP_H 27*eda14cbcSMatt Macy #define _ZFS_PROP_H 28*eda14cbcSMatt Macy 29*eda14cbcSMatt Macy #include <sys/fs/zfs.h> 30*eda14cbcSMatt Macy #include <sys/types.h> 31*eda14cbcSMatt Macy 32*eda14cbcSMatt Macy #ifdef __cplusplus 33*eda14cbcSMatt Macy extern "C" { 34*eda14cbcSMatt Macy #endif 35*eda14cbcSMatt Macy 36*eda14cbcSMatt Macy /* 37*eda14cbcSMatt Macy * For index types (e.g. compression and checksum), we want the numeric value 38*eda14cbcSMatt Macy * in the kernel, but the string value in userland. 39*eda14cbcSMatt Macy */ 40*eda14cbcSMatt Macy typedef enum { 41*eda14cbcSMatt Macy PROP_TYPE_NUMBER, /* numeric value */ 42*eda14cbcSMatt Macy PROP_TYPE_STRING, /* string value */ 43*eda14cbcSMatt Macy PROP_TYPE_INDEX /* numeric value indexed by string */ 44*eda14cbcSMatt Macy } zprop_type_t; 45*eda14cbcSMatt Macy 46*eda14cbcSMatt Macy typedef enum { 47*eda14cbcSMatt Macy PROP_DEFAULT, 48*eda14cbcSMatt Macy PROP_READONLY, 49*eda14cbcSMatt Macy PROP_INHERIT, 50*eda14cbcSMatt Macy /* 51*eda14cbcSMatt Macy * ONETIME properties are a sort of conglomeration of READONLY 52*eda14cbcSMatt Macy * and INHERIT. They can be set only during object creation, 53*eda14cbcSMatt Macy * after that they are READONLY. If not explicitly set during 54*eda14cbcSMatt Macy * creation, they can be inherited. ONETIME_DEFAULT properties 55*eda14cbcSMatt Macy * work the same way, but they will default instead of 56*eda14cbcSMatt Macy * inheriting a value. 57*eda14cbcSMatt Macy */ 58*eda14cbcSMatt Macy PROP_ONETIME, 59*eda14cbcSMatt Macy PROP_ONETIME_DEFAULT 60*eda14cbcSMatt Macy } zprop_attr_t; 61*eda14cbcSMatt Macy 62*eda14cbcSMatt Macy typedef struct zfs_index { 63*eda14cbcSMatt Macy const char *pi_name; 64*eda14cbcSMatt Macy uint64_t pi_value; 65*eda14cbcSMatt Macy } zprop_index_t; 66*eda14cbcSMatt Macy 67*eda14cbcSMatt Macy typedef struct { 68*eda14cbcSMatt Macy const char *pd_name; /* human-readable property name */ 69*eda14cbcSMatt Macy int pd_propnum; /* property number */ 70*eda14cbcSMatt Macy zprop_type_t pd_proptype; /* string, boolean, index, number */ 71*eda14cbcSMatt Macy const char *pd_strdefault; /* default for strings */ 72*eda14cbcSMatt Macy uint64_t pd_numdefault; /* for boolean / index / number */ 73*eda14cbcSMatt Macy zprop_attr_t pd_attr; /* default, readonly, inherit */ 74*eda14cbcSMatt Macy int pd_types; /* bitfield of valid dataset types */ 75*eda14cbcSMatt Macy /* fs | vol | snap; or pool */ 76*eda14cbcSMatt Macy const char *pd_values; /* string telling acceptable values */ 77*eda14cbcSMatt Macy const char *pd_colname; /* column header for "zfs list" */ 78*eda14cbcSMatt Macy boolean_t pd_rightalign; /* column alignment for "zfs list" */ 79*eda14cbcSMatt Macy boolean_t pd_visible; /* do we list this property with the */ 80*eda14cbcSMatt Macy /* "zfs get" help message */ 81*eda14cbcSMatt Macy boolean_t pd_zfs_mod_supported; /* supported by running zfs module */ 82*eda14cbcSMatt Macy const zprop_index_t *pd_table; /* for index properties, a table */ 83*eda14cbcSMatt Macy /* defining the possible values */ 84*eda14cbcSMatt Macy size_t pd_table_size; /* number of entries in pd_table[] */ 85*eda14cbcSMatt Macy } zprop_desc_t; 86*eda14cbcSMatt Macy 87*eda14cbcSMatt Macy /* 88*eda14cbcSMatt Macy * zfs dataset property functions 89*eda14cbcSMatt Macy */ 90*eda14cbcSMatt Macy void zfs_prop_init(void); 91*eda14cbcSMatt Macy zprop_type_t zfs_prop_get_type(zfs_prop_t); 92*eda14cbcSMatt Macy boolean_t zfs_prop_delegatable(zfs_prop_t prop); 93*eda14cbcSMatt Macy zprop_desc_t *zfs_prop_get_table(void); 94*eda14cbcSMatt Macy 95*eda14cbcSMatt Macy /* 96*eda14cbcSMatt Macy * zpool property functions 97*eda14cbcSMatt Macy */ 98*eda14cbcSMatt Macy void zpool_prop_init(void); 99*eda14cbcSMatt Macy zprop_type_t zpool_prop_get_type(zpool_prop_t); 100*eda14cbcSMatt Macy zprop_desc_t *zpool_prop_get_table(void); 101*eda14cbcSMatt Macy 102*eda14cbcSMatt Macy /* 103*eda14cbcSMatt Macy * Common routines to initialize property tables 104*eda14cbcSMatt Macy */ 105*eda14cbcSMatt Macy void zprop_register_impl(int, const char *, zprop_type_t, uint64_t, 106*eda14cbcSMatt Macy const char *, zprop_attr_t, int, const char *, const char *, 107*eda14cbcSMatt Macy boolean_t, boolean_t, const zprop_index_t *); 108*eda14cbcSMatt Macy void zprop_register_string(int, const char *, const char *, 109*eda14cbcSMatt Macy zprop_attr_t attr, int, const char *, const char *); 110*eda14cbcSMatt Macy void zprop_register_number(int, const char *, uint64_t, zprop_attr_t, int, 111*eda14cbcSMatt Macy const char *, const char *); 112*eda14cbcSMatt Macy void zprop_register_index(int, const char *, uint64_t, zprop_attr_t, int, 113*eda14cbcSMatt Macy const char *, const char *, const zprop_index_t *); 114*eda14cbcSMatt Macy void zprop_register_hidden(int, const char *, zprop_type_t, zprop_attr_t, 115*eda14cbcSMatt Macy int, const char *); 116*eda14cbcSMatt Macy 117*eda14cbcSMatt Macy /* 118*eda14cbcSMatt Macy * Common routines for zfs and zpool property management 119*eda14cbcSMatt Macy */ 120*eda14cbcSMatt Macy int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, zfs_type_t); 121*eda14cbcSMatt Macy int zprop_name_to_prop(const char *, zfs_type_t); 122*eda14cbcSMatt Macy int zprop_string_to_index(int, const char *, uint64_t *, zfs_type_t); 123*eda14cbcSMatt Macy int zprop_index_to_string(int, uint64_t, const char **, zfs_type_t); 124*eda14cbcSMatt Macy uint64_t zprop_random_value(int, uint64_t, zfs_type_t); 125*eda14cbcSMatt Macy const char *zprop_values(int, zfs_type_t); 126*eda14cbcSMatt Macy size_t zprop_width(int, boolean_t *, zfs_type_t); 127*eda14cbcSMatt Macy boolean_t zprop_valid_for_type(int, zfs_type_t, boolean_t); 128*eda14cbcSMatt Macy 129*eda14cbcSMatt Macy #ifdef __cplusplus 130*eda14cbcSMatt Macy } 131*eda14cbcSMatt Macy #endif 132*eda14cbcSMatt Macy 133*eda14cbcSMatt Macy #endif /* _ZFS_PROP_H */ 134