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