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