xref: /freebsd/sys/contrib/openzfs/include/sys/nvpair.h (revision 3ff01b231dfa83d518854c63e7c9cd1debd1139e)
1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9eda14cbcSMatt Macy  * or http://www.opensolaris.org/os/licensing.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy /*
22eda14cbcSMatt Macy  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
23eda14cbcSMatt Macy  * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24eda14cbcSMatt Macy  */
25eda14cbcSMatt Macy 
26eda14cbcSMatt Macy #ifndef	_SYS_NVPAIR_H
27*3ff01b23SMartin Matuska #define	_SYS_NVPAIR_H extern __attribute__((visibility("default")))
28eda14cbcSMatt Macy 
29eda14cbcSMatt Macy #include <sys/types.h>
30eda14cbcSMatt Macy #include <sys/time.h>
31eda14cbcSMatt Macy #include <sys/errno.h>
32eda14cbcSMatt Macy 
33eda14cbcSMatt Macy #ifdef	__cplusplus
34eda14cbcSMatt Macy extern "C" {
35eda14cbcSMatt Macy #endif
36eda14cbcSMatt Macy 
37eda14cbcSMatt Macy typedef enum {
38eda14cbcSMatt Macy 	DATA_TYPE_DONTCARE = -1,
39eda14cbcSMatt Macy 	DATA_TYPE_UNKNOWN = 0,
40eda14cbcSMatt Macy 	DATA_TYPE_BOOLEAN,
41eda14cbcSMatt Macy 	DATA_TYPE_BYTE,
42eda14cbcSMatt Macy 	DATA_TYPE_INT16,
43eda14cbcSMatt Macy 	DATA_TYPE_UINT16,
44eda14cbcSMatt Macy 	DATA_TYPE_INT32,
45eda14cbcSMatt Macy 	DATA_TYPE_UINT32,
46eda14cbcSMatt Macy 	DATA_TYPE_INT64,
47eda14cbcSMatt Macy 	DATA_TYPE_UINT64,
48eda14cbcSMatt Macy 	DATA_TYPE_STRING,
49eda14cbcSMatt Macy 	DATA_TYPE_BYTE_ARRAY,
50eda14cbcSMatt Macy 	DATA_TYPE_INT16_ARRAY,
51eda14cbcSMatt Macy 	DATA_TYPE_UINT16_ARRAY,
52eda14cbcSMatt Macy 	DATA_TYPE_INT32_ARRAY,
53eda14cbcSMatt Macy 	DATA_TYPE_UINT32_ARRAY,
54eda14cbcSMatt Macy 	DATA_TYPE_INT64_ARRAY,
55eda14cbcSMatt Macy 	DATA_TYPE_UINT64_ARRAY,
56eda14cbcSMatt Macy 	DATA_TYPE_STRING_ARRAY,
57eda14cbcSMatt Macy 	DATA_TYPE_HRTIME,
58eda14cbcSMatt Macy 	DATA_TYPE_NVLIST,
59eda14cbcSMatt Macy 	DATA_TYPE_NVLIST_ARRAY,
60eda14cbcSMatt Macy 	DATA_TYPE_BOOLEAN_VALUE,
61eda14cbcSMatt Macy 	DATA_TYPE_INT8,
62eda14cbcSMatt Macy 	DATA_TYPE_UINT8,
63eda14cbcSMatt Macy 	DATA_TYPE_BOOLEAN_ARRAY,
64eda14cbcSMatt Macy 	DATA_TYPE_INT8_ARRAY,
652fec3ae8SWarner Losh #if !defined(_KERNEL) && !defined(_STANDALONE)
66eda14cbcSMatt Macy 	DATA_TYPE_UINT8_ARRAY,
67eda14cbcSMatt Macy 	DATA_TYPE_DOUBLE
68eda14cbcSMatt Macy #else
69eda14cbcSMatt Macy 	DATA_TYPE_UINT8_ARRAY
70eda14cbcSMatt Macy #endif
71eda14cbcSMatt Macy } data_type_t;
72eda14cbcSMatt Macy 
73eda14cbcSMatt Macy typedef struct nvpair {
74eda14cbcSMatt Macy 	int32_t nvp_size;	/* size of this nvpair */
75eda14cbcSMatt Macy 	int16_t	nvp_name_sz;	/* length of name string */
76eda14cbcSMatt Macy 	int16_t	nvp_reserve;	/* not used */
77eda14cbcSMatt Macy 	int32_t	nvp_value_elem;	/* number of elements for array types */
78eda14cbcSMatt Macy 	data_type_t nvp_type;	/* type of value */
79eda14cbcSMatt Macy 	/* name string */
80eda14cbcSMatt Macy 	/* aligned ptr array for string arrays */
81eda14cbcSMatt Macy 	/* aligned array of data for value */
82eda14cbcSMatt Macy } nvpair_t;
83eda14cbcSMatt Macy 
84eda14cbcSMatt Macy /* nvlist header */
85eda14cbcSMatt Macy typedef struct nvlist {
86eda14cbcSMatt Macy 	int32_t		nvl_version;
87eda14cbcSMatt Macy 	uint32_t	nvl_nvflag;	/* persistent flags */
88eda14cbcSMatt Macy 	uint64_t	nvl_priv;	/* ptr to private data if not packed */
89eda14cbcSMatt Macy 	uint32_t	nvl_flag;
90eda14cbcSMatt Macy 	int32_t		nvl_pad;	/* currently not used, for alignment */
91eda14cbcSMatt Macy } nvlist_t;
92eda14cbcSMatt Macy 
93eda14cbcSMatt Macy /* nvp implementation version */
94eda14cbcSMatt Macy #define	NV_VERSION	0
95eda14cbcSMatt Macy 
96eda14cbcSMatt Macy /* nvlist pack encoding */
97eda14cbcSMatt Macy #define	NV_ENCODE_NATIVE	0
98eda14cbcSMatt Macy #define	NV_ENCODE_XDR		1
99eda14cbcSMatt Macy 
100eda14cbcSMatt Macy /* nvlist persistent unique name flags, stored in nvl_nvflags */
101eda14cbcSMatt Macy #define	NV_UNIQUE_NAME		0x1
102eda14cbcSMatt Macy #define	NV_UNIQUE_NAME_TYPE	0x2
103eda14cbcSMatt Macy 
104eda14cbcSMatt Macy /* nvlist lookup pairs related flags */
105eda14cbcSMatt Macy #define	NV_FLAG_NOENTOK		0x1
106eda14cbcSMatt Macy 
107eda14cbcSMatt Macy /* convenience macros */
108eda14cbcSMatt Macy #define	NV_ALIGN(x)		(((ulong_t)(x) + 7ul) & ~7ul)
109eda14cbcSMatt Macy #define	NV_ALIGN4(x)		(((x) + 3) & ~3)
110eda14cbcSMatt Macy 
111eda14cbcSMatt Macy #define	NVP_SIZE(nvp)		((nvp)->nvp_size)
112eda14cbcSMatt Macy #define	NVP_NAME(nvp)		((char *)(nvp) + sizeof (nvpair_t))
113eda14cbcSMatt Macy #define	NVP_TYPE(nvp)		((nvp)->nvp_type)
114eda14cbcSMatt Macy #define	NVP_NELEM(nvp)		((nvp)->nvp_value_elem)
115eda14cbcSMatt Macy #define	NVP_VALUE(nvp)		((char *)(nvp) + NV_ALIGN(sizeof (nvpair_t) \
116eda14cbcSMatt Macy 				+ (nvp)->nvp_name_sz))
117eda14cbcSMatt Macy 
118eda14cbcSMatt Macy #define	NVL_VERSION(nvl)	((nvl)->nvl_version)
119eda14cbcSMatt Macy #define	NVL_SIZE(nvl)		((nvl)->nvl_size)
120eda14cbcSMatt Macy #define	NVL_FLAG(nvl)		((nvl)->nvl_flag)
121eda14cbcSMatt Macy 
122eda14cbcSMatt Macy /* NV allocator framework */
123eda14cbcSMatt Macy typedef struct nv_alloc_ops nv_alloc_ops_t;
124eda14cbcSMatt Macy 
125eda14cbcSMatt Macy typedef struct nv_alloc {
126eda14cbcSMatt Macy 	const nv_alloc_ops_t *nva_ops;
127eda14cbcSMatt Macy 	void *nva_arg;
128eda14cbcSMatt Macy } nv_alloc_t;
129eda14cbcSMatt Macy 
130eda14cbcSMatt Macy struct nv_alloc_ops {
131eda14cbcSMatt Macy 	int (*nv_ao_init)(nv_alloc_t *, va_list);
132eda14cbcSMatt Macy 	void (*nv_ao_fini)(nv_alloc_t *);
133eda14cbcSMatt Macy 	void *(*nv_ao_alloc)(nv_alloc_t *, size_t);
134eda14cbcSMatt Macy 	void (*nv_ao_free)(nv_alloc_t *, void *, size_t);
135eda14cbcSMatt Macy 	void (*nv_ao_reset)(nv_alloc_t *);
136eda14cbcSMatt Macy };
137eda14cbcSMatt Macy 
138*3ff01b23SMartin Matuska _SYS_NVPAIR_H const nv_alloc_ops_t *nv_fixed_ops;
139*3ff01b23SMartin Matuska _SYS_NVPAIR_H nv_alloc_t *nv_alloc_nosleep;
140eda14cbcSMatt Macy 
141eda14cbcSMatt Macy #if defined(_KERNEL)
142*3ff01b23SMartin Matuska _SYS_NVPAIR_H nv_alloc_t *nv_alloc_sleep;
143*3ff01b23SMartin Matuska _SYS_NVPAIR_H nv_alloc_t *nv_alloc_pushpage;
144eda14cbcSMatt Macy #endif
145eda14cbcSMatt Macy 
146*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nv_alloc_init(nv_alloc_t *, const nv_alloc_ops_t *,
147*3ff01b23SMartin Matuska 	/* args */ ...);
148*3ff01b23SMartin Matuska _SYS_NVPAIR_H void nv_alloc_reset(nv_alloc_t *);
149*3ff01b23SMartin Matuska _SYS_NVPAIR_H void nv_alloc_fini(nv_alloc_t *);
150eda14cbcSMatt Macy 
151eda14cbcSMatt Macy /* list management */
152*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_alloc(nvlist_t **, uint_t, int);
153*3ff01b23SMartin Matuska _SYS_NVPAIR_H void nvlist_free(nvlist_t *);
154*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_size(nvlist_t *, size_t *, int);
155*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_pack(nvlist_t *, char **, size_t *, int, int);
156*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_unpack(char *, size_t, nvlist_t **, int);
157*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_dup(nvlist_t *, nvlist_t **, int);
158*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_merge(nvlist_t *, nvlist_t *, int);
159eda14cbcSMatt Macy 
160*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint_t nvlist_nvflag(nvlist_t *);
161eda14cbcSMatt Macy 
162*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_xalloc(nvlist_t **, uint_t, nv_alloc_t *);
163*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_xpack(nvlist_t *, char **, size_t *, int,
164*3ff01b23SMartin Matuska     nv_alloc_t *);
165*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_xunpack(char *, size_t, nvlist_t **, nv_alloc_t *);
166*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_xdup(nvlist_t *, nvlist_t **, nv_alloc_t *);
167*3ff01b23SMartin Matuska _SYS_NVPAIR_H nv_alloc_t *nvlist_lookup_nv_alloc(nvlist_t *);
168eda14cbcSMatt Macy 
169*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_nvpair(nvlist_t *, nvpair_t *);
170*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_boolean(nvlist_t *, const char *);
171*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_boolean_value(nvlist_t *, const char *, boolean_t);
172*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_byte(nvlist_t *, const char *, uchar_t);
173*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int8(nvlist_t *, const char *, int8_t);
174*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint8(nvlist_t *, const char *, uint8_t);
175*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int16(nvlist_t *, const char *, int16_t);
176*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint16(nvlist_t *, const char *, uint16_t);
177*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int32(nvlist_t *, const char *, int32_t);
178*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint32(nvlist_t *, const char *, uint32_t);
179*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int64(nvlist_t *, const char *, int64_t);
180*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint64(nvlist_t *, const char *, uint64_t);
181*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_string(nvlist_t *, const char *, const char *);
182*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *);
183*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_boolean_array(nvlist_t *, const char *,
184*3ff01b23SMartin Matuska     boolean_t *, uint_t);
185*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_byte_array(nvlist_t *, const char *, uchar_t *,
186*3ff01b23SMartin Matuska     uint_t);
187*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int8_array(nvlist_t *, const char *, int8_t *,
188*3ff01b23SMartin Matuska     uint_t);
189*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *,
190*3ff01b23SMartin Matuska     uint_t);
191*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int16_array(nvlist_t *, const char *, int16_t *,
192*3ff01b23SMartin Matuska     uint_t);
193*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *,
194*3ff01b23SMartin Matuska     uint_t);
195*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int32_array(nvlist_t *, const char *, int32_t *,
196*3ff01b23SMartin Matuska     uint_t);
197*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *,
198*3ff01b23SMartin Matuska     uint_t);
199*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_int64_array(nvlist_t *, const char *, int64_t *,
200*3ff01b23SMartin Matuska     uint_t);
201*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *,
202*3ff01b23SMartin Matuska     uint_t);
203*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_string_array(nvlist_t *, const char *,
204*3ff01b23SMartin Matuska     char * const *, uint_t);
205*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_nvlist_array(nvlist_t *, const char *,
206*3ff01b23SMartin Matuska     nvlist_t **, uint_t);
207*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t);
2082fec3ae8SWarner Losh #if !defined(_KERNEL) && !defined(_STANDALONE)
209*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_add_double(nvlist_t *, const char *, double);
210eda14cbcSMatt Macy #endif
211eda14cbcSMatt Macy 
212*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_remove(nvlist_t *, const char *, data_type_t);
213*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_remove_all(nvlist_t *, const char *);
214*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_remove_nvpair(nvlist_t *, nvpair_t *);
215eda14cbcSMatt Macy 
216*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_boolean(nvlist_t *, const char *);
217*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_boolean_value(nvlist_t *, const char *,
218*3ff01b23SMartin Matuska     boolean_t *);
219*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_byte(nvlist_t *, const char *, uchar_t *);
220*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int8(nvlist_t *, const char *, int8_t *);
221*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint8(nvlist_t *, const char *, uint8_t *);
222*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int16(nvlist_t *, const char *, int16_t *);
223*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint16(nvlist_t *, const char *, uint16_t *);
224*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int32(nvlist_t *, const char *, int32_t *);
225*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint32(nvlist_t *, const char *, uint32_t *);
226*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int64(nvlist_t *, const char *, int64_t *);
227*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *);
228*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_string(nvlist_t *, const char *, char **);
229*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_nvlist(nvlist_t *, const char *, nvlist_t **);
230*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_boolean_array(nvlist_t *, const char *,
231eda14cbcSMatt Macy     boolean_t **, uint_t *);
232*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_byte_array(nvlist_t *, const char *, uchar_t **,
233*3ff01b23SMartin Matuska     uint_t *);
234*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int8_array(nvlist_t *, const char *, int8_t **,
235*3ff01b23SMartin Matuska     uint_t *);
236*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint8_array(nvlist_t *, const char *,
237*3ff01b23SMartin Matuska     uint8_t **, uint_t *);
238*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int16_array(nvlist_t *, const char *,
239*3ff01b23SMartin Matuska     int16_t **, uint_t *);
240*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint16_array(nvlist_t *, const char *,
241*3ff01b23SMartin Matuska     uint16_t **, uint_t *);
242*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int32_array(nvlist_t *, const char *,
243*3ff01b23SMartin Matuska     int32_t **, uint_t *);
244*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint32_array(nvlist_t *, const char *,
245*3ff01b23SMartin Matuska     uint32_t **, uint_t *);
246*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_int64_array(nvlist_t *, const char *,
247*3ff01b23SMartin Matuska     int64_t **, uint_t *);
248*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_uint64_array(nvlist_t *, const char *,
249*3ff01b23SMartin Matuska     uint64_t **, uint_t *);
250*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_string_array(nvlist_t *, const char *,
251*3ff01b23SMartin Matuska     char ***, uint_t *);
252*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_nvlist_array(nvlist_t *, const char *,
253eda14cbcSMatt Macy     nvlist_t ***, uint_t *);
254*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *);
255*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_pairs(nvlist_t *, int, ...);
2562fec3ae8SWarner Losh #if !defined(_KERNEL) && !defined(_STANDALONE)
257*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_double(nvlist_t *, const char *, double *);
258eda14cbcSMatt Macy #endif
259eda14cbcSMatt Macy 
260*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **);
261*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *,
262*3ff01b23SMartin Matuska     nvpair_t **, int *, char **);
263*3ff01b23SMartin Matuska _SYS_NVPAIR_H boolean_t nvlist_exists(nvlist_t *, const char *);
264*3ff01b23SMartin Matuska _SYS_NVPAIR_H boolean_t nvlist_empty(nvlist_t *);
265eda14cbcSMatt Macy 
266eda14cbcSMatt Macy /* processing nvpair */
267*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *);
268*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvpair_t *nvlist_prev_nvpair(nvlist_t *, nvpair_t *);
269*3ff01b23SMartin Matuska _SYS_NVPAIR_H char *nvpair_name(nvpair_t *);
270*3ff01b23SMartin Matuska _SYS_NVPAIR_H data_type_t nvpair_type(nvpair_t *);
271*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_type_is_array(nvpair_t *);
272*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_boolean_value(nvpair_t *, boolean_t *);
273*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_byte(nvpair_t *, uchar_t *);
274*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int8(nvpair_t *, int8_t *);
275*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint8(nvpair_t *, uint8_t *);
276*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int16(nvpair_t *, int16_t *);
277*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint16(nvpair_t *, uint16_t *);
278*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int32(nvpair_t *, int32_t *);
279*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint32(nvpair_t *, uint32_t *);
280*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int64(nvpair_t *, int64_t *);
281*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint64(nvpair_t *, uint64_t *);
282*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_string(nvpair_t *, char **);
283*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_nvlist(nvpair_t *, nvlist_t **);
284*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_boolean_array(nvpair_t *, boolean_t **,
285*3ff01b23SMartin Matuska     uint_t *);
286*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_byte_array(nvpair_t *, uchar_t **, uint_t *);
287*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int8_array(nvpair_t *, int8_t **, uint_t *);
288*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint8_array(nvpair_t *, uint8_t **, uint_t *);
289*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int16_array(nvpair_t *, int16_t **, uint_t *);
290*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint16_array(nvpair_t *, uint16_t **, uint_t *);
291*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int32_array(nvpair_t *, int32_t **, uint_t *);
292*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint32_array(nvpair_t *, uint32_t **, uint_t *);
293*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_int64_array(nvpair_t *, int64_t **, uint_t *);
294*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_uint64_array(nvpair_t *, uint64_t **, uint_t *);
295*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_string_array(nvpair_t *, char ***, uint_t *);
296*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *);
297*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_hrtime(nvpair_t *, hrtime_t *);
2982fec3ae8SWarner Losh #if !defined(_KERNEL) && !defined(_STANDALONE)
299*3ff01b23SMartin Matuska _SYS_NVPAIR_H int nvpair_value_double(nvpair_t *, double *);
300eda14cbcSMatt Macy #endif
301eda14cbcSMatt Macy 
302*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvlist_t *fnvlist_alloc(void);
303*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_free(nvlist_t *);
304*3ff01b23SMartin Matuska _SYS_NVPAIR_H size_t fnvlist_size(nvlist_t *);
305*3ff01b23SMartin Matuska _SYS_NVPAIR_H char *fnvlist_pack(nvlist_t *, size_t *);
306*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_pack_free(char *, size_t);
307*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvlist_t *fnvlist_unpack(char *, size_t);
308*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvlist_t *fnvlist_dup(nvlist_t *);
309*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_merge(nvlist_t *, nvlist_t *);
310*3ff01b23SMartin Matuska _SYS_NVPAIR_H size_t fnvlist_num_pairs(nvlist_t *);
311eda14cbcSMatt Macy 
312*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_boolean(nvlist_t *, const char *);
313*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_boolean_value(nvlist_t *, const char *,
314*3ff01b23SMartin Matuska     boolean_t);
315*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_byte(nvlist_t *, const char *, uchar_t);
316*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int8(nvlist_t *, const char *, int8_t);
317*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint8(nvlist_t *, const char *, uint8_t);
318*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int16(nvlist_t *, const char *, int16_t);
319*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint16(nvlist_t *, const char *, uint16_t);
320*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int32(nvlist_t *, const char *, int32_t);
321*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint32(nvlist_t *, const char *, uint32_t);
322*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int64(nvlist_t *, const char *, int64_t);
323*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint64(nvlist_t *, const char *, uint64_t);
324*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_string(nvlist_t *, const char *, const char *);
325*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *);
326*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_nvpair(nvlist_t *, nvpair_t *);
327*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_boolean_array(nvlist_t *, const char *,
328*3ff01b23SMartin Matuska     boolean_t *, uint_t);
329*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_byte_array(nvlist_t *, const char *, uchar_t *,
330*3ff01b23SMartin Matuska     uint_t);
331*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int8_array(nvlist_t *, const char *, int8_t *,
332*3ff01b23SMartin Matuska     uint_t);
333*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *,
334*3ff01b23SMartin Matuska     uint_t);
335*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int16_array(nvlist_t *, const char *, int16_t *,
336*3ff01b23SMartin Matuska     uint_t);
337*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint16_array(nvlist_t *, const char *,
338*3ff01b23SMartin Matuska     uint16_t *, uint_t);
339*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int32_array(nvlist_t *, const char *, int32_t *,
340*3ff01b23SMartin Matuska     uint_t);
341*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint32_array(nvlist_t *, const char *,
342*3ff01b23SMartin Matuska     uint32_t *, uint_t);
343*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_int64_array(nvlist_t *, const char *, int64_t *,
344*3ff01b23SMartin Matuska     uint_t);
345*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_uint64_array(nvlist_t *, const char *,
346*3ff01b23SMartin Matuska     uint64_t *, uint_t);
347*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_string_array(nvlist_t *, const char *,
348*3ff01b23SMartin Matuska     char * const *, uint_t);
349*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_add_nvlist_array(nvlist_t *, const char *,
350*3ff01b23SMartin Matuska     nvlist_t **, uint_t);
351eda14cbcSMatt Macy 
352*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_remove(nvlist_t *, const char *);
353*3ff01b23SMartin Matuska _SYS_NVPAIR_H void fnvlist_remove_nvpair(nvlist_t *, nvpair_t *);
354eda14cbcSMatt Macy 
355*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvpair_t *fnvlist_lookup_nvpair(nvlist_t *, const char *);
356*3ff01b23SMartin Matuska _SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean(nvlist_t *, const char *);
357*3ff01b23SMartin Matuska _SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean_value(nvlist_t *, const char *);
358*3ff01b23SMartin Matuska _SYS_NVPAIR_H uchar_t fnvlist_lookup_byte(nvlist_t *, const char *);
359*3ff01b23SMartin Matuska _SYS_NVPAIR_H int8_t fnvlist_lookup_int8(nvlist_t *, const char *);
360*3ff01b23SMartin Matuska _SYS_NVPAIR_H int16_t fnvlist_lookup_int16(nvlist_t *, const char *);
361*3ff01b23SMartin Matuska _SYS_NVPAIR_H int32_t fnvlist_lookup_int32(nvlist_t *, const char *);
362*3ff01b23SMartin Matuska _SYS_NVPAIR_H int64_t fnvlist_lookup_int64(nvlist_t *, const char *);
363*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint8_t fnvlist_lookup_uint8(nvlist_t *, const char *);
364*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint16_t fnvlist_lookup_uint16(nvlist_t *, const char *);
365*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint32_t fnvlist_lookup_uint32(nvlist_t *, const char *);
366*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint64_t fnvlist_lookup_uint64(nvlist_t *, const char *);
367*3ff01b23SMartin Matuska _SYS_NVPAIR_H char *fnvlist_lookup_string(nvlist_t *, const char *);
368*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvlist_t *fnvlist_lookup_nvlist(nvlist_t *, const char *);
369*3ff01b23SMartin Matuska _SYS_NVPAIR_H boolean_t *fnvlist_lookup_boolean_array(nvlist_t *, const char *,
370*3ff01b23SMartin Matuska     uint_t *);
371*3ff01b23SMartin Matuska _SYS_NVPAIR_H uchar_t *fnvlist_lookup_byte_array(nvlist_t *, const char *,
372*3ff01b23SMartin Matuska     uint_t *);
373*3ff01b23SMartin Matuska _SYS_NVPAIR_H int8_t *fnvlist_lookup_int8_array(nvlist_t *, const char *,
374*3ff01b23SMartin Matuska     uint_t *);
375*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint8_t *fnvlist_lookup_uint8_array(nvlist_t *, const char *,
376*3ff01b23SMartin Matuska     uint_t *);
377*3ff01b23SMartin Matuska _SYS_NVPAIR_H int16_t *fnvlist_lookup_int16_array(nvlist_t *, const char *,
378*3ff01b23SMartin Matuska     uint_t *);
379*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint16_t *fnvlist_lookup_uint16_array(nvlist_t *, const char *,
380*3ff01b23SMartin Matuska     uint_t *);
381*3ff01b23SMartin Matuska _SYS_NVPAIR_H int32_t *fnvlist_lookup_int32_array(nvlist_t *, const char *,
382*3ff01b23SMartin Matuska     uint_t *);
383*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint32_t *fnvlist_lookup_uint32_array(nvlist_t *, const char *,
384*3ff01b23SMartin Matuska     uint_t *);
385*3ff01b23SMartin Matuska _SYS_NVPAIR_H int64_t *fnvlist_lookup_int64_array(nvlist_t *, const char *,
386*3ff01b23SMartin Matuska     uint_t *);
387*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint64_t *fnvlist_lookup_uint64_array(nvlist_t *, const char *,
388*3ff01b23SMartin Matuska     uint_t *);
389eda14cbcSMatt Macy 
390*3ff01b23SMartin Matuska _SYS_NVPAIR_H boolean_t fnvpair_value_boolean_value(nvpair_t *nvp);
391*3ff01b23SMartin Matuska _SYS_NVPAIR_H uchar_t fnvpair_value_byte(nvpair_t *nvp);
392*3ff01b23SMartin Matuska _SYS_NVPAIR_H int8_t fnvpair_value_int8(nvpair_t *nvp);
393*3ff01b23SMartin Matuska _SYS_NVPAIR_H int16_t fnvpair_value_int16(nvpair_t *nvp);
394*3ff01b23SMartin Matuska _SYS_NVPAIR_H int32_t fnvpair_value_int32(nvpair_t *nvp);
395*3ff01b23SMartin Matuska _SYS_NVPAIR_H int64_t fnvpair_value_int64(nvpair_t *nvp);
396*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint8_t fnvpair_value_uint8(nvpair_t *nvp);
397*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint16_t fnvpair_value_uint16(nvpair_t *nvp);
398*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint32_t fnvpair_value_uint32(nvpair_t *nvp);
399*3ff01b23SMartin Matuska _SYS_NVPAIR_H uint64_t fnvpair_value_uint64(nvpair_t *nvp);
400*3ff01b23SMartin Matuska _SYS_NVPAIR_H char *fnvpair_value_string(nvpair_t *nvp);
401*3ff01b23SMartin Matuska _SYS_NVPAIR_H nvlist_t *fnvpair_value_nvlist(nvpair_t *nvp);
402eda14cbcSMatt Macy 
403eda14cbcSMatt Macy #ifdef	__cplusplus
404eda14cbcSMatt Macy }
405eda14cbcSMatt Macy #endif
406eda14cbcSMatt Macy 
407eda14cbcSMatt Macy #endif	/* _SYS_NVPAIR_H */
408