Unleashed v1.4
[unleashed.git] / share / man / man3nvpair / nvlist_add_boolean.3nvpair
blob2d85c2659df080b2d1318e9c2336cb2da1803e34
1 '\" te
2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .\" Copyright (c) 2016 Delphix. All Rights Reserved.
7 .TH NVLIST_ADD_BOOLEAN 3NVPAIR "Sep 15, 2009"
8 .SH NAME
9 nvlist_add_boolean, nvlist_add_boolean_value, nvlist_add_byte, nvlist_add_int8,
10 nvlist_add_uint8, nvlist_add_int16, nvlist_add_uint16, nvlist_add_int32,
11 nvlist_add_uint32, nvlist_add_int64, nvlist_add_uint64, nvlist_add_double,
12 nvlist_add_string, nvlist_add_nvlist, nvlist_add_nvpair,
13 nvlist_add_boolean_array, nvlist_add_byte_array, nvlist_add_int8_array,
14 nvlist_add_uint8_array, nvlist_add_int16_array, nvlist_add_uint16_array,
15 nvlist_add_int32_array, nvlist_add_uint32_array, nvlist_add_int64_array,
16 nvlist_add_uint64_array, nvlist_add_string_array, nvlist_add_nvlist_array \-
17 add new name-value pair to nvlist_t
18 .SH SYNOPSIS
19 .LP
20 .nf
21 \fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lnvpair\fR [ \fIlibrary\fR... ]
22 #include <libnvpair.h>
24 \fBint\fR \fBnvlist_add_boolean\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR);
25 .fi
27 .LP
28 .nf
29 \fBint\fR \fBnvlist_add_boolean_value\fR(\fBnvlist_t *\fR\fInvl\fR,
30      \fBconst char *\fR\fIname\fR, \fBboolean_t\fR \fIval\fR);
31 .fi
33 .LP
34 .nf
35 \fBint\fR \fBnvlist_add_byte\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
36      \fBuchar_t\fR \fIval\fR);
37 .fi
39 .LP
40 .nf
41 \fBint\fR \fBnvlist_add_int8\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
42      \fBint8_t\fR \fIval\fR);
43 .fi
45 .LP
46 .nf
47 \fBint\fR \fBnvlist_add_uint8\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
48      \fBuint8_t\fR \fIval\fR);
49 .fi
51 .LP
52 .nf
53 \fBint\fR \fBnvlist_add_int16\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
54      \fBint16_t\fR \fIval\fR);
55 .fi
57 .LP
58 .nf
59 \fBint\fR \fBnvlist_add_uint16\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
60      \fBuint16_t\fR \fIval\fR);
61 .fi
63 .LP
64 .nf
65 \fBint\fR \fBnvlist_add_int32\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
66      \fBint32_t\fR \fIval\fR);
67 .fi
69 .LP
70 .nf
71 \fBint\fR \fBnvlist_add_uint32\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
72      \fBuint32_t\fR \fIval\fR);
73 .fi
75 .LP
76 .nf
77 \fBint\fR \fBnvlist_add_int64\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
78      \fBint64_t\fR \fIval\fR);
79 .fi
81 .LP
82 .nf
83 \fBint\fR \fBnvlist_add_uint64\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
84      \fBuint64_t\fR \fIval\fR);
85 .fi
87 .LP
88 .nf
89 \fBint\fR \fBnvlist_add_double\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
90      \fBdouble\fR \fIval\fR);
91 .fi
93 .LP
94 .nf
95 \fBint\fR \fBnvlist_add_string\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
96      \fBconst char *\fR\fIval\fR);
97 .fi
99 .LP
101 \fBint\fR \fBnvlist_add_nvlist\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
102      \fBnvlist_t *\fR\fIval\fR);
107 \fBint\fR \fBnvlist_add_nvpair\fR(\fBnvlist_t *\fR\fInvl\fR, \fBnvpair_t *\fR\fInvp\fR);
112 \fBint\fR \fBnvlist_add_boolean_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
113      \fBboolean_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
118 \fBint\fR \fBnvlist_add_byte_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
119      \fBuchar_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
124 \fBint\fR \fBnvlist_add_int8_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
125      \fBint8_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
130 \fBint\fR \fBnvlist_add_uint8_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
131      \fBuint8_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
136 \fBint\fR \fBnvlist_add_int16_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
137      \fBint16_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
142 \fBint\fR \fBnvlist_add_uint16_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
143      \fBuint16_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
148 \fBint\fR \fBnvlist_add_int32_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
149      \fBint32_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
154 \fBint\fR \fBnvlist_add_uint32_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
155      \fBuint32_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
160 \fBint\fR \fBnvlist_add_int64_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
161      \fBint64_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
166 \fBint\fR \fBnvlist_add_uint64_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
167      \fBuint64_t *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
172 \fBint\fR \fBnvlist_add_string_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
173      \fBchar *const *\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
178 \fBint\fR \fBnvlist_add_nvlist_array\fR(\fBnvlist_t *\fR\fInvl\fR, \fBconst char *\fR\fIname\fR,
179      \fBnvlist_t **\fR\fIval\fR, \fBuint_t\fR \fInelem\fR);
182 .SH PARAMETERS
183 .ne 2
185 \fB\fInvl\fR\fR
187 .RS 9n
188 The \fBnvlist_t\fR (name-value pair list) to be processed.
192 .ne 2
194 \fB\fInvp\fR\fR
196 .RS 9n
197 The \fBnvpair_t\fR (name-value pair) to be processed.
201 .ne 2
203 \fB\fIname\fR\fR
205 .RS 9n
206 Name of the \fBnvpair\fR (name-value pair).
210 .ne 2
212 \fB\fInelem\fR\fR
214 .RS 9n
215 Number of elements in value (that is, array size).
219 .ne 2
221 \fB\fIval\fR\fR
223 .RS 9n
224 Value or starting address of the array value.
227 .SH DESCRIPTION
229 These functions add a new name-value pair to an \fBnvlist_t\fR. The uniqueness
230 of \fBnvpair\fR name and data types follows the \fInvflag\fR argument specified
231 for \fBnvlist_alloc()\fR. See \fBnvlist_alloc\fR(3NVPAIR).
234 If \fBNV_UNIQUE_NAME\fR was specified for \fInvflag\fR, existing \fBnvpair\fRs
235 with matching names are removed before the new \fBnvpair\fR is added.
238 If \fBNV_UNIQUE_NAME_TYPE\fR was specified for \fInvflag\fR, existing
239 \fBnvpair\fRs with matching names and data types are removed before the new
240 \fBnvpair\fR is added.
243 If neither was specified for \fInvflag\fR, the new \fBnvpair\fR is
244 unconditionally added at the end of the list. The library preserves the order
245 of the name-value pairs across packing, unpacking, and duplication.
248 Multiple threads can simultaneously read the same \fBnvlist_t\fR, but only one
249 thread can actively change a given \fBnvlist_t\fR at a time. The caller is
250 responsible for the synchronization.
253 The name used for any name-value pair, including the terminating null
254 byte, can be no more than
255 .B INT16_MAX
256 (2^15 - 1) bytes in
257 length, otherwise
258 .B EINVAL
259 will be returned.
262 The list that is added to the parent \fBnvlist_t\fR by calling
263 \fBnvlist_add_nvlist()\fR is copied and thus is not freed when
264 \fBnvlist_free()\fR is called on the parent list. To prevent memory leaks, your
265 code needs to look like the following (error handling elided for clarity):
267 .in +2
269 nvlist_t *parent_nvl;
270 nvlist_t *child_nvl;
272 /* create parent list, add an entry */
273 (void) nvlist_alloc(&parent_nvl, NV_UNIQUE_NAME, KM_SLEEP);
274 (void) nvlist_add_boolean(parent_nvl, "parent_bool", 0);
276 /* create child list, add an entry */
277 (void) nvlist_alloc(&child_nvl, NV_UNIQUE_NAME, KM_SLEEP);
278 (void) nvlist_add_boolean(child_nvl, "child_bool", 0);
280 /* add the child to the parent */
281 (void) nvlist_add_nvlist(parent_nvl, "child_nvlist", child_nvl);
283 /* do stuff .. */
285 /* free nvlist(s) */
286 (void) nvlist_free(child_nvl); /* required, but not obvious */
287 (void) nvlist_free(parent_nvl);
289 .in -2
293 The \fBnvlist_add_boolean()\fR function is deprecated. The
294 \fBnvlist_add_boolean_value()\fR function should be used instead.
295 .SH RETURN VALUES
297 These functions return 0 on success and an error value on failure.
298 .SH ERRORS
300 These functions will fail if:
302 .ne 2
304 \fB\fBEINVAL\fR\fR
306 .RS 10n
307 There is an invalid argument.
311 .ne 2
313 \fB\fBENOMEM\fR\fR
315 .RS 10n
316 There is insufficient memory.
319 .SH ATTRIBUTES
321 See \fBattributes\fR(5) for descriptions of the following attributes:
326 box;
327 c | c
328 l | l .
329 ATTRIBUTE TYPE  ATTRIBUTE VALUE
331 Interface Stability     Committed
333 MT-Level        MT-Safe
336 .SH SEE ALSO
338 \fBlibnvpair\fR(3LIB), \fBnvlist_alloc\fR(3NVPAIR), \fBattributes\fR(5)