1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5e9dbad6fSeschrock * Common Development and Distribution License (the "License"). 6e9dbad6fSeschrock * 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 /* 22*83d7f9feSTom Erickson * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23fa9e4066Sahrens * Use is subject to license terms. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #ifndef _ZFS_PROP_H 27fa9e4066Sahrens #define _ZFS_PROP_H 28fa9e4066Sahrens 29fa9e4066Sahrens #include <sys/fs/zfs.h> 30fa9e4066Sahrens #include <sys/types.h> 31fa9e4066Sahrens 32fa9e4066Sahrens #ifdef __cplusplus 33fa9e4066Sahrens extern "C" { 34fa9e4066Sahrens #endif 35fa9e4066Sahrens 36101f5531Slling /* 37101f5531Slling * For index types (e.g. compression and checksum), we want the numeric value 38101f5531Slling * in the kernel, but the string value in userland. 39101f5531Slling */ 40fa9e4066Sahrens typedef enum { 4191ebeef5Sahrens PROP_TYPE_NUMBER, /* numeric value */ 4291ebeef5Sahrens PROP_TYPE_STRING, /* string value */ 4391ebeef5Sahrens PROP_TYPE_INDEX /* numeric value indexed by string */ 44990b4856Slling } zprop_type_t; 45fa9e4066Sahrens 46990b4856Slling typedef enum { 47990b4856Slling PROP_DEFAULT, 48990b4856Slling PROP_READONLY, 49da6c28aaSamw PROP_INHERIT, 50da6c28aaSamw /* 51da6c28aaSamw * ONETIME properties are a sort of conglomeration of READONLY 52da6c28aaSamw * and INHERIT. They can be set only during object creation, 53da6c28aaSamw * after that they are READONLY. If not explicitly set during 54da6c28aaSamw * creation, they can be inherited. 55da6c28aaSamw */ 56da6c28aaSamw PROP_ONETIME 57990b4856Slling } zprop_attr_t; 58990b4856Slling 59990b4856Slling typedef struct zfs_index { 60990b4856Slling const char *pi_name; 61990b4856Slling uint64_t pi_value; 62990b4856Slling } zprop_index_t; 63990b4856Slling 64990b4856Slling typedef struct { 65990b4856Slling const char *pd_name; /* human-readable property name */ 66990b4856Slling int pd_propnum; /* property number */ 67990b4856Slling zprop_type_t pd_proptype; /* string, boolean, index, number */ 68990b4856Slling const char *pd_strdefault; /* default for strings */ 69990b4856Slling uint64_t pd_numdefault; /* for boolean / index / number */ 70990b4856Slling zprop_attr_t pd_attr; /* default, readonly, inherit */ 71990b4856Slling int pd_types; /* bitfield of valid dataset types */ 72990b4856Slling /* fs | vol | snap; or pool */ 73990b4856Slling const char *pd_values; /* string telling acceptable values */ 74990b4856Slling const char *pd_colname; /* column header for "zfs list" */ 75990b4856Slling boolean_t pd_rightalign; /* column alignment for "zfs list" */ 76990b4856Slling boolean_t pd_visible; /* do we list this property with the */ 77990b4856Slling /* "zfs get" help message */ 78990b4856Slling const zprop_index_t *pd_table; /* for index properties, a table */ 79990b4856Slling /* defining the possible values */ 80b24ab676SJeff Bonwick size_t pd_table_size; /* number of entries in pd_table[] */ 81990b4856Slling } zprop_desc_t; 82990b4856Slling 83990b4856Slling /* 84990b4856Slling * zfs dataset property functions 85990b4856Slling */ 8691ebeef5Sahrens void zfs_prop_init(void); 87990b4856Slling zprop_type_t zfs_prop_get_type(zfs_prop_t); 88990b4856Slling boolean_t zfs_prop_delegatable(zfs_prop_t prop); 89990b4856Slling zprop_desc_t *zfs_prop_get_table(void); 90990b4856Slling 91990b4856Slling /* 92990b4856Slling * zpool property functions 93990b4856Slling */ 94990b4856Slling void zpool_prop_init(void); 95990b4856Slling zprop_type_t zpool_prop_get_type(zpool_prop_t); 96990b4856Slling zprop_desc_t *zpool_prop_get_table(void); 97990b4856Slling 98990b4856Slling /* 99990b4856Slling * Common routines to initialize property tables 100990b4856Slling */ 101*83d7f9feSTom Erickson void zprop_register_impl(int, const char *, zprop_type_t, uint64_t, 102990b4856Slling const char *, zprop_attr_t, int, const char *, const char *, 103990b4856Slling boolean_t, boolean_t, const zprop_index_t *); 104*83d7f9feSTom Erickson void zprop_register_string(int, const char *, const char *, 105*83d7f9feSTom Erickson zprop_attr_t attr, int, const char *, const char *); 106*83d7f9feSTom Erickson void zprop_register_number(int, const char *, uint64_t, zprop_attr_t, int, 107990b4856Slling const char *, const char *); 108*83d7f9feSTom Erickson void zprop_register_index(int, const char *, uint64_t, zprop_attr_t, int, 109990b4856Slling const char *, const char *, const zprop_index_t *); 110*83d7f9feSTom Erickson void zprop_register_hidden(int, const char *, zprop_type_t, zprop_attr_t, 111990b4856Slling int, const char *); 112990b4856Slling 113990b4856Slling /* 114990b4856Slling * Common routines for zfs and zpool property management 115990b4856Slling */ 116990b4856Slling int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, zfs_type_t); 117990b4856Slling int zprop_name_to_prop(const char *, zfs_type_t); 118990b4856Slling int zprop_string_to_index(int, const char *, uint64_t *, zfs_type_t); 119990b4856Slling int zprop_index_to_string(int, uint64_t, const char **, zfs_type_t); 120b24ab676SJeff Bonwick uint64_t zprop_random_value(int, uint64_t, zfs_type_t); 121990b4856Slling const char *zprop_values(int, zfs_type_t); 122990b4856Slling size_t zprop_width(int, boolean_t *, zfs_type_t); 1234853e976Sgw25295 boolean_t zprop_valid_for_type(int, zfs_type_t); 124fa9e4066Sahrens 125fa9e4066Sahrens #ifdef __cplusplus 126fa9e4066Sahrens } 127fa9e4066Sahrens #endif 128fa9e4066Sahrens 129fa9e4066Sahrens #endif /* _ZFS_PROP_H */ 130