xref: /onnv-gate/usr/src/common/zfs/zfs_prop.h (revision 11976:3791e5495b0d)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
52676Seschrock  * Common Development and Distribution License (the "License").
62676Seschrock  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
21789Sahrens /*
22*11976STom.Erickson@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23789Sahrens  * Use is subject to license terms.
24789Sahrens  */
25789Sahrens 
26789Sahrens #ifndef	_ZFS_PROP_H
27789Sahrens #define	_ZFS_PROP_H
28789Sahrens 
29789Sahrens #include <sys/fs/zfs.h>
30789Sahrens #include <sys/types.h>
31789Sahrens 
32789Sahrens #ifdef	__cplusplus
33789Sahrens extern "C" {
34789Sahrens #endif
35789Sahrens 
36914Slling /*
37914Slling  * For index types (e.g. compression and checksum), we want the numeric value
38914Slling  * in the kernel, but the string value in userland.
39914Slling  */
40789Sahrens typedef enum {
414787Sahrens 	PROP_TYPE_NUMBER,	/* numeric value */
424787Sahrens 	PROP_TYPE_STRING,	/* string value */
434787Sahrens 	PROP_TYPE_INDEX		/* numeric value indexed by string */
445094Slling } zprop_type_t;
455094Slling 
465094Slling typedef enum {
475094Slling 	PROP_DEFAULT,
485094Slling 	PROP_READONLY,
495331Samw 	PROP_INHERIT,
505331Samw 	/*
515331Samw 	 * ONETIME properties are a sort of conglomeration of READONLY
525331Samw 	 * and INHERIT.  They can be set only during object creation,
535331Samw 	 * after that they are READONLY.  If not explicitly set during
545331Samw 	 * creation, they can be inherited.
555331Samw 	 */
565331Samw 	PROP_ONETIME
575094Slling } zprop_attr_t;
585094Slling 
595094Slling typedef struct zfs_index {
605094Slling 	const char *pi_name;
615094Slling 	uint64_t pi_value;
625094Slling } zprop_index_t;
635094Slling 
645094Slling typedef struct {
655094Slling 	const char *pd_name;		/* human-readable property name */
665094Slling 	int pd_propnum;			/* property number */
675094Slling 	zprop_type_t pd_proptype;	/* string, boolean, index, number */
685094Slling 	const char *pd_strdefault;	/* default for strings */
695094Slling 	uint64_t pd_numdefault;		/* for boolean / index / number */
705094Slling 	zprop_attr_t pd_attr;		/* default, readonly, inherit */
715094Slling 	int pd_types;			/* bitfield of valid dataset types */
725094Slling 					/* fs | vol | snap; or pool */
735094Slling 	const char *pd_values;		/* string telling acceptable values */
745094Slling 	const char *pd_colname;		/* column header for "zfs list" */
755094Slling 	boolean_t pd_rightalign;	/* column alignment for "zfs list" */
765094Slling 	boolean_t pd_visible;		/* do we list this property with the */
775094Slling 					/* "zfs get" help message */
785094Slling 	const zprop_index_t *pd_table;	/* for index properties, a table */
795094Slling 					/* defining the possible values */
8010922SJeff.Bonwick@Sun.COM 	size_t pd_table_size;		/* number of entries in pd_table[] */
815094Slling } zprop_desc_t;
82789Sahrens 
835094Slling /*
845094Slling  * zfs dataset property functions
855094Slling  */
865094Slling void zfs_prop_init(void);
875094Slling zprop_type_t zfs_prop_get_type(zfs_prop_t);
884787Sahrens boolean_t zfs_prop_delegatable(zfs_prop_t prop);
895094Slling zprop_desc_t *zfs_prop_get_table(void);
905094Slling 
915094Slling /*
925094Slling  * zpool property functions
935094Slling  */
945094Slling void zpool_prop_init(void);
955094Slling zprop_type_t zpool_prop_get_type(zpool_prop_t);
965094Slling zprop_desc_t *zpool_prop_get_table(void);
975094Slling 
985094Slling /*
995094Slling  * Common routines to initialize property tables
1005094Slling  */
101*11976STom.Erickson@Sun.COM void zprop_register_impl(int, const char *, zprop_type_t, uint64_t,
1025094Slling     const char *, zprop_attr_t, int, const char *, const char *,
1035094Slling     boolean_t, boolean_t, const zprop_index_t *);
104*11976STom.Erickson@Sun.COM void zprop_register_string(int, const char *, const char *,
105*11976STom.Erickson@Sun.COM     zprop_attr_t attr, int, const char *, const char *);
106*11976STom.Erickson@Sun.COM void zprop_register_number(int, const char *, uint64_t, zprop_attr_t, int,
1075094Slling     const char *, const char *);
108*11976STom.Erickson@Sun.COM void zprop_register_index(int, const char *, uint64_t, zprop_attr_t, int,
1095094Slling     const char *, const char *, const zprop_index_t *);
110*11976STom.Erickson@Sun.COM void zprop_register_hidden(int, const char *, zprop_type_t, zprop_attr_t,
1115094Slling     int, const char *);
1125094Slling 
1135094Slling /*
1145094Slling  * Common routines for zfs and zpool property management
1155094Slling  */
1165094Slling int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, zfs_type_t);
1175094Slling int zprop_name_to_prop(const char *, zfs_type_t);
1185094Slling int zprop_string_to_index(int, const char *, uint64_t *, zfs_type_t);
1195094Slling int zprop_index_to_string(int, uint64_t, const char **, zfs_type_t);
12010922SJeff.Bonwick@Sun.COM uint64_t zprop_random_value(int, uint64_t, zfs_type_t);
1215094Slling const char *zprop_values(int, zfs_type_t);
1225094Slling size_t zprop_width(int, boolean_t *, zfs_type_t);
1236690Sgw25295 boolean_t zprop_valid_for_type(int, zfs_type_t);
124789Sahrens 
125789Sahrens #ifdef	__cplusplus
126789Sahrens }
127789Sahrens #endif
128789Sahrens 
129789Sahrens #endif	/* _ZFS_PROP_H */
130