2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2009-2013 The FreeBSD Foundation
5 * Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
8 * This software was developed by Pawel Jakub Dawidek under sponsorship from
9 * the FreeBSD Foundation.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/endian.h>
38 #include <sys/queue.h>
42 #include <sys/errno.h>
43 #include <sys/kernel.h>
45 #include <sys/malloc.h>
46 #include <sys/systm.h>
48 #include <machine/stdarg.h>
51 #include <sys/socket.h>
72 #include "nvlist_impl.h"
73 #include "nvpair_impl.h"
77 #define PJDLOG_ASSERT(...) MPASS(__VA_ARGS__)
78 #define PJDLOG_RASSERT(expr, ...) KASSERT(expr, (__VA_ARGS__))
79 #define PJDLOG_ABORT(...) panic(__VA_ARGS__)
82 #define PJDLOG_ASSERT(...) assert(__VA_ARGS__)
83 #define PJDLOG_RASSERT(expr, ...) assert(expr)
84 #define PJDLOG_ABORT(...) do { \
85 fprintf(stderr, "%s:%u: ", __FILE__, __LINE__); \
86 fprintf(stderr, __VA_ARGS__); \
87 fprintf(stderr, "\n"); \
93 #define NV_FLAG_PRIVATE_MASK (NV_FLAG_BIG_ENDIAN | NV_FLAG_IN_ARRAY)
94 #define NV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE | NV_FLAG_NO_UNIQUE)
95 #define NV_FLAG_ALL_MASK (NV_FLAG_PRIVATE_MASK | NV_FLAG_PUBLIC_MASK)
97 #define NVLIST_MAGIC 0x6e766c /* "nvl" */
102 nvpair_t *nvl_parent;
103 nvpair_t *nvl_array_next;
104 struct nvl_head nvl_head;
107 #define NVLIST_ASSERT(nvl) do { \
108 PJDLOG_ASSERT((nvl) != NULL); \
109 PJDLOG_ASSERT((nvl)->nvl_magic == NVLIST_MAGIC); \
113 MALLOC_DEFINE(M_NVLIST, "nvlist", "kernel nvlist");
116 #define NVPAIR_ASSERT(nvp) nvpair_assert(nvp)
118 #define NVLIST_HEADER_MAGIC 0x6c
119 #define NVLIST_HEADER_VERSION 0x00
120 struct nvlist_header {
122 uint8_t nvlh_version;
124 uint64_t nvlh_descriptors;
129 nvlist_create(int flags)
133 PJDLOG_ASSERT((flags & ~(NV_FLAG_PUBLIC_MASK)) == 0);
135 nvl = nv_malloc(sizeof(*nvl));
139 nvl->nvl_flags = flags;
140 nvl->nvl_parent = NULL;
141 nvl->nvl_array_next = NULL;
142 TAILQ_INIT(&nvl->nvl_head);
143 nvl->nvl_magic = NVLIST_MAGIC;
149 nvlist_destroy(nvlist_t *nvl)
160 while ((nvp = nvlist_first_nvpair(nvl)) != NULL) {
161 nvlist_remove_nvpair(nvl, nvp);
164 if (nvl->nvl_array_next != NULL)
165 nvpair_free_structure(nvl->nvl_array_next);
166 nvl->nvl_array_next = NULL;
167 nvl->nvl_parent = NULL;
175 nvlist_set_error(nvlist_t *nvl, int error)
178 PJDLOG_ASSERT(error != 0);
181 * Check for error != 0 so that we don't do the wrong thing if somebody
182 * tries to abuse this API when asserts are disabled.
184 if (nvl != NULL && error != 0 && nvl->nvl_error == 0)
185 nvl->nvl_error = error;
189 nvlist_error(const nvlist_t *nvl)
197 return (nvl->nvl_error);
201 nvlist_get_nvpair_parent(const nvlist_t *nvl)
206 return (nvl->nvl_parent);
210 nvlist_get_parent(const nvlist_t *nvl, void **cookiep)
216 nvp = nvl->nvl_parent;
222 return (nvpair_nvlist(nvp));
226 nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent)
231 nvl->nvl_parent = parent;
235 nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele)
241 nvl->nvl_flags |= NV_FLAG_IN_ARRAY;
243 nvl->nvl_flags &= ~NV_FLAG_IN_ARRAY;
244 nv_free(nvl->nvl_array_next);
247 nvl->nvl_array_next = ele;
251 nvlist_in_array(const nvlist_t *nvl)
256 return ((nvl->nvl_flags & NV_FLAG_IN_ARRAY) != 0);
260 nvlist_get_array_next(const nvlist_t *nvl)
266 nvp = nvl->nvl_array_next;
270 return (nvpair_get_nvlist(nvp));
274 nvlist_get_pararr(const nvlist_t *nvl, void **cookiep)
278 ret = nvlist_get_array_next(nvl);
285 return (nvlist_get_parent(nvl, cookiep));
289 nvlist_empty(const nvlist_t *nvl)
293 PJDLOG_ASSERT(nvl->nvl_error == 0);
295 return (nvlist_first_nvpair(nvl) == NULL);
299 nvlist_flags(const nvlist_t *nvl)
303 PJDLOG_ASSERT(nvl->nvl_error == 0);
305 return (nvl->nvl_flags & NV_FLAG_PUBLIC_MASK);
309 nvlist_set_flags(nvlist_t *nvl, int flags)
313 PJDLOG_ASSERT(nvl->nvl_error == 0);
315 nvl->nvl_flags = flags;
319 nvlist_report_missing(int type, const char *name)
322 PJDLOG_ABORT("Element '%s' of type %s doesn't exist.",
323 name, nvpair_type_string(type));
327 nvlist_find(const nvlist_t *nvl, int type, const char *name)
332 PJDLOG_ASSERT(nvl->nvl_error == 0);
333 PJDLOG_ASSERT(type == NV_TYPE_NONE ||
334 (type >= NV_TYPE_FIRST && type <= NV_TYPE_LAST));
336 for (nvp = nvlist_first_nvpair(nvl); nvp != NULL;
337 nvp = nvlist_next_nvpair(nvl, nvp)) {
338 if (type != NV_TYPE_NONE && nvpair_type(nvp) != type)
340 if ((nvl->nvl_flags & NV_FLAG_IGNORE_CASE) != 0) {
341 if (strcasecmp(nvpair_name(nvp), name) != 0)
344 if (strcmp(nvpair_name(nvp), name) != 0)
357 nvlist_exists_type(const nvlist_t *nvl, const char *name, int type)
361 PJDLOG_ASSERT(nvl->nvl_error == 0);
362 PJDLOG_ASSERT(type == NV_TYPE_NONE ||
363 (type >= NV_TYPE_FIRST && type <= NV_TYPE_LAST));
365 return (nvlist_find(nvl, type, name) != NULL);
369 nvlist_free_type(nvlist_t *nvl, const char *name, int type)
374 PJDLOG_ASSERT(nvl->nvl_error == 0);
375 PJDLOG_ASSERT(type == NV_TYPE_NONE ||
376 (type >= NV_TYPE_FIRST && type <= NV_TYPE_LAST));
378 nvp = nvlist_find(nvl, type, name);
380 nvlist_free_nvpair(nvl, nvp);
382 nvlist_report_missing(type, name);
386 nvlist_clone(const nvlist_t *nvl)
389 nvpair_t *nvp, *newnvp;
393 if (nvl->nvl_error != 0) {
394 ERRNO_SET(nvl->nvl_error);
398 newnvl = nvlist_create(nvl->nvl_flags & NV_FLAG_PUBLIC_MASK);
399 for (nvp = nvlist_first_nvpair(nvl); nvp != NULL;
400 nvp = nvlist_next_nvpair(nvl, nvp)) {
401 newnvp = nvpair_clone(nvp);
404 (void)nvlist_move_nvpair(newnvl, newnvp);
407 nvlist_destroy(newnvl);
415 nvlist_dump_error_check(const nvlist_t *nvl, int fd, int level)
418 if (nvlist_error(nvl) != 0) {
419 dprintf(fd, "%*serror: %d\n", level * 4, "",
428 * Dump content of nvlist.
431 nvlist_dump(const nvlist_t *nvl, int fd)
433 const nvlist_t *tmpnvl;
434 nvpair_t *nvp, *tmpnvp;
439 if (nvlist_dump_error_check(nvl, fd, level))
442 nvp = nvlist_first_nvpair(nvl);
443 while (nvp != NULL) {
444 dprintf(fd, "%*s%s (%s):", level * 4, "", nvpair_name(nvp),
445 nvpair_type_string(nvpair_type(nvp)));
446 switch (nvpair_type(nvp)) {
448 dprintf(fd, " null\n");
451 dprintf(fd, " %s\n", nvpair_get_bool(nvp) ?
455 dprintf(fd, " %ju (%jd) (0x%jx)\n",
456 (uintmax_t)nvpair_get_number(nvp),
457 (intmax_t)nvpair_get_number(nvp),
458 (uintmax_t)nvpair_get_number(nvp));
461 dprintf(fd, " [%s]\n", nvpair_get_string(nvp));
465 tmpnvl = nvpair_get_nvlist(nvp);
466 if (nvlist_dump_error_check(tmpnvl, fd, level + 1))
468 tmpnvp = nvlist_first_nvpair(tmpnvl);
469 if (tmpnvp != NULL) {
476 case NV_TYPE_DESCRIPTOR:
477 dprintf(fd, " %d\n", nvpair_get_descriptor(nvp));
481 const unsigned char *binary;
485 binary = nvpair_get_binary(nvp, &size);
486 dprintf(fd, " %zu ", size);
487 for (ii = 0; ii < size; ii++)
488 dprintf(fd, "%02hhx", binary[ii]);
492 case NV_TYPE_BOOL_ARRAY:
498 value = nvpair_get_bool_array(nvp, &nitems);
500 for (ii = 0; ii < nitems; ii++) {
501 dprintf(fd, "%s", value[ii] ? "TRUE" : "FALSE");
502 if (ii != nitems - 1)
508 case NV_TYPE_STRING_ARRAY:
510 const char * const *value;
514 value = nvpair_get_string_array(nvp, &nitems);
516 for (ii = 0; ii < nitems; ii++) {
517 if (value[ii] == NULL)
520 dprintf(fd, "\"%s\"", value[ii]);
521 if (ii != nitems - 1)
527 case NV_TYPE_NUMBER_ARRAY:
529 const uint64_t *value;
533 value = nvpair_get_number_array(nvp, &nitems);
535 for (ii = 0; ii < nitems; ii++) {
536 dprintf(fd, "%ju (%jd) (0x%jx)",
537 value[ii], value[ii], value[ii]);
538 if (ii != nitems - 1)
544 case NV_TYPE_DESCRIPTOR_ARRAY:
550 value = nvpair_get_descriptor_array(nvp, &nitems);
552 for (ii = 0; ii < nitems; ii++) {
553 dprintf(fd, "%d", value[ii]);
554 if (ii != nitems - 1)
560 case NV_TYPE_NVLIST_ARRAY:
562 const nvlist_t * const *value;
566 value = nvpair_get_nvlist_array(nvp, &nitems);
567 dprintf(fd, " %zu\n", nitems);
570 for (ii = 0; ii < nitems; ii++) {
571 if (nvlist_dump_error_check(value[ii], fd,
576 if (tmpnvl == NULL) {
577 tmpnvp = nvlist_first_nvpair(value[ii]);
578 if (tmpnvp != NULL) {
581 dprintf(fd, "%*s,\n",
582 (level + 1) * 4, "");
586 if (tmpnvp != NULL) {
595 PJDLOG_ABORT("Unknown type: %d.", nvpair_type(nvp));
598 while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) {
601 if (nvlist_in_array(nvl))
602 dprintf(fd, "%*s,\n", level * 4, "");
603 nvl = nvlist_get_pararr(nvl, &cookie);
606 if (nvlist_in_array(nvl) && cookie == NULL) {
607 nvp = nvlist_first_nvpair(nvl);
612 } while (nvp == NULL);
613 if (nvlist_in_array(nvl) && cookie == NULL)
620 nvlist_fdump(const nvlist_t *nvl, FILE *fp)
624 nvlist_dump(nvl, fileno(fp));
629 * The function obtains size of the nvlist after nvlist_pack().
632 nvlist_size(const nvlist_t *nvl)
634 const nvlist_t *tmpnvl;
635 const nvlist_t * const *nvlarray;
636 const nvpair_t *nvp, *tmpnvp;
642 PJDLOG_ASSERT(nvl->nvl_error == 0);
644 size = sizeof(struct nvlist_header);
645 nvp = nvlist_first_nvpair(nvl);
646 while (nvp != NULL) {
647 size += nvpair_header_size();
648 size += strlen(nvpair_name(nvp)) + 1;
649 if (nvpair_type(nvp) == NV_TYPE_NVLIST) {
650 size += sizeof(struct nvlist_header);
651 size += nvpair_header_size() + 1;
652 tmpnvl = nvpair_get_nvlist(nvp);
653 PJDLOG_ASSERT(tmpnvl->nvl_error == 0);
654 tmpnvp = nvlist_first_nvpair(tmpnvl);
655 if (tmpnvp != NULL) {
660 } else if (nvpair_type(nvp) == NV_TYPE_NVLIST_ARRAY) {
661 nvlarray = nvpair_get_nvlist_array(nvp, &nitems);
662 PJDLOG_ASSERT(nitems > 0);
664 size += (nvpair_header_size() + 1) * nitems;
665 size += sizeof(struct nvlist_header) * nitems;
669 for (ii = 0; ii < nitems; ii++) {
670 PJDLOG_ASSERT(nvlarray[ii]->nvl_error == 0);
671 tmpnvp = nvlist_first_nvpair(nvlarray[ii]);
672 if (tmpnvp != NULL) {
673 tmpnvl = nvlarray[ii];
677 if (tmpnvp != NULL) {
684 size += nvpair_size(nvp);
687 while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) {
690 nvl = nvlist_get_pararr(nvl, &cookie);
693 if (nvlist_in_array(nvl) && cookie == NULL) {
694 nvp = nvlist_first_nvpair(nvl);
698 } while (nvp == NULL);
699 if (nvlist_in_array(nvl) && cookie == NULL)
710 nvlist_xdescriptors(const nvlist_t *nvl, int *descs)
717 PJDLOG_ASSERT(nvl->nvl_error == 0);
721 while (nvlist_next(nvl, &type, &cookie) != NULL) {
724 case NV_TYPE_DESCRIPTOR:
725 *descs = nvpair_get_descriptor(nvp);
728 case NV_TYPE_DESCRIPTOR_ARRAY:
734 value = nvpair_get_descriptor_array(nvp,
736 for (ii = 0; ii < nitems; ii++) {
743 nvl = nvpair_get_nvlist(nvp);
746 case NV_TYPE_NVLIST_ARRAY:
748 const nvlist_t * const *value;
751 value = nvpair_get_nvlist_array(nvp, &nitems);
752 PJDLOG_ASSERT(value != NULL);
753 PJDLOG_ASSERT(nitems > 0);
761 } while ((nvl = nvlist_get_pararr(nvl, &cookie)) != NULL);
769 nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp)
774 nitems = nvlist_ndescriptors(nvl);
775 fds = nv_malloc(sizeof(fds[0]) * (nitems + 1));
779 nvlist_xdescriptors(nvl, fds);
788 nvlist_ndescriptors(const nvlist_t *nvl)
797 PJDLOG_ASSERT(nvl->nvl_error == 0);
802 while (nvlist_next(nvl, &type, &cookie) != NULL) {
805 case NV_TYPE_DESCRIPTOR:
809 nvl = nvpair_get_nvlist(nvp);
812 case NV_TYPE_NVLIST_ARRAY:
814 const nvlist_t * const *value;
817 value = nvpair_get_nvlist_array(nvp, &nitems);
818 PJDLOG_ASSERT(value != NULL);
819 PJDLOG_ASSERT(nitems > 0);
825 case NV_TYPE_DESCRIPTOR_ARRAY:
829 (void)nvpair_get_descriptor_array(nvp,
836 } while ((nvl = nvlist_get_pararr(nvl, &cookie)) != NULL);
844 static unsigned char *
845 nvlist_pack_header(const nvlist_t *nvl, unsigned char *ptr, size_t *leftp)
847 struct nvlist_header nvlhdr;
851 nvlhdr.nvlh_magic = NVLIST_HEADER_MAGIC;
852 nvlhdr.nvlh_version = NVLIST_HEADER_VERSION;
853 nvlhdr.nvlh_flags = nvl->nvl_flags;
854 #if BYTE_ORDER == BIG_ENDIAN
855 nvlhdr.nvlh_flags |= NV_FLAG_BIG_ENDIAN;
857 nvlhdr.nvlh_descriptors = nvlist_ndescriptors(nvl);
858 nvlhdr.nvlh_size = *leftp - sizeof(nvlhdr);
859 PJDLOG_ASSERT(*leftp >= sizeof(nvlhdr));
860 memcpy(ptr, &nvlhdr, sizeof(nvlhdr));
861 ptr += sizeof(nvlhdr);
862 *leftp -= sizeof(nvlhdr);
868 nvlist_xpack(const nvlist_t *nvl, int64_t *fdidxp, size_t *sizep)
870 unsigned char *buf, *ptr;
872 const nvlist_t *tmpnvl;
873 nvpair_t *nvp, *tmpnvp;
878 if (nvl->nvl_error != 0) {
879 ERRNO_SET(nvl->nvl_error);
883 size = nvlist_size(nvl);
884 buf = nv_malloc(size);
891 ptr = nvlist_pack_header(nvl, ptr, &left);
893 nvp = nvlist_first_nvpair(nvl);
894 while (nvp != NULL) {
897 nvpair_init_datasize(nvp);
898 ptr = nvpair_pack_header(nvp, ptr, &left);
901 switch (nvpair_type(nvp)) {
903 ptr = nvpair_pack_null(nvp, ptr, &left);
906 ptr = nvpair_pack_bool(nvp, ptr, &left);
909 ptr = nvpair_pack_number(nvp, ptr, &left);
912 ptr = nvpair_pack_string(nvp, ptr, &left);
915 tmpnvl = nvpair_get_nvlist(nvp);
916 ptr = nvlist_pack_header(tmpnvl, ptr, &left);
919 tmpnvp = nvlist_first_nvpair(tmpnvl);
920 if (tmpnvp != NULL) {
925 ptr = nvpair_pack_nvlist_up(ptr, &left);
928 case NV_TYPE_DESCRIPTOR:
929 ptr = nvpair_pack_descriptor(nvp, ptr, fdidxp, &left);
931 case NV_TYPE_DESCRIPTOR_ARRAY:
932 ptr = nvpair_pack_descriptor_array(nvp, ptr, fdidxp,
937 ptr = nvpair_pack_binary(nvp, ptr, &left);
939 case NV_TYPE_BOOL_ARRAY:
940 ptr = nvpair_pack_bool_array(nvp, ptr, &left);
942 case NV_TYPE_NUMBER_ARRAY:
943 ptr = nvpair_pack_number_array(nvp, ptr, &left);
945 case NV_TYPE_STRING_ARRAY:
946 ptr = nvpair_pack_string_array(nvp, ptr, &left);
948 case NV_TYPE_NVLIST_ARRAY:
950 const nvlist_t * const * value;
955 value = nvpair_get_nvlist_array(nvp, &nitems);
956 for (ii = 0; ii < nitems; ii++) {
957 ptr = nvlist_pack_header(value[ii], ptr, &left);
960 tmpnvp = nvlist_first_nvpair(value[ii]);
961 if (tmpnvp != NULL) {
965 ptr = nvpair_pack_nvlist_array_next(ptr, &left);
969 if (tmpnvl != NULL) {
977 PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp));
981 while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) {
984 if (nvlist_in_array(nvl)) {
985 ptr = nvpair_pack_nvlist_array_next(ptr,
990 nvl = nvlist_get_pararr(nvl, &cookie);
993 if (nvlist_in_array(nvl) && cookie == NULL) {
994 nvp = nvlist_first_nvpair(nvl);
995 ptr = nvlist_pack_header(nvl, ptr,
999 } else if (nvpair_type((nvpair_t *)cookie) !=
1000 NV_TYPE_NVLIST_ARRAY) {
1001 ptr = nvpair_pack_nvlist_up(ptr, &left);
1008 } while (nvp == NULL);
1009 if (nvlist_in_array(nvl) && cookie == NULL)
1024 nvlist_pack(const nvlist_t *nvl, size_t *sizep)
1029 if (nvl->nvl_error != 0) {
1030 ERRNO_SET(nvl->nvl_error);
1034 if (nvlist_ndescriptors(nvl) > 0) {
1035 ERRNO_SET(EOPNOTSUPP);
1039 return (nvlist_xpack(nvl, NULL, sizep));
1043 nvlist_check_header(struct nvlist_header *nvlhdrp)
1046 if (nvlhdrp->nvlh_magic != NVLIST_HEADER_MAGIC) {
1050 if ((nvlhdrp->nvlh_flags & ~NV_FLAG_ALL_MASK) != 0) {
1054 #if BYTE_ORDER == BIG_ENDIAN
1055 if ((nvlhdrp->nvlh_flags & NV_FLAG_BIG_ENDIAN) == 0) {
1056 nvlhdrp->nvlh_size = le64toh(nvlhdrp->nvlh_size);
1057 nvlhdrp->nvlh_descriptors = le64toh(nvlhdrp->nvlh_descriptors);
1060 if ((nvlhdrp->nvlh_flags & NV_FLAG_BIG_ENDIAN) != 0) {
1061 nvlhdrp->nvlh_size = be64toh(nvlhdrp->nvlh_size);
1062 nvlhdrp->nvlh_descriptors = be64toh(nvlhdrp->nvlh_descriptors);
1068 const unsigned char *
1069 nvlist_unpack_header(nvlist_t *nvl, const unsigned char *ptr, size_t nfds,
1070 bool *isbep, size_t *leftp)
1072 struct nvlist_header nvlhdr;
1075 if (*leftp < sizeof(nvlhdr))
1078 memcpy(&nvlhdr, ptr, sizeof(nvlhdr));
1080 if (!nvlist_check_header(&nvlhdr))
1083 if (nvlhdr.nvlh_size != *leftp - sizeof(nvlhdr))
1087 * nvlh_descriptors might be smaller than nfds in embedded nvlists.
1089 if (nvlhdr.nvlh_descriptors > nfds)
1092 if ((nvlhdr.nvlh_flags & ~NV_FLAG_ALL_MASK) != 0)
1095 inarrayf = (nvl->nvl_flags & NV_FLAG_IN_ARRAY);
1096 nvl->nvl_flags = (nvlhdr.nvlh_flags & NV_FLAG_PUBLIC_MASK) | inarrayf;
1098 ptr += sizeof(nvlhdr);
1100 *isbep = (((int)nvlhdr.nvlh_flags & NV_FLAG_BIG_ENDIAN) != 0);
1101 *leftp -= sizeof(nvlhdr);
1110 nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds,
1113 const unsigned char *ptr;
1114 nvlist_t *nvl, *retnvl, *tmpnvl, *array;
1119 PJDLOG_ASSERT((flags & ~(NV_FLAG_PUBLIC_MASK)) == 0);
1124 tmpnvl = array = NULL;
1125 nvl = retnvl = nvlist_create(0);
1129 ptr = nvlist_unpack_header(nvl, ptr, nfds, &isbe, &left);
1132 if (nvl->nvl_flags != flags) {
1138 ptr = nvpair_unpack(isbe, ptr, &left, &nvp);
1141 switch (nvpair_type(nvp)) {
1143 ptr = nvpair_unpack_null(isbe, nvp, ptr, &left);
1146 ptr = nvpair_unpack_bool(isbe, nvp, ptr, &left);
1148 case NV_TYPE_NUMBER:
1149 ptr = nvpair_unpack_number(isbe, nvp, ptr, &left);
1151 case NV_TYPE_STRING:
1152 ptr = nvpair_unpack_string(isbe, nvp, ptr, &left);
1154 case NV_TYPE_NVLIST:
1155 ptr = nvpair_unpack_nvlist(isbe, nvp, ptr, &left, nfds,
1157 if (tmpnvl == NULL || ptr == NULL)
1159 nvlist_set_parent(tmpnvl, nvp);
1162 case NV_TYPE_DESCRIPTOR:
1163 ptr = nvpair_unpack_descriptor(isbe, nvp, ptr, &left,
1166 case NV_TYPE_DESCRIPTOR_ARRAY:
1167 ptr = nvpair_unpack_descriptor_array(isbe, nvp, ptr,
1171 case NV_TYPE_BINARY:
1172 ptr = nvpair_unpack_binary(isbe, nvp, ptr, &left);
1174 case NV_TYPE_NVLIST_UP:
1175 if (nvl->nvl_parent == NULL)
1177 nvl = nvpair_nvlist(nvl->nvl_parent);
1178 nvpair_free_structure(nvp);
1180 case NV_TYPE_NVLIST_ARRAY_NEXT:
1181 if (nvl->nvl_array_next == NULL) {
1182 if (nvl->nvl_parent == NULL)
1184 nvl = nvpair_nvlist(nvl->nvl_parent);
1186 nvl = __DECONST(nvlist_t *,
1187 nvlist_get_array_next(nvl));
1188 ptr = nvlist_unpack_header(nvl, ptr, nfds,
1193 nvpair_free_structure(nvp);
1195 case NV_TYPE_BOOL_ARRAY:
1196 ptr = nvpair_unpack_bool_array(isbe, nvp, ptr, &left);
1198 case NV_TYPE_NUMBER_ARRAY:
1199 ptr = nvpair_unpack_number_array(isbe, nvp, ptr, &left);
1201 case NV_TYPE_STRING_ARRAY:
1202 ptr = nvpair_unpack_string_array(isbe, nvp, ptr, &left);
1204 case NV_TYPE_NVLIST_ARRAY:
1205 ptr = nvpair_unpack_nvlist_array(isbe, nvp, ptr, &left,
1209 PJDLOG_ASSERT(array != NULL);
1212 nvlist_set_parent(array, nvp);
1213 array = __DECONST(nvlist_t *,
1214 nvlist_get_array_next(array));
1215 } while (array != NULL);
1216 ptr = nvlist_unpack_header(tmpnvl, ptr, nfds, &isbe,
1220 PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp));
1224 if (!nvlist_move_nvpair(nvl, nvp))
1226 if (tmpnvl != NULL) {
1234 nvlist_destroy(retnvl);
1239 nvlist_unpack(const void *buf, size_t size, int flags)
1242 return (nvlist_xunpack(buf, size, NULL, 0, flags));
1247 nvlist_send(int sock, const nvlist_t *nvl)
1249 size_t datasize, nfds;
1255 if (nvlist_error(nvl) != 0) {
1256 ERRNO_SET(nvlist_error(nvl));
1260 fds = nvlist_descriptors(nvl, &nfds);
1267 data = nvlist_xpack(nvl, &fdidx, &datasize);
1271 if (buf_send(sock, data, datasize) == -1)
1275 if (fd_send(sock, fds, nfds) == -1)
1289 nvlist_recv(int sock, int flags)
1291 struct nvlist_header nvlhdr;
1292 nvlist_t *nvl, *ret;
1294 size_t nfds, size, i;
1297 if (buf_recv(sock, &nvlhdr, sizeof(nvlhdr)) == -1)
1300 if (!nvlist_check_header(&nvlhdr))
1303 nfds = (size_t)nvlhdr.nvlh_descriptors;
1304 size = sizeof(nvlhdr) + (size_t)nvlhdr.nvlh_size;
1306 buf = nv_malloc(size);
1310 memcpy(buf, &nvlhdr, sizeof(nvlhdr));
1315 if (buf_recv(sock, buf + sizeof(nvlhdr), size - sizeof(nvlhdr)) == -1)
1319 fds = nv_malloc(nfds * sizeof(fds[0]));
1322 if (fd_recv(sock, fds, nfds) == -1)
1326 nvl = nvlist_xunpack(buf, size, fds, nfds, flags);
1329 for (i = 0; i < nfds; i++)
1346 nvlist_xfer(int sock, nvlist_t *nvl, int flags)
1349 if (nvlist_send(sock, nvl) < 0) {
1350 nvlist_destroy(nvl);
1353 nvlist_destroy(nvl);
1354 return (nvlist_recv(sock, flags));
1359 nvlist_first_nvpair(const nvlist_t *nvl)
1364 return (TAILQ_FIRST(&nvl->nvl_head));
1368 nvlist_next_nvpair(const nvlist_t *nvl __unused, const nvpair_t *nvp)
1374 PJDLOG_ASSERT(nvpair_nvlist(nvp) == nvl);
1376 retnvp = nvpair_next(nvp);
1377 PJDLOG_ASSERT(retnvp == NULL || nvpair_nvlist(retnvp) == nvl);
1384 nvlist_prev_nvpair(const nvlist_t *nvl __unused, const nvpair_t *nvp)
1390 PJDLOG_ASSERT(nvpair_nvlist(nvp) == nvl);
1392 retnvp = nvpair_prev(nvp);
1393 PJDLOG_ASSERT(nvpair_nvlist(retnvp) == nvl);
1399 nvlist_next(const nvlist_t *nvl, int *typep, void **cookiep)
1405 if (cookiep == NULL || *cookiep == NULL)
1406 nvp = nvlist_first_nvpair(nvl);
1408 nvp = nvlist_next_nvpair(nvl, *cookiep);
1412 *typep = nvpair_type(nvp);
1413 if (cookiep != NULL)
1415 return (nvpair_name(nvp));
1419 nvlist_exists(const nvlist_t *nvl, const char *name)
1422 return (nvlist_find(nvl, NV_TYPE_NONE, name) != NULL);
1425 #define NVLIST_EXISTS(type, TYPE) \
1427 nvlist_exists_##type(const nvlist_t *nvl, const char *name) \
1430 return (nvlist_find(nvl, NV_TYPE_##TYPE, name) != NULL); \
1433 NVLIST_EXISTS(null, NULL)
1434 NVLIST_EXISTS(bool, BOOL)
1435 NVLIST_EXISTS(number, NUMBER)
1436 NVLIST_EXISTS(string, STRING)
1437 NVLIST_EXISTS(nvlist, NVLIST)
1438 NVLIST_EXISTS(binary, BINARY)
1439 NVLIST_EXISTS(bool_array, BOOL_ARRAY)
1440 NVLIST_EXISTS(number_array, NUMBER_ARRAY)
1441 NVLIST_EXISTS(string_array, STRING_ARRAY)
1442 NVLIST_EXISTS(nvlist_array, NVLIST_ARRAY)
1444 NVLIST_EXISTS(descriptor, DESCRIPTOR)
1445 NVLIST_EXISTS(descriptor_array, DESCRIPTOR_ARRAY)
1448 #undef NVLIST_EXISTS
1451 nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
1457 if (nvlist_error(nvl) != 0) {
1458 ERRNO_SET(nvlist_error(nvl));
1461 if ((nvl->nvl_flags & NV_FLAG_NO_UNIQUE) == 0) {
1462 if (nvlist_exists(nvl, nvpair_name(nvp))) {
1463 nvl->nvl_error = EEXIST;
1464 ERRNO_SET(nvlist_error(nvl));
1469 newnvp = nvpair_clone(nvp);
1470 if (newnvp == NULL) {
1471 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1472 ERRNO_SET(nvlist_error(nvl));
1476 nvpair_insert(&nvl->nvl_head, newnvp, nvl);
1480 nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...)
1484 va_start(valueap, valuefmt);
1485 nvlist_add_stringv(nvl, name, valuefmt, valueap);
1490 nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt,
1495 if (nvlist_error(nvl) != 0) {
1496 ERRNO_SET(nvlist_error(nvl));
1500 nvp = nvpair_create_stringv(name, valuefmt, valueap);
1502 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1503 ERRNO_SET(nvl->nvl_error);
1505 (void)nvlist_move_nvpair(nvl, nvp);
1510 nvlist_add_null(nvlist_t *nvl, const char *name)
1514 if (nvlist_error(nvl) != 0) {
1515 ERRNO_SET(nvlist_error(nvl));
1519 nvp = nvpair_create_null(name);
1521 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1522 ERRNO_SET(nvl->nvl_error);
1524 (void)nvlist_move_nvpair(nvl, nvp);
1529 nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value,
1534 if (nvlist_error(nvl) != 0) {
1535 ERRNO_SET(nvlist_error(nvl));
1539 nvp = nvpair_create_binary(name, value, size);
1541 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1542 ERRNO_SET(nvl->nvl_error);
1544 (void)nvlist_move_nvpair(nvl, nvp);
1549 #define NVLIST_ADD(vtype, type) \
1551 nvlist_add_##type(nvlist_t *nvl, const char *name, vtype value) \
1555 if (nvlist_error(nvl) != 0) { \
1556 ERRNO_SET(nvlist_error(nvl)); \
1560 nvp = nvpair_create_##type(name, value); \
1561 if (nvp == NULL) { \
1562 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \
1563 ERRNO_SET(nvl->nvl_error); \
1565 (void)nvlist_move_nvpair(nvl, nvp); \
1569 NVLIST_ADD(bool, bool)
1570 NVLIST_ADD(uint64_t, number)
1571 NVLIST_ADD(const char *, string)
1572 NVLIST_ADD(const nvlist_t *, nvlist)
1574 NVLIST_ADD(int, descriptor);
1579 #define NVLIST_ADD_ARRAY(vtype, type) \
1581 nvlist_add_##type##_array(nvlist_t *nvl, const char *name, vtype value, \
1586 if (nvlist_error(nvl) != 0) { \
1587 ERRNO_SET(nvlist_error(nvl)); \
1591 nvp = nvpair_create_##type##_array(name, value, nitems); \
1592 if (nvp == NULL) { \
1593 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \
1594 ERRNO_SET(nvl->nvl_error); \
1596 (void)nvlist_move_nvpair(nvl, nvp); \
1600 NVLIST_ADD_ARRAY(const bool *, bool)
1601 NVLIST_ADD_ARRAY(const uint64_t *, number)
1602 NVLIST_ADD_ARRAY(const char * const *, string)
1603 NVLIST_ADD_ARRAY(const nvlist_t * const *, nvlist)
1605 NVLIST_ADD_ARRAY(const int *, descriptor)
1608 #undef NVLIST_ADD_ARRAY
1610 #define NVLIST_APPEND_ARRAY(vtype, type, TYPE) \
1612 nvlist_append_##type##_array(nvlist_t *nvl, const char *name, vtype value)\
1616 if (nvlist_error(nvl) != 0) { \
1617 ERRNO_SET(nvlist_error(nvl)); \
1620 nvp = nvlist_find(nvl, NV_TYPE_##TYPE##_ARRAY, name); \
1621 if (nvp == NULL) { \
1622 nvlist_add_##type##_array(nvl, name, &value, 1); \
1625 if (nvpair_append_##type##_array(nvp, value) == -1) { \
1626 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \
1627 ERRNO_SET(nvl->nvl_error); \
1631 NVLIST_APPEND_ARRAY(const bool, bool, BOOL)
1632 NVLIST_APPEND_ARRAY(const uint64_t, number, NUMBER)
1633 NVLIST_APPEND_ARRAY(const char *, string, STRING)
1634 NVLIST_APPEND_ARRAY(const nvlist_t *, nvlist, NVLIST)
1636 NVLIST_APPEND_ARRAY(const int, descriptor, DESCRIPTOR)
1639 #undef NVLIST_APPEND_ARRAY
1642 nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp)
1646 PJDLOG_ASSERT(nvpair_nvlist(nvp) == NULL);
1648 if (nvlist_error(nvl) != 0) {
1650 ERRNO_SET(nvlist_error(nvl));
1653 if ((nvl->nvl_flags & NV_FLAG_NO_UNIQUE) == 0) {
1654 if (nvlist_exists(nvl, nvpair_name(nvp))) {
1656 nvl->nvl_error = EEXIST;
1657 ERRNO_SET(nvl->nvl_error);
1662 nvpair_insert(&nvl->nvl_head, nvp, nvl);
1667 nvlist_move_string(nvlist_t *nvl, const char *name, char *value)
1671 if (nvlist_error(nvl) != 0) {
1673 ERRNO_SET(nvlist_error(nvl));
1677 nvp = nvpair_move_string(name, value);
1679 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1680 ERRNO_SET(nvl->nvl_error);
1682 (void)nvlist_move_nvpair(nvl, nvp);
1687 nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value)
1691 if (nvlist_error(nvl) != 0) {
1692 if (value != NULL && nvlist_get_nvpair_parent(value) != NULL)
1693 nvlist_destroy(value);
1694 ERRNO_SET(nvlist_error(nvl));
1698 nvp = nvpair_move_nvlist(name, value);
1700 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1701 ERRNO_SET(nvl->nvl_error);
1703 (void)nvlist_move_nvpair(nvl, nvp);
1709 nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value)
1713 if (nvlist_error(nvl) != 0) {
1715 ERRNO_SET(nvlist_error(nvl));
1719 nvp = nvpair_move_descriptor(name, value);
1721 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1722 ERRNO_SET(nvl->nvl_error);
1724 (void)nvlist_move_nvpair(nvl, nvp);
1730 nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
1734 if (nvlist_error(nvl) != 0) {
1736 ERRNO_SET(nvlist_error(nvl));
1740 nvp = nvpair_move_binary(name, value, size);
1742 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1743 ERRNO_SET(nvl->nvl_error);
1745 (void)nvlist_move_nvpair(nvl, nvp);
1750 nvlist_move_bool_array(nvlist_t *nvl, const char *name, bool *value,
1755 if (nvlist_error(nvl) != 0) {
1757 ERRNO_SET(nvlist_error(nvl));
1761 nvp = nvpair_move_bool_array(name, value, nitems);
1763 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1764 ERRNO_SET(nvl->nvl_error);
1766 (void)nvlist_move_nvpair(nvl, nvp);
1771 nvlist_move_string_array(nvlist_t *nvl, const char *name, char **value,
1777 if (nvlist_error(nvl) != 0) {
1778 if (value != NULL) {
1779 for (i = 0; i < nitems; i++)
1783 ERRNO_SET(nvlist_error(nvl));
1787 nvp = nvpair_move_string_array(name, value, nitems);
1789 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1790 ERRNO_SET(nvl->nvl_error);
1792 (void)nvlist_move_nvpair(nvl, nvp);
1797 nvlist_move_nvlist_array(nvlist_t *nvl, const char *name, nvlist_t **value,
1803 if (nvlist_error(nvl) != 0) {
1804 if (value != NULL) {
1805 for (i = 0; i < nitems; i++) {
1806 if (nvlist_get_pararr(value[i], NULL) == NULL)
1807 nvlist_destroy(value[i]);
1811 ERRNO_SET(nvlist_error(nvl));
1815 nvp = nvpair_move_nvlist_array(name, value, nitems);
1817 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1818 ERRNO_SET(nvl->nvl_error);
1820 (void)nvlist_move_nvpair(nvl, nvp);
1825 nvlist_move_number_array(nvlist_t *nvl, const char *name, uint64_t *value,
1830 if (nvlist_error(nvl) != 0) {
1832 ERRNO_SET(nvlist_error(nvl));
1836 nvp = nvpair_move_number_array(name, value, nitems);
1838 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1839 ERRNO_SET(nvl->nvl_error);
1841 (void)nvlist_move_nvpair(nvl, nvp);
1847 nvlist_move_descriptor_array(nvlist_t *nvl, const char *name, int *value,
1853 if (nvlist_error(nvl) != 0) {
1855 for (i = 0; i < nitems; i++)
1860 ERRNO_SET(nvlist_error(nvl));
1864 nvp = nvpair_move_descriptor_array(name, value, nitems);
1866 nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
1867 ERRNO_SET(nvl->nvl_error);
1869 (void)nvlist_move_nvpair(nvl, nvp);
1875 nvlist_get_nvpair(const nvlist_t *nvl, const char *name)
1878 return (nvlist_find(nvl, NV_TYPE_NONE, name));
1881 #define NVLIST_GET(ftype, type, TYPE) \
1883 nvlist_get_##type(const nvlist_t *nvl, const char *name) \
1885 const nvpair_t *nvp; \
1887 nvp = nvlist_find(nvl, NV_TYPE_##TYPE, name); \
1889 nvlist_report_missing(NV_TYPE_##TYPE, name); \
1890 return (nvpair_get_##type(nvp)); \
1893 NVLIST_GET(bool, bool, BOOL)
1894 NVLIST_GET(uint64_t, number, NUMBER)
1895 NVLIST_GET(const char *, string, STRING)
1896 NVLIST_GET(const nvlist_t *, nvlist, NVLIST)
1898 NVLIST_GET(int, descriptor, DESCRIPTOR)
1904 nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep)
1908 nvp = nvlist_find(nvl, NV_TYPE_BINARY, name);
1910 nvlist_report_missing(NV_TYPE_BINARY, name);
1912 return (nvpair_get_binary(nvp, sizep));
1915 #define NVLIST_GET_ARRAY(ftype, type, TYPE) \
1917 nvlist_get_##type##_array(const nvlist_t *nvl, const char *name, \
1920 const nvpair_t *nvp; \
1922 nvp = nvlist_find(nvl, NV_TYPE_##TYPE##_ARRAY, name); \
1924 nvlist_report_missing(NV_TYPE_##TYPE##_ARRAY, name); \
1925 return (nvpair_get_##type##_array(nvp, nitems)); \
1928 NVLIST_GET_ARRAY(const bool *, bool, BOOL)
1929 NVLIST_GET_ARRAY(const uint64_t *, number, NUMBER)
1930 NVLIST_GET_ARRAY(const char * const *, string, STRING)
1931 NVLIST_GET_ARRAY(const nvlist_t * const *, nvlist, NVLIST)
1933 NVLIST_GET_ARRAY(const int *, descriptor, DESCRIPTOR)
1936 #undef NVLIST_GET_ARRAY
1938 #define NVLIST_TAKE(ftype, type, TYPE) \
1940 nvlist_take_##type(nvlist_t *nvl, const char *name) \
1945 nvp = nvlist_find(nvl, NV_TYPE_##TYPE, name); \
1947 nvlist_report_missing(NV_TYPE_##TYPE, name); \
1948 value = (ftype)(intptr_t)nvpair_get_##type(nvp); \
1949 nvlist_remove_nvpair(nvl, nvp); \
1950 nvpair_free_structure(nvp); \
1954 NVLIST_TAKE(bool, bool, BOOL)
1955 NVLIST_TAKE(uint64_t, number, NUMBER)
1956 NVLIST_TAKE(char *, string, STRING)
1957 NVLIST_TAKE(nvlist_t *, nvlist, NVLIST)
1959 NVLIST_TAKE(int, descriptor, DESCRIPTOR)
1965 nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep)
1970 nvp = nvlist_find(nvl, NV_TYPE_BINARY, name);
1972 nvlist_report_missing(NV_TYPE_BINARY, name);
1974 value = (void *)(intptr_t)nvpair_get_binary(nvp, sizep);
1975 nvlist_remove_nvpair(nvl, nvp);
1976 nvpair_free_structure(nvp);
1980 #define NVLIST_TAKE_ARRAY(ftype, type, TYPE) \
1982 nvlist_take_##type##_array(nvlist_t *nvl, const char *name, \
1988 nvp = nvlist_find(nvl, NV_TYPE_##TYPE##_ARRAY, name); \
1990 nvlist_report_missing(NV_TYPE_##TYPE##_ARRAY, name); \
1991 value = (ftype)(intptr_t)nvpair_get_##type##_array(nvp, nitems);\
1992 nvlist_remove_nvpair(nvl, nvp); \
1993 nvpair_free_structure(nvp); \
1997 NVLIST_TAKE_ARRAY(bool *, bool, BOOL)
1998 NVLIST_TAKE_ARRAY(uint64_t *, number, NUMBER)
1999 NVLIST_TAKE_ARRAY(char **, string, STRING)
2000 NVLIST_TAKE_ARRAY(nvlist_t **, nvlist, NVLIST)
2002 NVLIST_TAKE_ARRAY(int *, descriptor, DESCRIPTOR)
2006 nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp)
2011 PJDLOG_ASSERT(nvpair_nvlist(nvp) == nvl);
2013 nvpair_remove(&nvl->nvl_head, nvp, nvl);
2017 nvlist_free(nvlist_t *nvl, const char *name)
2020 nvlist_free_type(nvl, name, NV_TYPE_NONE);
2023 #define NVLIST_FREE(type, TYPE) \
2025 nvlist_free_##type(nvlist_t *nvl, const char *name) \
2028 nvlist_free_type(nvl, name, NV_TYPE_##TYPE); \
2031 NVLIST_FREE(null, NULL)
2032 NVLIST_FREE(bool, BOOL)
2033 NVLIST_FREE(number, NUMBER)
2034 NVLIST_FREE(string, STRING)
2035 NVLIST_FREE(nvlist, NVLIST)
2036 NVLIST_FREE(binary, BINARY)
2037 NVLIST_FREE(bool_array, BOOL_ARRAY)
2038 NVLIST_FREE(number_array, NUMBER_ARRAY)
2039 NVLIST_FREE(string_array, STRING_ARRAY)
2040 NVLIST_FREE(nvlist_array, NVLIST_ARRAY)
2042 NVLIST_FREE(descriptor, DESCRIPTOR)
2043 NVLIST_FREE(descriptor_array, DESCRIPTOR_ARRAY)
2049 nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp)
2054 PJDLOG_ASSERT(nvpair_nvlist(nvp) == nvl);
2056 nvlist_remove_nvpair(nvl, nvp);