]> git.proxmox.com Git - mirror_zfs-debian.git/blame - zfs/lib/libzcommon/include/zfs_prop.h
Remove stray stub kernel files which should be brought in my linux-kernel-module...
[mirror_zfs-debian.git] / zfs / lib / libzcommon / 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/*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _ZFS_PROP_H
27#define _ZFS_PROP_H
28
29#pragma ident "@(#)zfs_prop.h 1.9 07/10/25 SMI"
30
31#include <sys/fs/zfs.h>
32#include <sys/types.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/*
39 * For index types (e.g. compression and checksum), we want the numeric value
40 * in the kernel, but the string value in userland.
41 */
42typedef enum {
43 PROP_TYPE_NUMBER, /* numeric value */
44 PROP_TYPE_STRING, /* string value */
45 PROP_TYPE_INDEX /* numeric value indexed by string */
46} zprop_type_t;
47
48typedef enum {
49 PROP_DEFAULT,
50 PROP_READONLY,
51 PROP_INHERIT,
52 /*
53 * ONETIME properties are a sort of conglomeration of READONLY
54 * and INHERIT. They can be set only during object creation,
55 * after that they are READONLY. If not explicitly set during
56 * creation, they can be inherited.
57 */
58 PROP_ONETIME
59} zprop_attr_t;
60
61typedef struct zfs_index {
62 const char *pi_name;
63 uint64_t pi_value;
64} zprop_index_t;
65
66typedef struct {
67 const char *pd_name; /* human-readable property name */
68 int pd_propnum; /* property number */
69 zprop_type_t pd_proptype; /* string, boolean, index, number */
70 const char *pd_strdefault; /* default for strings */
71 uint64_t pd_numdefault; /* for boolean / index / number */
72 zprop_attr_t pd_attr; /* default, readonly, inherit */
73 int pd_types; /* bitfield of valid dataset types */
74 /* fs | vol | snap; or pool */
75 const char *pd_values; /* string telling acceptable values */
76 const char *pd_colname; /* column header for "zfs list" */
77 boolean_t pd_rightalign; /* column alignment for "zfs list" */
78 boolean_t pd_visible; /* do we list this property with the */
79 /* "zfs get" help message */
80 const zprop_index_t *pd_table; /* for index properties, a table */
81 /* defining the possible values */
82} zprop_desc_t;
83
84/*
85 * zfs dataset property functions
86 */
87void zfs_prop_init(void);
88zprop_type_t zfs_prop_get_type(zfs_prop_t);
89boolean_t zfs_prop_delegatable(zfs_prop_t prop);
90zprop_desc_t *zfs_prop_get_table(void);
91
92/*
93 * zpool property functions
94 */
95void zpool_prop_init(void);
96zprop_type_t zpool_prop_get_type(zpool_prop_t);
97zprop_desc_t *zpool_prop_get_table(void);
98
99/*
100 * Common routines to initialize property tables
101 */
102void register_impl(int, const char *, zprop_type_t, uint64_t,
103 const char *, zprop_attr_t, int, const char *, const char *,
104 boolean_t, boolean_t, const zprop_index_t *);
105void register_string(int, const char *, const char *, zprop_attr_t attr,
106 int, const char *, const char *);
107void register_number(int, const char *, uint64_t, zprop_attr_t, int,
108 const char *, const char *);
109void register_index(int, const char *, uint64_t, zprop_attr_t, int,
110 const char *, const char *, const zprop_index_t *);
111void register_hidden(int, const char *, zprop_type_t, zprop_attr_t,
112 int, const char *);
113
114/*
115 * Common routines for zfs and zpool property management
116 */
117int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, zfs_type_t);
118int zprop_name_to_prop(const char *, zfs_type_t);
119int zprop_string_to_index(int, const char *, uint64_t *, zfs_type_t);
120int zprop_index_to_string(int, uint64_t, const char **, zfs_type_t);
121const char *zprop_values(int, zfs_type_t);
122size_t zprop_width(int, boolean_t *, zfs_type_t);
123int zprop_valid_for_type(int, zfs_type_t);
124
125#ifdef __cplusplus
126}
127#endif
128
129#endif /* _ZFS_PROP_H */