xref: /titanic_52/usr/src/common/zfs/zfs_prop.h (revision 990b4856d0eaada6f8140335733a1b1771ed2746)
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 /*
223d7072f8Seschrock  * Copyright 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30fa9e4066Sahrens 
31fa9e4066Sahrens #include <sys/fs/zfs.h>
32fa9e4066Sahrens #include <sys/types.h>
33fa9e4066Sahrens 
34fa9e4066Sahrens #ifdef	__cplusplus
35fa9e4066Sahrens extern "C" {
36fa9e4066Sahrens #endif
37fa9e4066Sahrens 
38101f5531Slling /*
39101f5531Slling  * For index types (e.g. compression and checksum), we want the numeric value
40101f5531Slling  * in the kernel, but the string value in userland.
41101f5531Slling  */
42fa9e4066Sahrens typedef enum {
4391ebeef5Sahrens 	PROP_TYPE_NUMBER,	/* numeric value */
4491ebeef5Sahrens 	PROP_TYPE_STRING,	/* string value */
4591ebeef5Sahrens 	PROP_TYPE_INDEX		/* numeric value indexed by string */
46*990b4856Slling } zprop_type_t;
47fa9e4066Sahrens 
48*990b4856Slling typedef enum {
49*990b4856Slling 	PROP_DEFAULT,
50*990b4856Slling 	PROP_READONLY,
51*990b4856Slling 	PROP_INHERIT
52*990b4856Slling } zprop_attr_t;
53*990b4856Slling 
54*990b4856Slling typedef struct zfs_index {
55*990b4856Slling 	const char *pi_name;
56*990b4856Slling 	uint64_t pi_value;
57*990b4856Slling } zprop_index_t;
58*990b4856Slling 
59*990b4856Slling typedef struct {
60*990b4856Slling 	const char *pd_name;		/* human-readable property name */
61*990b4856Slling 	int pd_propnum;			/* property number */
62*990b4856Slling 	zprop_type_t pd_proptype;	/* string, boolean, index, number */
63*990b4856Slling 	const char *pd_strdefault;	/* default for strings */
64*990b4856Slling 	uint64_t pd_numdefault;		/* for boolean / index / number */
65*990b4856Slling 	zprop_attr_t pd_attr;		/* default, readonly, inherit */
66*990b4856Slling 	int pd_types;			/* bitfield of valid dataset types */
67*990b4856Slling 					/* fs | vol | snap; or pool */
68*990b4856Slling 	const char *pd_values;		/* string telling acceptable values */
69*990b4856Slling 	const char *pd_colname;		/* column header for "zfs list" */
70*990b4856Slling 	boolean_t pd_rightalign;	/* column alignment for "zfs list" */
71*990b4856Slling 	boolean_t pd_visible;		/* do we list this property with the */
72*990b4856Slling 					/* "zfs get" help message */
73*990b4856Slling 	const zprop_index_t *pd_table;	/* for index properties, a table */
74*990b4856Slling 					/* defining the possible values */
75*990b4856Slling } zprop_desc_t;
76*990b4856Slling 
77*990b4856Slling /*
78*990b4856Slling  * zfs dataset property functions
79*990b4856Slling  */
8091ebeef5Sahrens void zfs_prop_init(void);
81*990b4856Slling zprop_type_t zfs_prop_get_type(zfs_prop_t);
82*990b4856Slling boolean_t zfs_prop_delegatable(zfs_prop_t prop);
83*990b4856Slling zprop_desc_t *zfs_prop_get_table(void);
84*990b4856Slling 
85*990b4856Slling /*
86*990b4856Slling  * zpool property functions
87*990b4856Slling  */
88*990b4856Slling void zpool_prop_init(void);
89*990b4856Slling zprop_type_t zpool_prop_get_type(zpool_prop_t);
90*990b4856Slling zprop_desc_t *zpool_prop_get_table(void);
91*990b4856Slling 
92*990b4856Slling /*
93*990b4856Slling  * Common routines to initialize property tables
94*990b4856Slling  */
95*990b4856Slling void register_impl(int, const char *, zprop_type_t, uint64_t,
96*990b4856Slling     const char *, zprop_attr_t, int, const char *, const char *,
97*990b4856Slling     boolean_t, boolean_t, const zprop_index_t *);
98*990b4856Slling void register_string(int, const char *, const char *, zprop_attr_t attr,
99*990b4856Slling     int, const char *, const char *);
100*990b4856Slling void register_number(int, const char *, uint64_t, zprop_attr_t, int,
101*990b4856Slling     const char *, const char *);
102*990b4856Slling void register_index(int, const char *, uint64_t, zprop_attr_t, int,
103*990b4856Slling     const char *, const char *, const zprop_index_t *);
104*990b4856Slling void register_hidden(int, const char *, zprop_type_t, zprop_attr_t,
105*990b4856Slling     int, const char *);
106*990b4856Slling 
107*990b4856Slling /*
108*990b4856Slling  * Common routines for zfs and zpool property management
109*990b4856Slling  */
110*990b4856Slling int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, zfs_type_t);
111*990b4856Slling int zprop_name_to_prop(const char *, zfs_type_t);
112*990b4856Slling int zprop_string_to_index(int, const char *, uint64_t *, zfs_type_t);
113*990b4856Slling int zprop_index_to_string(int, uint64_t, const char **, zfs_type_t);
114*990b4856Slling const char *zprop_values(int, zfs_type_t);
115*990b4856Slling size_t zprop_width(int, boolean_t *, zfs_type_t);
116*990b4856Slling int zprop_valid_for_type(int, zfs_type_t);
117fa9e4066Sahrens 
118fa9e4066Sahrens #ifdef	__cplusplus
119fa9e4066Sahrens }
120fa9e4066Sahrens #endif
121fa9e4066Sahrens 
122fa9e4066Sahrens #endif	/* _ZFS_PROP_H */
123