xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/dsl_prop.h (revision 968633ad8faee931821fd6b656eb0d96d4b186c0)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_DSL_PROP_H
27 #define	_SYS_DSL_PROP_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/dmu.h>
32 #include <sys/dsl_pool.h>
33 #include <sys/zfs_context.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 struct dsl_dataset;
40 struct dsl_dir;
41 
42 /* The callback func may not call into the DMU or DSL! */
43 typedef void (dsl_prop_changed_cb_t)(void *arg, uint64_t newval);
44 
45 typedef struct dsl_prop_cb_record {
46 	list_node_t cbr_node; /* link on dd_prop_cbs */
47 	struct dsl_dataset *cbr_ds;
48 	const char *cbr_propname;
49 	dsl_prop_changed_cb_t *cbr_func;
50 	void *cbr_arg;
51 } dsl_prop_cb_record_t;
52 
53 int dsl_prop_register(struct dsl_dataset *ds, const char *propname,
54     dsl_prop_changed_cb_t *callback, void *cbarg);
55 int dsl_prop_unregister(struct dsl_dataset *ds, const char *propname,
56     dsl_prop_changed_cb_t *callback, void *cbarg);
57 int dsl_prop_numcb(struct dsl_dataset *ds);
58 
59 int dsl_prop_get(const char *ddname, const char *propname,
60     int intsz, int numints, void *buf, char *setpoint);
61 int dsl_prop_get_integer(const char *ddname, const char *propname,
62     uint64_t *valuep, char *setpoint);
63 int dsl_prop_get_all(objset_t *os, nvlist_t **nvp, boolean_t local);
64 int dsl_prop_get_ds(struct dsl_dataset *ds, const char *propname,
65     int intsz, int numints, void *buf, char *setpoint);
66 int dsl_prop_get_dd(struct dsl_dir *dd, const char *propname,
67     int intsz, int numints, void *buf, char *setpoint);
68 
69 int dsl_prop_set(const char *ddname, const char *propname,
70     int intsz, int numints, const void *buf);
71 void dsl_prop_set_uint64_sync(dsl_dir_t *dd, const char *name, uint64_t val,
72     cred_t *cr, dmu_tx_t *tx);
73 
74 void dsl_prop_nvlist_add_uint64(nvlist_t *nv, zfs_prop_t prop, uint64_t value);
75 void dsl_prop_nvlist_add_string(nvlist_t *nv,
76     zfs_prop_t prop, const char *value);
77 
78 #ifdef	__cplusplus
79 }
80 #endif
81 
82 #endif	/* _SYS_DSL_PROP_H */
83