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
9271171e0SMartin Matuska * or https://opensource.org/licenses/CDDL-1.0.
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 /*
23eda14cbcSMatt Macy * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24eda14cbcSMatt Macy */
25eda14cbcSMatt Macy
26eda14cbcSMatt Macy #include <sys/nvpair.h>
27eda14cbcSMatt Macy #include <sys/kmem.h>
28eda14cbcSMatt Macy #include <sys/debug.h>
29eda14cbcSMatt Macy #include <sys/param.h>
30eda14cbcSMatt Macy #ifndef _KERNEL
31eda14cbcSMatt Macy #include <stdlib.h>
32eda14cbcSMatt Macy #endif
33eda14cbcSMatt Macy
34eda14cbcSMatt Macy /*
35eda14cbcSMatt Macy * "Force" nvlist wrapper.
36eda14cbcSMatt Macy *
37eda14cbcSMatt Macy * These functions wrap the nvlist_* functions with assertions that assume
38eda14cbcSMatt Macy * the operation is successful. This allows the caller's code to be much
39eda14cbcSMatt Macy * more readable, especially for the fnvlist_lookup_* and fnvpair_value_*
40eda14cbcSMatt Macy * functions, which can return the requested value (rather than filling in
41eda14cbcSMatt Macy * a pointer).
42eda14cbcSMatt Macy *
43eda14cbcSMatt Macy * These functions use NV_UNIQUE_NAME, encoding NV_ENCODE_NATIVE, and allocate
44eda14cbcSMatt Macy * with KM_SLEEP.
45eda14cbcSMatt Macy *
46eda14cbcSMatt Macy * More wrappers should be added as needed -- for example
47eda14cbcSMatt Macy * nvlist_lookup_*_array and nvpair_value_*_array.
48eda14cbcSMatt Macy */
49eda14cbcSMatt Macy
50eda14cbcSMatt Macy nvlist_t *
fnvlist_alloc(void)51eda14cbcSMatt Macy fnvlist_alloc(void)
52eda14cbcSMatt Macy {
53eda14cbcSMatt Macy nvlist_t *nvl;
54eda14cbcSMatt Macy VERIFY0(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP));
55eda14cbcSMatt Macy return (nvl);
56eda14cbcSMatt Macy }
57eda14cbcSMatt Macy
58eda14cbcSMatt Macy void
fnvlist_free(nvlist_t * nvl)59eda14cbcSMatt Macy fnvlist_free(nvlist_t *nvl)
60eda14cbcSMatt Macy {
61eda14cbcSMatt Macy nvlist_free(nvl);
62eda14cbcSMatt Macy }
63eda14cbcSMatt Macy
64eda14cbcSMatt Macy size_t
fnvlist_size(nvlist_t * nvl)65eda14cbcSMatt Macy fnvlist_size(nvlist_t *nvl)
66eda14cbcSMatt Macy {
67eda14cbcSMatt Macy size_t size;
68eda14cbcSMatt Macy VERIFY0(nvlist_size(nvl, &size, NV_ENCODE_NATIVE));
69eda14cbcSMatt Macy return (size);
70eda14cbcSMatt Macy }
71eda14cbcSMatt Macy
72eda14cbcSMatt Macy /*
73eda14cbcSMatt Macy * Returns allocated buffer of size *sizep. Caller must free the buffer with
74eda14cbcSMatt Macy * fnvlist_pack_free().
75eda14cbcSMatt Macy */
76eda14cbcSMatt Macy char *
fnvlist_pack(nvlist_t * nvl,size_t * sizep)77eda14cbcSMatt Macy fnvlist_pack(nvlist_t *nvl, size_t *sizep)
78eda14cbcSMatt Macy {
79eda14cbcSMatt Macy char *packed = 0;
80eda14cbcSMatt Macy VERIFY3U(nvlist_pack(nvl, &packed, sizep, NV_ENCODE_NATIVE,
81eda14cbcSMatt Macy KM_SLEEP), ==, 0);
82eda14cbcSMatt Macy return (packed);
83eda14cbcSMatt Macy }
84eda14cbcSMatt Macy
85eda14cbcSMatt Macy void
fnvlist_pack_free(char * pack,size_t size)86eda14cbcSMatt Macy fnvlist_pack_free(char *pack, size_t size)
87eda14cbcSMatt Macy {
88eda14cbcSMatt Macy #ifdef _KERNEL
89eda14cbcSMatt Macy kmem_free(pack, size);
90eda14cbcSMatt Macy #else
91e92ffd9bSMartin Matuska (void) size;
92eda14cbcSMatt Macy free(pack);
93eda14cbcSMatt Macy #endif
94eda14cbcSMatt Macy }
95eda14cbcSMatt Macy
96eda14cbcSMatt Macy nvlist_t *
fnvlist_unpack(char * buf,size_t buflen)97eda14cbcSMatt Macy fnvlist_unpack(char *buf, size_t buflen)
98eda14cbcSMatt Macy {
99eda14cbcSMatt Macy nvlist_t *rv;
100eda14cbcSMatt Macy VERIFY0(nvlist_unpack(buf, buflen, &rv, KM_SLEEP));
101eda14cbcSMatt Macy return (rv);
102eda14cbcSMatt Macy }
103eda14cbcSMatt Macy
104eda14cbcSMatt Macy nvlist_t *
fnvlist_dup(const nvlist_t * nvl)105681ce946SMartin Matuska fnvlist_dup(const nvlist_t *nvl)
106eda14cbcSMatt Macy {
107eda14cbcSMatt Macy nvlist_t *rv;
108eda14cbcSMatt Macy VERIFY0(nvlist_dup(nvl, &rv, KM_SLEEP));
109eda14cbcSMatt Macy return (rv);
110eda14cbcSMatt Macy }
111eda14cbcSMatt Macy
112eda14cbcSMatt Macy void
fnvlist_merge(nvlist_t * dst,nvlist_t * src)113eda14cbcSMatt Macy fnvlist_merge(nvlist_t *dst, nvlist_t *src)
114eda14cbcSMatt Macy {
115eda14cbcSMatt Macy VERIFY0(nvlist_merge(dst, src, KM_SLEEP));
116eda14cbcSMatt Macy }
117eda14cbcSMatt Macy
118eda14cbcSMatt Macy size_t
fnvlist_num_pairs(nvlist_t * nvl)119eda14cbcSMatt Macy fnvlist_num_pairs(nvlist_t *nvl)
120eda14cbcSMatt Macy {
121eda14cbcSMatt Macy size_t count = 0;
122eda14cbcSMatt Macy nvpair_t *pair;
123eda14cbcSMatt Macy
124eda14cbcSMatt Macy for (pair = nvlist_next_nvpair(nvl, 0); pair != NULL;
125eda14cbcSMatt Macy pair = nvlist_next_nvpair(nvl, pair))
126eda14cbcSMatt Macy count++;
127eda14cbcSMatt Macy return (count);
128eda14cbcSMatt Macy }
129eda14cbcSMatt Macy
130eda14cbcSMatt Macy void
fnvlist_add_boolean(nvlist_t * nvl,const char * name)131eda14cbcSMatt Macy fnvlist_add_boolean(nvlist_t *nvl, const char *name)
132eda14cbcSMatt Macy {
133eda14cbcSMatt Macy VERIFY0(nvlist_add_boolean(nvl, name));
134eda14cbcSMatt Macy }
135eda14cbcSMatt Macy
136eda14cbcSMatt Macy void
fnvlist_add_boolean_value(nvlist_t * nvl,const char * name,boolean_t val)137eda14cbcSMatt Macy fnvlist_add_boolean_value(nvlist_t *nvl, const char *name, boolean_t val)
138eda14cbcSMatt Macy {
139eda14cbcSMatt Macy VERIFY0(nvlist_add_boolean_value(nvl, name, val));
140eda14cbcSMatt Macy }
141eda14cbcSMatt Macy
142eda14cbcSMatt Macy void
fnvlist_add_byte(nvlist_t * nvl,const char * name,uchar_t val)143eda14cbcSMatt Macy fnvlist_add_byte(nvlist_t *nvl, const char *name, uchar_t val)
144eda14cbcSMatt Macy {
145eda14cbcSMatt Macy VERIFY0(nvlist_add_byte(nvl, name, val));
146eda14cbcSMatt Macy }
147eda14cbcSMatt Macy
148eda14cbcSMatt Macy void
fnvlist_add_int8(nvlist_t * nvl,const char * name,int8_t val)149eda14cbcSMatt Macy fnvlist_add_int8(nvlist_t *nvl, const char *name, int8_t val)
150eda14cbcSMatt Macy {
151eda14cbcSMatt Macy VERIFY0(nvlist_add_int8(nvl, name, val));
152eda14cbcSMatt Macy }
153eda14cbcSMatt Macy
154eda14cbcSMatt Macy void
fnvlist_add_uint8(nvlist_t * nvl,const char * name,uint8_t val)155eda14cbcSMatt Macy fnvlist_add_uint8(nvlist_t *nvl, const char *name, uint8_t val)
156eda14cbcSMatt Macy {
157eda14cbcSMatt Macy VERIFY0(nvlist_add_uint8(nvl, name, val));
158eda14cbcSMatt Macy }
159eda14cbcSMatt Macy
160eda14cbcSMatt Macy void
fnvlist_add_int16(nvlist_t * nvl,const char * name,int16_t val)161eda14cbcSMatt Macy fnvlist_add_int16(nvlist_t *nvl, const char *name, int16_t val)
162eda14cbcSMatt Macy {
163eda14cbcSMatt Macy VERIFY0(nvlist_add_int16(nvl, name, val));
164eda14cbcSMatt Macy }
165eda14cbcSMatt Macy
166eda14cbcSMatt Macy void
fnvlist_add_uint16(nvlist_t * nvl,const char * name,uint16_t val)167eda14cbcSMatt Macy fnvlist_add_uint16(nvlist_t *nvl, const char *name, uint16_t val)
168eda14cbcSMatt Macy {
169eda14cbcSMatt Macy VERIFY0(nvlist_add_uint16(nvl, name, val));
170eda14cbcSMatt Macy }
171eda14cbcSMatt Macy
172eda14cbcSMatt Macy void
fnvlist_add_int32(nvlist_t * nvl,const char * name,int32_t val)173eda14cbcSMatt Macy fnvlist_add_int32(nvlist_t *nvl, const char *name, int32_t val)
174eda14cbcSMatt Macy {
175eda14cbcSMatt Macy VERIFY0(nvlist_add_int32(nvl, name, val));
176eda14cbcSMatt Macy }
177eda14cbcSMatt Macy
178eda14cbcSMatt Macy void
fnvlist_add_uint32(nvlist_t * nvl,const char * name,uint32_t val)179eda14cbcSMatt Macy fnvlist_add_uint32(nvlist_t *nvl, const char *name, uint32_t val)
180eda14cbcSMatt Macy {
181eda14cbcSMatt Macy VERIFY0(nvlist_add_uint32(nvl, name, val));
182eda14cbcSMatt Macy }
183eda14cbcSMatt Macy
184eda14cbcSMatt Macy void
fnvlist_add_int64(nvlist_t * nvl,const char * name,int64_t val)185eda14cbcSMatt Macy fnvlist_add_int64(nvlist_t *nvl, const char *name, int64_t val)
186eda14cbcSMatt Macy {
187eda14cbcSMatt Macy VERIFY0(nvlist_add_int64(nvl, name, val));
188eda14cbcSMatt Macy }
189eda14cbcSMatt Macy
190eda14cbcSMatt Macy void
fnvlist_add_uint64(nvlist_t * nvl,const char * name,uint64_t val)191eda14cbcSMatt Macy fnvlist_add_uint64(nvlist_t *nvl, const char *name, uint64_t val)
192eda14cbcSMatt Macy {
193eda14cbcSMatt Macy VERIFY0(nvlist_add_uint64(nvl, name, val));
194eda14cbcSMatt Macy }
195eda14cbcSMatt Macy
196eda14cbcSMatt Macy void
fnvlist_add_string(nvlist_t * nvl,const char * name,const char * val)197eda14cbcSMatt Macy fnvlist_add_string(nvlist_t *nvl, const char *name, const char *val)
198eda14cbcSMatt Macy {
199eda14cbcSMatt Macy VERIFY0(nvlist_add_string(nvl, name, val));
200eda14cbcSMatt Macy }
201eda14cbcSMatt Macy
202eda14cbcSMatt Macy void
fnvlist_add_nvlist(nvlist_t * nvl,const char * name,nvlist_t * val)203eda14cbcSMatt Macy fnvlist_add_nvlist(nvlist_t *nvl, const char *name, nvlist_t *val)
204eda14cbcSMatt Macy {
205eda14cbcSMatt Macy VERIFY0(nvlist_add_nvlist(nvl, name, val));
206eda14cbcSMatt Macy }
207eda14cbcSMatt Macy
208eda14cbcSMatt Macy void
fnvlist_add_nvpair(nvlist_t * nvl,nvpair_t * pair)209eda14cbcSMatt Macy fnvlist_add_nvpair(nvlist_t *nvl, nvpair_t *pair)
210eda14cbcSMatt Macy {
211eda14cbcSMatt Macy VERIFY0(nvlist_add_nvpair(nvl, pair));
212eda14cbcSMatt Macy }
213eda14cbcSMatt Macy
214eda14cbcSMatt Macy void
fnvlist_add_boolean_array(nvlist_t * nvl,const char * name,const boolean_t * val,uint_t n)215eda14cbcSMatt Macy fnvlist_add_boolean_array(nvlist_t *nvl, const char *name,
216681ce946SMartin Matuska const boolean_t *val, uint_t n)
217eda14cbcSMatt Macy {
218eda14cbcSMatt Macy VERIFY0(nvlist_add_boolean_array(nvl, name, val, n));
219eda14cbcSMatt Macy }
220eda14cbcSMatt Macy
221eda14cbcSMatt Macy void
fnvlist_add_byte_array(nvlist_t * nvl,const char * name,const uchar_t * val,uint_t n)222681ce946SMartin Matuska fnvlist_add_byte_array(nvlist_t *nvl, const char *name, const uchar_t *val,
223681ce946SMartin Matuska uint_t n)
224eda14cbcSMatt Macy {
225eda14cbcSMatt Macy VERIFY0(nvlist_add_byte_array(nvl, name, val, n));
226eda14cbcSMatt Macy }
227eda14cbcSMatt Macy
228eda14cbcSMatt Macy void
fnvlist_add_int8_array(nvlist_t * nvl,const char * name,const int8_t * val,uint_t n)229681ce946SMartin Matuska fnvlist_add_int8_array(nvlist_t *nvl, const char *name, const int8_t *val,
230681ce946SMartin Matuska uint_t n)
231eda14cbcSMatt Macy {
232eda14cbcSMatt Macy VERIFY0(nvlist_add_int8_array(nvl, name, val, n));
233eda14cbcSMatt Macy }
234eda14cbcSMatt Macy
235eda14cbcSMatt Macy void
fnvlist_add_uint8_array(nvlist_t * nvl,const char * name,const uint8_t * val,uint_t n)236681ce946SMartin Matuska fnvlist_add_uint8_array(nvlist_t *nvl, const char *name, const uint8_t *val,
237681ce946SMartin Matuska uint_t n)
238eda14cbcSMatt Macy {
239eda14cbcSMatt Macy VERIFY0(nvlist_add_uint8_array(nvl, name, val, n));
240eda14cbcSMatt Macy }
241eda14cbcSMatt Macy
242eda14cbcSMatt Macy void
fnvlist_add_int16_array(nvlist_t * nvl,const char * name,const int16_t * val,uint_t n)243681ce946SMartin Matuska fnvlist_add_int16_array(nvlist_t *nvl, const char *name, const int16_t *val,
244681ce946SMartin Matuska uint_t n)
245eda14cbcSMatt Macy {
246eda14cbcSMatt Macy VERIFY0(nvlist_add_int16_array(nvl, name, val, n));
247eda14cbcSMatt Macy }
248eda14cbcSMatt Macy
249eda14cbcSMatt Macy void
fnvlist_add_uint16_array(nvlist_t * nvl,const char * name,const uint16_t * val,uint_t n)250eda14cbcSMatt Macy fnvlist_add_uint16_array(nvlist_t *nvl, const char *name,
251681ce946SMartin Matuska const uint16_t *val, uint_t n)
252eda14cbcSMatt Macy {
253eda14cbcSMatt Macy VERIFY0(nvlist_add_uint16_array(nvl, name, val, n));
254eda14cbcSMatt Macy }
255eda14cbcSMatt Macy
256eda14cbcSMatt Macy void
fnvlist_add_int32_array(nvlist_t * nvl,const char * name,const int32_t * val,uint_t n)257681ce946SMartin Matuska fnvlist_add_int32_array(nvlist_t *nvl, const char *name, const int32_t *val,
258681ce946SMartin Matuska uint_t n)
259eda14cbcSMatt Macy {
260eda14cbcSMatt Macy VERIFY0(nvlist_add_int32_array(nvl, name, val, n));
261eda14cbcSMatt Macy }
262eda14cbcSMatt Macy
263eda14cbcSMatt Macy void
fnvlist_add_uint32_array(nvlist_t * nvl,const char * name,const uint32_t * val,uint_t n)264eda14cbcSMatt Macy fnvlist_add_uint32_array(nvlist_t *nvl, const char *name,
265681ce946SMartin Matuska const uint32_t *val, uint_t n)
266eda14cbcSMatt Macy {
267eda14cbcSMatt Macy VERIFY0(nvlist_add_uint32_array(nvl, name, val, n));
268eda14cbcSMatt Macy }
269eda14cbcSMatt Macy
270eda14cbcSMatt Macy void
fnvlist_add_int64_array(nvlist_t * nvl,const char * name,const int64_t * val,uint_t n)271681ce946SMartin Matuska fnvlist_add_int64_array(nvlist_t *nvl, const char *name, const int64_t *val,
272681ce946SMartin Matuska uint_t n)
273eda14cbcSMatt Macy {
274eda14cbcSMatt Macy VERIFY0(nvlist_add_int64_array(nvl, name, val, n));
275eda14cbcSMatt Macy }
276eda14cbcSMatt Macy
277eda14cbcSMatt Macy void
fnvlist_add_uint64_array(nvlist_t * nvl,const char * name,const uint64_t * val,uint_t n)278eda14cbcSMatt Macy fnvlist_add_uint64_array(nvlist_t *nvl, const char *name,
279681ce946SMartin Matuska const uint64_t *val, uint_t n)
280eda14cbcSMatt Macy {
281eda14cbcSMatt Macy VERIFY0(nvlist_add_uint64_array(nvl, name, val, n));
282eda14cbcSMatt Macy }
283eda14cbcSMatt Macy
284eda14cbcSMatt Macy void
fnvlist_add_string_array(nvlist_t * nvl,const char * name,const char * const * val,uint_t n)285eda14cbcSMatt Macy fnvlist_add_string_array(nvlist_t *nvl, const char *name,
286681ce946SMartin Matuska const char * const *val, uint_t n)
287eda14cbcSMatt Macy {
288eda14cbcSMatt Macy VERIFY0(nvlist_add_string_array(nvl, name, val, n));
289eda14cbcSMatt Macy }
290eda14cbcSMatt Macy
291eda14cbcSMatt Macy void
fnvlist_add_nvlist_array(nvlist_t * nvl,const char * name,const nvlist_t * const * val,uint_t n)292eda14cbcSMatt Macy fnvlist_add_nvlist_array(nvlist_t *nvl, const char *name,
293681ce946SMartin Matuska const nvlist_t * const *val, uint_t n)
294eda14cbcSMatt Macy {
295eda14cbcSMatt Macy VERIFY0(nvlist_add_nvlist_array(nvl, name, val, n));
296eda14cbcSMatt Macy }
297eda14cbcSMatt Macy
298eda14cbcSMatt Macy void
fnvlist_remove(nvlist_t * nvl,const char * name)299eda14cbcSMatt Macy fnvlist_remove(nvlist_t *nvl, const char *name)
300eda14cbcSMatt Macy {
301eda14cbcSMatt Macy VERIFY0(nvlist_remove_all(nvl, name));
302eda14cbcSMatt Macy }
303eda14cbcSMatt Macy
304eda14cbcSMatt Macy void
fnvlist_remove_nvpair(nvlist_t * nvl,nvpair_t * pair)305eda14cbcSMatt Macy fnvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *pair)
306eda14cbcSMatt Macy {
307eda14cbcSMatt Macy VERIFY0(nvlist_remove_nvpair(nvl, pair));
308eda14cbcSMatt Macy }
309eda14cbcSMatt Macy
310eda14cbcSMatt Macy nvpair_t *
fnvlist_lookup_nvpair(nvlist_t * nvl,const char * name)311eda14cbcSMatt Macy fnvlist_lookup_nvpair(nvlist_t *nvl, const char *name)
312eda14cbcSMatt Macy {
313eda14cbcSMatt Macy nvpair_t *rv;
314eda14cbcSMatt Macy VERIFY0(nvlist_lookup_nvpair(nvl, name, &rv));
315eda14cbcSMatt Macy return (rv);
316eda14cbcSMatt Macy }
317eda14cbcSMatt Macy
318eda14cbcSMatt Macy /* returns B_TRUE if the entry exists */
319eda14cbcSMatt Macy boolean_t
fnvlist_lookup_boolean(const nvlist_t * nvl,const char * name)320681ce946SMartin Matuska fnvlist_lookup_boolean(const nvlist_t *nvl, const char *name)
321eda14cbcSMatt Macy {
322eda14cbcSMatt Macy return (nvlist_lookup_boolean(nvl, name) == 0);
323eda14cbcSMatt Macy }
324eda14cbcSMatt Macy
325eda14cbcSMatt Macy boolean_t
fnvlist_lookup_boolean_value(const nvlist_t * nvl,const char * name)326681ce946SMartin Matuska fnvlist_lookup_boolean_value(const nvlist_t *nvl, const char *name)
327eda14cbcSMatt Macy {
328eda14cbcSMatt Macy boolean_t rv;
329eda14cbcSMatt Macy VERIFY0(nvlist_lookup_boolean_value(nvl, name, &rv));
330eda14cbcSMatt Macy return (rv);
331eda14cbcSMatt Macy }
332eda14cbcSMatt Macy
333eda14cbcSMatt Macy uchar_t
fnvlist_lookup_byte(const nvlist_t * nvl,const char * name)334681ce946SMartin Matuska fnvlist_lookup_byte(const nvlist_t *nvl, const char *name)
335eda14cbcSMatt Macy {
336eda14cbcSMatt Macy uchar_t rv;
337eda14cbcSMatt Macy VERIFY0(nvlist_lookup_byte(nvl, name, &rv));
338eda14cbcSMatt Macy return (rv);
339eda14cbcSMatt Macy }
340eda14cbcSMatt Macy
341eda14cbcSMatt Macy int8_t
fnvlist_lookup_int8(const nvlist_t * nvl,const char * name)342681ce946SMartin Matuska fnvlist_lookup_int8(const nvlist_t *nvl, const char *name)
343eda14cbcSMatt Macy {
344eda14cbcSMatt Macy int8_t rv;
345eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int8(nvl, name, &rv));
346eda14cbcSMatt Macy return (rv);
347eda14cbcSMatt Macy }
348eda14cbcSMatt Macy
349eda14cbcSMatt Macy int16_t
fnvlist_lookup_int16(const nvlist_t * nvl,const char * name)350681ce946SMartin Matuska fnvlist_lookup_int16(const nvlist_t *nvl, const char *name)
351eda14cbcSMatt Macy {
352eda14cbcSMatt Macy int16_t rv;
353eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int16(nvl, name, &rv));
354eda14cbcSMatt Macy return (rv);
355eda14cbcSMatt Macy }
356eda14cbcSMatt Macy
357eda14cbcSMatt Macy int32_t
fnvlist_lookup_int32(const nvlist_t * nvl,const char * name)358681ce946SMartin Matuska fnvlist_lookup_int32(const nvlist_t *nvl, const char *name)
359eda14cbcSMatt Macy {
360eda14cbcSMatt Macy int32_t rv;
361eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int32(nvl, name, &rv));
362eda14cbcSMatt Macy return (rv);
363eda14cbcSMatt Macy }
364eda14cbcSMatt Macy
365eda14cbcSMatt Macy int64_t
fnvlist_lookup_int64(const nvlist_t * nvl,const char * name)366681ce946SMartin Matuska fnvlist_lookup_int64(const nvlist_t *nvl, const char *name)
367eda14cbcSMatt Macy {
368eda14cbcSMatt Macy int64_t rv;
369eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int64(nvl, name, &rv));
370eda14cbcSMatt Macy return (rv);
371eda14cbcSMatt Macy }
372eda14cbcSMatt Macy
373eda14cbcSMatt Macy uint8_t
fnvlist_lookup_uint8(const nvlist_t * nvl,const char * name)374681ce946SMartin Matuska fnvlist_lookup_uint8(const nvlist_t *nvl, const char *name)
375eda14cbcSMatt Macy {
376eda14cbcSMatt Macy uint8_t rv;
377eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint8(nvl, name, &rv));
378eda14cbcSMatt Macy return (rv);
379eda14cbcSMatt Macy }
380eda14cbcSMatt Macy
381eda14cbcSMatt Macy uint16_t
fnvlist_lookup_uint16(const nvlist_t * nvl,const char * name)382681ce946SMartin Matuska fnvlist_lookup_uint16(const nvlist_t *nvl, const char *name)
383eda14cbcSMatt Macy {
384eda14cbcSMatt Macy uint16_t rv;
385eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint16(nvl, name, &rv));
386eda14cbcSMatt Macy return (rv);
387eda14cbcSMatt Macy }
388eda14cbcSMatt Macy
389eda14cbcSMatt Macy uint32_t
fnvlist_lookup_uint32(const nvlist_t * nvl,const char * name)390681ce946SMartin Matuska fnvlist_lookup_uint32(const nvlist_t *nvl, const char *name)
391eda14cbcSMatt Macy {
392eda14cbcSMatt Macy uint32_t rv;
393eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint32(nvl, name, &rv));
394eda14cbcSMatt Macy return (rv);
395eda14cbcSMatt Macy }
396eda14cbcSMatt Macy
397eda14cbcSMatt Macy uint64_t
fnvlist_lookup_uint64(const nvlist_t * nvl,const char * name)398681ce946SMartin Matuska fnvlist_lookup_uint64(const nvlist_t *nvl, const char *name)
399eda14cbcSMatt Macy {
400eda14cbcSMatt Macy uint64_t rv;
401eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint64(nvl, name, &rv));
402eda14cbcSMatt Macy return (rv);
403eda14cbcSMatt Macy }
404eda14cbcSMatt Macy
405*2a58b312SMartin Matuska const char *
fnvlist_lookup_string(const nvlist_t * nvl,const char * name)406*2a58b312SMartin Matuska fnvlist_lookup_string(const nvlist_t *nvl, const char *name)
407eda14cbcSMatt Macy {
408*2a58b312SMartin Matuska const char *rv;
409eda14cbcSMatt Macy VERIFY0(nvlist_lookup_string(nvl, name, &rv));
410eda14cbcSMatt Macy return (rv);
411eda14cbcSMatt Macy }
412eda14cbcSMatt Macy
413eda14cbcSMatt Macy nvlist_t *
fnvlist_lookup_nvlist(nvlist_t * nvl,const char * name)414eda14cbcSMatt Macy fnvlist_lookup_nvlist(nvlist_t *nvl, const char *name)
415eda14cbcSMatt Macy {
416eda14cbcSMatt Macy nvlist_t *rv;
417eda14cbcSMatt Macy VERIFY0(nvlist_lookup_nvlist(nvl, name, &rv));
418eda14cbcSMatt Macy return (rv);
419eda14cbcSMatt Macy }
420eda14cbcSMatt Macy boolean_t *
fnvlist_lookup_boolean_array(nvlist_t * nvl,const char * name,uint_t * n)421eda14cbcSMatt Macy fnvlist_lookup_boolean_array(nvlist_t *nvl, const char *name, uint_t *n)
422eda14cbcSMatt Macy {
423eda14cbcSMatt Macy boolean_t *rv;
424eda14cbcSMatt Macy VERIFY0(nvlist_lookup_boolean_array(nvl, name, &rv, n));
425eda14cbcSMatt Macy return (rv);
426eda14cbcSMatt Macy }
427eda14cbcSMatt Macy
428eda14cbcSMatt Macy uchar_t *
fnvlist_lookup_byte_array(nvlist_t * nvl,const char * name,uint_t * n)429eda14cbcSMatt Macy fnvlist_lookup_byte_array(nvlist_t *nvl, const char *name, uint_t *n)
430eda14cbcSMatt Macy {
431eda14cbcSMatt Macy uchar_t *rv;
432eda14cbcSMatt Macy VERIFY0(nvlist_lookup_byte_array(nvl, name, &rv, n));
433eda14cbcSMatt Macy return (rv);
434eda14cbcSMatt Macy }
435eda14cbcSMatt Macy
436eda14cbcSMatt Macy int8_t *
fnvlist_lookup_int8_array(nvlist_t * nvl,const char * name,uint_t * n)437eda14cbcSMatt Macy fnvlist_lookup_int8_array(nvlist_t *nvl, const char *name, uint_t *n)
438eda14cbcSMatt Macy {
439eda14cbcSMatt Macy int8_t *rv;
440eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int8_array(nvl, name, &rv, n));
441eda14cbcSMatt Macy return (rv);
442eda14cbcSMatt Macy }
443eda14cbcSMatt Macy
444eda14cbcSMatt Macy uint8_t *
fnvlist_lookup_uint8_array(nvlist_t * nvl,const char * name,uint_t * n)445eda14cbcSMatt Macy fnvlist_lookup_uint8_array(nvlist_t *nvl, const char *name, uint_t *n)
446eda14cbcSMatt Macy {
447eda14cbcSMatt Macy uint8_t *rv;
448eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint8_array(nvl, name, &rv, n));
449eda14cbcSMatt Macy return (rv);
450eda14cbcSMatt Macy }
451eda14cbcSMatt Macy
452eda14cbcSMatt Macy int16_t *
fnvlist_lookup_int16_array(nvlist_t * nvl,const char * name,uint_t * n)453eda14cbcSMatt Macy fnvlist_lookup_int16_array(nvlist_t *nvl, const char *name, uint_t *n)
454eda14cbcSMatt Macy {
455eda14cbcSMatt Macy int16_t *rv;
456eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int16_array(nvl, name, &rv, n));
457eda14cbcSMatt Macy return (rv);
458eda14cbcSMatt Macy }
459eda14cbcSMatt Macy
460eda14cbcSMatt Macy uint16_t *
fnvlist_lookup_uint16_array(nvlist_t * nvl,const char * name,uint_t * n)461eda14cbcSMatt Macy fnvlist_lookup_uint16_array(nvlist_t *nvl, const char *name, uint_t *n)
462eda14cbcSMatt Macy {
463eda14cbcSMatt Macy uint16_t *rv;
464eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint16_array(nvl, name, &rv, n));
465eda14cbcSMatt Macy return (rv);
466eda14cbcSMatt Macy }
467eda14cbcSMatt Macy
468eda14cbcSMatt Macy int32_t *
fnvlist_lookup_int32_array(nvlist_t * nvl,const char * name,uint_t * n)469eda14cbcSMatt Macy fnvlist_lookup_int32_array(nvlist_t *nvl, const char *name, uint_t *n)
470eda14cbcSMatt Macy {
471eda14cbcSMatt Macy int32_t *rv;
472eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int32_array(nvl, name, &rv, n));
473eda14cbcSMatt Macy return (rv);
474eda14cbcSMatt Macy }
475eda14cbcSMatt Macy
476eda14cbcSMatt Macy uint32_t *
fnvlist_lookup_uint32_array(nvlist_t * nvl,const char * name,uint_t * n)477eda14cbcSMatt Macy fnvlist_lookup_uint32_array(nvlist_t *nvl, const char *name, uint_t *n)
478eda14cbcSMatt Macy {
479eda14cbcSMatt Macy uint32_t *rv;
480eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint32_array(nvl, name, &rv, n));
481eda14cbcSMatt Macy return (rv);
482eda14cbcSMatt Macy }
483eda14cbcSMatt Macy
484eda14cbcSMatt Macy int64_t *
fnvlist_lookup_int64_array(nvlist_t * nvl,const char * name,uint_t * n)485eda14cbcSMatt Macy fnvlist_lookup_int64_array(nvlist_t *nvl, const char *name, uint_t *n)
486eda14cbcSMatt Macy {
487eda14cbcSMatt Macy int64_t *rv;
488eda14cbcSMatt Macy VERIFY0(nvlist_lookup_int64_array(nvl, name, &rv, n));
489eda14cbcSMatt Macy return (rv);
490eda14cbcSMatt Macy }
491eda14cbcSMatt Macy
492eda14cbcSMatt Macy uint64_t *
fnvlist_lookup_uint64_array(nvlist_t * nvl,const char * name,uint_t * n)493eda14cbcSMatt Macy fnvlist_lookup_uint64_array(nvlist_t *nvl, const char *name, uint_t *n)
494eda14cbcSMatt Macy {
495eda14cbcSMatt Macy uint64_t *rv;
496eda14cbcSMatt Macy VERIFY0(nvlist_lookup_uint64_array(nvl, name, &rv, n));
497eda14cbcSMatt Macy return (rv);
498eda14cbcSMatt Macy }
499eda14cbcSMatt Macy
500eda14cbcSMatt Macy boolean_t
fnvpair_value_boolean_value(const nvpair_t * nvp)501681ce946SMartin Matuska fnvpair_value_boolean_value(const nvpair_t *nvp)
502eda14cbcSMatt Macy {
503eda14cbcSMatt Macy boolean_t rv;
504eda14cbcSMatt Macy VERIFY0(nvpair_value_boolean_value(nvp, &rv));
505eda14cbcSMatt Macy return (rv);
506eda14cbcSMatt Macy }
507eda14cbcSMatt Macy
508eda14cbcSMatt Macy uchar_t
fnvpair_value_byte(const nvpair_t * nvp)509681ce946SMartin Matuska fnvpair_value_byte(const nvpair_t *nvp)
510eda14cbcSMatt Macy {
511eda14cbcSMatt Macy uchar_t rv;
512eda14cbcSMatt Macy VERIFY0(nvpair_value_byte(nvp, &rv));
513eda14cbcSMatt Macy return (rv);
514eda14cbcSMatt Macy }
515eda14cbcSMatt Macy
516eda14cbcSMatt Macy int8_t
fnvpair_value_int8(const nvpair_t * nvp)517681ce946SMartin Matuska fnvpair_value_int8(const nvpair_t *nvp)
518eda14cbcSMatt Macy {
519eda14cbcSMatt Macy int8_t rv;
520eda14cbcSMatt Macy VERIFY0(nvpair_value_int8(nvp, &rv));
521eda14cbcSMatt Macy return (rv);
522eda14cbcSMatt Macy }
523eda14cbcSMatt Macy
524eda14cbcSMatt Macy int16_t
fnvpair_value_int16(const nvpair_t * nvp)525681ce946SMartin Matuska fnvpair_value_int16(const nvpair_t *nvp)
526eda14cbcSMatt Macy {
527eda14cbcSMatt Macy int16_t rv;
528eda14cbcSMatt Macy VERIFY0(nvpair_value_int16(nvp, &rv));
529eda14cbcSMatt Macy return (rv);
530eda14cbcSMatt Macy }
531eda14cbcSMatt Macy
532eda14cbcSMatt Macy int32_t
fnvpair_value_int32(const nvpair_t * nvp)533681ce946SMartin Matuska fnvpair_value_int32(const nvpair_t *nvp)
534eda14cbcSMatt Macy {
535eda14cbcSMatt Macy int32_t rv;
536eda14cbcSMatt Macy VERIFY0(nvpair_value_int32(nvp, &rv));
537eda14cbcSMatt Macy return (rv);
538eda14cbcSMatt Macy }
539eda14cbcSMatt Macy
540eda14cbcSMatt Macy int64_t
fnvpair_value_int64(const nvpair_t * nvp)541681ce946SMartin Matuska fnvpair_value_int64(const nvpair_t *nvp)
542eda14cbcSMatt Macy {
543eda14cbcSMatt Macy int64_t rv;
544eda14cbcSMatt Macy VERIFY0(nvpair_value_int64(nvp, &rv));
545eda14cbcSMatt Macy return (rv);
546eda14cbcSMatt Macy }
547eda14cbcSMatt Macy
548eda14cbcSMatt Macy uint8_t
fnvpair_value_uint8(const nvpair_t * nvp)549681ce946SMartin Matuska fnvpair_value_uint8(const nvpair_t *nvp)
550eda14cbcSMatt Macy {
551eda14cbcSMatt Macy uint8_t rv;
552eda14cbcSMatt Macy VERIFY0(nvpair_value_uint8(nvp, &rv));
553eda14cbcSMatt Macy return (rv);
554eda14cbcSMatt Macy }
555eda14cbcSMatt Macy
556eda14cbcSMatt Macy uint16_t
fnvpair_value_uint16(const nvpair_t * nvp)557681ce946SMartin Matuska fnvpair_value_uint16(const nvpair_t *nvp)
558eda14cbcSMatt Macy {
559eda14cbcSMatt Macy uint16_t rv;
560eda14cbcSMatt Macy VERIFY0(nvpair_value_uint16(nvp, &rv));
561eda14cbcSMatt Macy return (rv);
562eda14cbcSMatt Macy }
563eda14cbcSMatt Macy
564eda14cbcSMatt Macy uint32_t
fnvpair_value_uint32(const nvpair_t * nvp)565681ce946SMartin Matuska fnvpair_value_uint32(const nvpair_t *nvp)
566eda14cbcSMatt Macy {
567eda14cbcSMatt Macy uint32_t rv;
568eda14cbcSMatt Macy VERIFY0(nvpair_value_uint32(nvp, &rv));
569eda14cbcSMatt Macy return (rv);
570eda14cbcSMatt Macy }
571eda14cbcSMatt Macy
572eda14cbcSMatt Macy uint64_t
fnvpair_value_uint64(const nvpair_t * nvp)573681ce946SMartin Matuska fnvpair_value_uint64(const nvpair_t *nvp)
574eda14cbcSMatt Macy {
575eda14cbcSMatt Macy uint64_t rv;
576eda14cbcSMatt Macy VERIFY0(nvpair_value_uint64(nvp, &rv));
577eda14cbcSMatt Macy return (rv);
578eda14cbcSMatt Macy }
579eda14cbcSMatt Macy
580*2a58b312SMartin Matuska const char *
fnvpair_value_string(const nvpair_t * nvp)581*2a58b312SMartin Matuska fnvpair_value_string(const nvpair_t *nvp)
582eda14cbcSMatt Macy {
583*2a58b312SMartin Matuska const char *rv;
584eda14cbcSMatt Macy VERIFY0(nvpair_value_string(nvp, &rv));
585eda14cbcSMatt Macy return (rv);
586eda14cbcSMatt Macy }
587eda14cbcSMatt Macy
588eda14cbcSMatt Macy nvlist_t *
fnvpair_value_nvlist(nvpair_t * nvp)589eda14cbcSMatt Macy fnvpair_value_nvlist(nvpair_t *nvp)
590eda14cbcSMatt Macy {
591eda14cbcSMatt Macy nvlist_t *rv;
592eda14cbcSMatt Macy VERIFY0(nvpair_value_nvlist(nvp, &rv));
593eda14cbcSMatt Macy return (rv);
594eda14cbcSMatt Macy }
595eda14cbcSMatt Macy
596eda14cbcSMatt Macy #if defined(_KERNEL)
597eda14cbcSMatt Macy
598eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_alloc);
599eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_free);
600eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_size);
601eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_pack);
602eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_pack_free);
603eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_unpack);
604eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_dup);
605eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_merge);
606eda14cbcSMatt Macy
607eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_nvpair);
608eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_boolean);
609eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_boolean_value);
610eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_byte);
611eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int8);
612eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint8);
613eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int16);
614eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint16);
615eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int32);
616eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint32);
617eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int64);
618eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint64);
619eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_string);
620eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_nvlist);
621eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_boolean_array);
622eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_byte_array);
623eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int8_array);
624eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint8_array);
625eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int16_array);
626eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint16_array);
627eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int32_array);
628eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint32_array);
629eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_int64_array);
630eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_uint64_array);
631eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_string_array);
632eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_add_nvlist_array);
633eda14cbcSMatt Macy
634eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_remove);
635eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_remove_nvpair);
636eda14cbcSMatt Macy
637eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_nvpair);
638eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_boolean);
639eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_boolean_value);
640eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_byte);
641eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_int8);
642eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_uint8);
643eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_int16);
644eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_uint16);
645eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_int32);
646eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_uint32);
647eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_int64);
648eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_uint64);
649eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_string);
650eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_lookup_nvlist);
651eda14cbcSMatt Macy
652eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_boolean_value);
653eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_byte);
654eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_int8);
655eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_uint8);
656eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_int16);
657eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_uint16);
658eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_int32);
659eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_uint32);
660eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_int64);
661eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_uint64);
662eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_string);
663eda14cbcSMatt Macy EXPORT_SYMBOL(fnvpair_value_nvlist);
664eda14cbcSMatt Macy EXPORT_SYMBOL(fnvlist_num_pairs);
665eda14cbcSMatt Macy
666eda14cbcSMatt Macy #endif
667