1nvlist_add_boolean(3NVPANIaRm)e-value Pair Library Functnivolnisst_add_boolean(3NVPAIR)
2
3
4

NAME

6       nvlist_add_boolean,      nvlist_add_boolean_value,     nvlist_add_byte,
7       nvlist_add_int8, nvlist_add_uint8, nvlist_add_int16, nvlist_add_uint16,
8       nvlist_add_int32,          nvlist_add_uint32,         nvlist_add_int64,
9       nvlist_add_uint64,        nvlist_add_double,         nvlist_add_string,
10       nvlist_add_nvlist,     nvlist_add_nvpair,     nvlist_add_boolean_array,
11       nvlist_add_byte_array,  nvlist_add_int8_array,  nvlist_add_uint8_array,
12       nvlist_add_int16_array,                        nvlist_add_uint16_array,
13       nvlist_add_int32_array,                        nvlist_add_uint32_array,
14       nvlist_add_int64_array,                        nvlist_add_uint64_array,
15       nvlist_add_string_array, nvlist_add_nvlist_array - add  new  name-value
16       pair to nvlist_t
17

SYNOPSIS

19       cc [ flag... ] file... -lnvpair [ library... ]
20       #include <libnvpair.h>
21
22       int nvlist_add_boolean(nvlist_t *nvl, const char *name);
23
24
25       int nvlist_add_boolean_value(nvlist_t *nvl,
26            const char *name, boolean_t val);
27
28
29       int nvlist_add_byte(nvlist_t *nvl, const char *name,
30            uchar_t val);
31
32
33       int nvlist_add_int8(nvlist_t *nvl, const char *name,
34            int8_t val);
35
36
37       int nvlist_add_uint8(nvlist_t *nvl, const char *name,
38            uint8_t val);
39
40
41       int nvlist_add_int16(nvlist_t *nvl, const char *name,
42            int16_t val);
43
44
45       int nvlist_add_uint16(nvlist_t *nvl, const char *name,
46            uint16_t val);
47
48
49       int nvlist_add_int32(nvlist_t *nvl, const char *name,
50            int32_t val);
51
52
53       int nvlist_add_uint32(nvlist_t *nvl, const char *name,
54            uint32_t val);
55
56
57       int nvlist_add_int64(nvlist_t *nvl, const char *name,
58            int64_t val);
59
60
61       int nvlist_add_uint64(nvlist_t *nvl, const char *name,
62            uint64_t val);
63
64
65       int nvlist_add_double(nvlist_t *nvl, const char *name,
66            double val);
67
68
69       int nvlist_add_string(nvlist_t *nvl, const char *name,
70            const char *val);
71
72
73       int nvlist_add_nvlist(nvlist_t *nvl, const char *name,
74            nvlist_t *val);
75
76
77       int nvlist_add_nvpair(nvlist_t *nvl, nvpair_t *nvp);
78
79
80       int nvlist_add_boolean_array(nvlist_t *nvl, const char *name,
81            boolean_t *val, uint_t nelem);
82
83
84       int nvlist_add_byte_array(nvlist_t *nvl, const char *name,
85            uchar_t *val, uint_t nelem);
86
87
88       int nvlist_add_int8_array(nvlist_t *nvl, const char *name,
89            int8_t *val, uint_t nelem);
90
91
92       int nvlist_add_uint8_array(nvlist_t *nvl, const char *name,
93            uint8_t *val, uint_t nelem);
94
95
96       int nvlist_add_int16_array(nvlist_t *nvl, const char *name,
97            int16_t *val, uint_t nelem);
98
99
100       int nvlist_add_uint16_array(nvlist_t *nvl, const char *name,
101            uint16_t *val, uint_t nelem);
102
103
104       int nvlist_add_int32_array(nvlist_t *nvl, const char *name,
105            int32_t *val, uint_t nelem);
106
107
108       int nvlist_add_uint32_array(nvlist_t *nvl, const char *name,
109            uint32_t *val, uint_t nelem);
110
111
112       int nvlist_add_int64_array(nvlist_t *nvl, const char *name,
113            int64_t *val, uint_t nelem);
114
115
116       int nvlist_add_uint64_array(nvlist_t *nvl, const char *name,
117            uint64_t *val, uint_t nelem);
118
119
120       int nvlist_add_string_array(nvlist_t *nvl, const char *name,
121            char *const *val, uint_t nelem);
122
123
124       int nvlist_add_nvlist_array(nvlist_t *nvl, const char *name,
125            nvlist_t **val, uint_t nelem);
126
127

PARAMETERS

129       nvl      The nvlist_t (name-value pair list) to be processed.
130
131
132       nvp      The nvpair_t (name-value pair) to be processed.
133
134
135       name     Name of the nvpair (name-value pair).
136
137
138       nelem    Number of elements in value (that is, array size).
139
140
141       val      Value or starting address of the array value.
142
143

DESCRIPTION

145       These  functions  add a new name-value pair to an nvlist_t. The unique‐
146       ness of nvpair name and data types follows the nvflag  argument  speci‐
147       fied for nvlist_alloc(). See nvlist_alloc(3NVPAIR).
148
149
150       If  NV_UNIQUE_NAME  was  specified  for  nvflag,  existing nvpairs with
151       matching names are removed before the new nvpair is added.
152
153
154       If NV_UNIQUE_NAME_TYPE was specified for nvflag, existing nvpairs  with
155       matching  names  and  data  types  are removed before the new nvpair is
156       added.
157
158
159       If neither was specified for nvflag, the new nvpair is  unconditionally
160       added  at  the  end of the list. The library preserves the order of the
161       name-value pairs across packing, unpacking, and duplication.
162
163
164       Multiple threads can simultaneously read the same  nvlist_t,  but  only
165       one  thread  can actively change a given nvlist_t at a time. The caller
166       is responsible for the synchronization.
167
168
169       The  list  that  is  added  to   the   parent   nvlist_t   by   calling
170       nvlist_add_nvlist()  is copied and thus is not freed when nvlist_free()
171       is called on the parent list. To prevent memory leaks, your code  needs
172       to look like the following (error handling elided for clarity):
173
174         nvlist_t *parent_nvl;
175         nvlist_t *child_nvl;
176
177         /* create parent list, add an entry */
178         (void) nvlist_alloc(&parent_nvl, NV_UNIQUE_NAME, KM_SLEEP);
179         (void) nvlist_add_boolean(parent_nvl, "parent_bool", 0);
180
181         /* create child list, add an entry */
182         (void) nvlist_alloc(&child_nvl, NV_UNIQUE_NAME, KM_SLEEP);
183         (void) nvlist_add_boolean(child_nvl, "child_bool", 0);
184
185         /* add the child to the parent */
186         (void) nvlist_add_nvlist(parent_nvl, "child_nvlist", child_nvl);
187
188         /* do stuff .. */
189
190         /* free nvlist(s) */
191         (void) nvlist_free(child_nvl); /* required, but not obvious */
192         (void) nvlist_free(parent_nvl);
193
194
195
196       The  nvlist_add_boolean()  function is deprecated. The nvlist_add_bool‐
197       ean_value() function should be used instead.
198

RETURN VALUES

200       These functions return 0 on success and an error value on failure.
201

ERRORS

203       These functions will fail if:
204
205       EINVAL    There is an invalid argument.
206
207
208       ENOMEM    There is insufficient memory.
209
210

ATTRIBUTES

212       See attributes(5) for descriptions of the following attributes:
213
214
215
216
217       ┌────────────────────────────┬──────────────────────────────┐
218       │      ATTRIBUTE TYPE        │       ATTRIBUTE VALUE        │
219       ├────────────────────────────┼──────────────────────────────┤
220       │Interface Stability         │ Committed                    │
221       ├────────────────────────────┼──────────────────────────────┤
222       │MT-Level                    │ MT-Safe                      │
223       └────────────────────────────┴──────────────────────────────┘
224

SEE ALSO

226       libnvpair(3LIB), nvlist_alloc(3NVPAIR), attributes(5)
227
228
229
230SunOS 5.11                        15 Sep 2009      nvlist_add_boolean(3NVPAIR)
Impressum