Print this page
OS-1840 fmdump shall emit JSON (copyright fixes 2)
OS-1840 fmdump shall emit JSON (rm feedback)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/nvpair.h
+++ new/usr/src/uts/common/sys/nvpair.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 + * Copyright (c) 2013, Joyent, Inc. All rights reserved.
24 25 */
25 26
26 27 #ifndef _SYS_NVPAIR_H
27 28 #define _SYS_NVPAIR_H
28 29
29 30 #include <sys/types.h>
30 31 #include <sys/time.h>
31 32 #include <sys/errno.h>
32 33 #include <sys/va_list.h>
33 34
34 35 #if defined(_KERNEL) && !defined(_BOOT)
35 36 #include <sys/kmem.h>
36 37 #endif
37 38
38 39 #ifdef __cplusplus
39 40 extern "C" {
40 41 #endif
41 42
42 43 typedef enum {
43 44 DATA_TYPE_UNKNOWN = 0,
44 45 DATA_TYPE_BOOLEAN,
45 46 DATA_TYPE_BYTE,
46 47 DATA_TYPE_INT16,
47 48 DATA_TYPE_UINT16,
48 49 DATA_TYPE_INT32,
49 50 DATA_TYPE_UINT32,
50 51 DATA_TYPE_INT64,
51 52 DATA_TYPE_UINT64,
52 53 DATA_TYPE_STRING,
53 54 DATA_TYPE_BYTE_ARRAY,
54 55 DATA_TYPE_INT16_ARRAY,
55 56 DATA_TYPE_UINT16_ARRAY,
56 57 DATA_TYPE_INT32_ARRAY,
57 58 DATA_TYPE_UINT32_ARRAY,
58 59 DATA_TYPE_INT64_ARRAY,
59 60 DATA_TYPE_UINT64_ARRAY,
60 61 DATA_TYPE_STRING_ARRAY,
61 62 DATA_TYPE_HRTIME,
62 63 DATA_TYPE_NVLIST,
63 64 DATA_TYPE_NVLIST_ARRAY,
64 65 DATA_TYPE_BOOLEAN_VALUE,
65 66 DATA_TYPE_INT8,
66 67 DATA_TYPE_UINT8,
67 68 DATA_TYPE_BOOLEAN_ARRAY,
68 69 DATA_TYPE_INT8_ARRAY,
69 70 #if !defined(_KERNEL)
70 71 DATA_TYPE_UINT8_ARRAY,
71 72 DATA_TYPE_DOUBLE
72 73 #else
73 74 DATA_TYPE_UINT8_ARRAY
74 75 #endif
75 76 } data_type_t;
76 77
77 78 typedef struct nvpair {
78 79 int32_t nvp_size; /* size of this nvpair */
79 80 int16_t nvp_name_sz; /* length of name string */
80 81 int16_t nvp_reserve; /* not used */
81 82 int32_t nvp_value_elem; /* number of elements for array types */
82 83 data_type_t nvp_type; /* type of value */
83 84 /* name string */
84 85 /* aligned ptr array for string arrays */
85 86 /* aligned array of data for value */
86 87 } nvpair_t;
87 88
88 89 /* nvlist header */
89 90 typedef struct nvlist {
90 91 int32_t nvl_version;
91 92 uint32_t nvl_nvflag; /* persistent flags */
92 93 uint64_t nvl_priv; /* ptr to private data if not packed */
93 94 uint32_t nvl_flag;
94 95 int32_t nvl_pad; /* currently not used, for alignment */
95 96 } nvlist_t;
96 97
97 98 /* nvp implementation version */
98 99 #define NV_VERSION 0
99 100
100 101 /* nvlist pack encoding */
101 102 #define NV_ENCODE_NATIVE 0
102 103 #define NV_ENCODE_XDR 1
103 104
104 105 /* nvlist persistent unique name flags, stored in nvl_nvflags */
105 106 #define NV_UNIQUE_NAME 0x1
106 107 #define NV_UNIQUE_NAME_TYPE 0x2
107 108
108 109 /* nvlist lookup pairs related flags */
109 110 #define NV_FLAG_NOENTOK 0x1
110 111
111 112 /* convenience macros */
112 113 #define NV_ALIGN(x) (((ulong_t)(x) + 7ul) & ~7ul)
113 114 #define NV_ALIGN4(x) (((x) + 3) & ~3)
114 115
115 116 #define NVP_SIZE(nvp) ((nvp)->nvp_size)
116 117 #define NVP_NAME(nvp) ((char *)(nvp) + sizeof (nvpair_t))
117 118 #define NVP_TYPE(nvp) ((nvp)->nvp_type)
118 119 #define NVP_NELEM(nvp) ((nvp)->nvp_value_elem)
119 120 #define NVP_VALUE(nvp) ((char *)(nvp) + NV_ALIGN(sizeof (nvpair_t) \
120 121 + (nvp)->nvp_name_sz))
121 122
122 123 #define NVL_VERSION(nvl) ((nvl)->nvl_version)
123 124 #define NVL_SIZE(nvl) ((nvl)->nvl_size)
124 125 #define NVL_FLAG(nvl) ((nvl)->nvl_flag)
125 126
126 127 /* NV allocator framework */
127 128 typedef struct nv_alloc_ops nv_alloc_ops_t;
128 129
129 130 typedef struct nv_alloc {
130 131 const nv_alloc_ops_t *nva_ops;
131 132 void *nva_arg;
132 133 } nv_alloc_t;
133 134
134 135 struct nv_alloc_ops {
135 136 int (*nv_ao_init)(nv_alloc_t *, __va_list);
136 137 void (*nv_ao_fini)(nv_alloc_t *);
137 138 void *(*nv_ao_alloc)(nv_alloc_t *, size_t);
138 139 void (*nv_ao_free)(nv_alloc_t *, void *, size_t);
139 140 void (*nv_ao_reset)(nv_alloc_t *);
140 141 };
141 142
142 143 extern const nv_alloc_ops_t *nv_fixed_ops;
143 144 extern nv_alloc_t *nv_alloc_nosleep;
144 145
145 146 #if defined(_KERNEL) && !defined(_BOOT)
146 147 extern nv_alloc_t *nv_alloc_sleep;
147 148 #endif
148 149
149 150 int nv_alloc_init(nv_alloc_t *, const nv_alloc_ops_t *, /* args */ ...);
150 151 void nv_alloc_reset(nv_alloc_t *);
151 152 void nv_alloc_fini(nv_alloc_t *);
152 153
153 154 /* list management */
154 155 int nvlist_alloc(nvlist_t **, uint_t, int);
155 156 void nvlist_free(nvlist_t *);
156 157 int nvlist_size(nvlist_t *, size_t *, int);
157 158 int nvlist_pack(nvlist_t *, char **, size_t *, int, int);
158 159 int nvlist_unpack(char *, size_t, nvlist_t **, int);
159 160 int nvlist_dup(nvlist_t *, nvlist_t **, int);
160 161 int nvlist_merge(nvlist_t *, nvlist_t *, int);
161 162
162 163 uint_t nvlist_nvflag(nvlist_t *);
163 164
164 165 int nvlist_xalloc(nvlist_t **, uint_t, nv_alloc_t *);
165 166 int nvlist_xpack(nvlist_t *, char **, size_t *, int, nv_alloc_t *);
166 167 int nvlist_xunpack(char *, size_t, nvlist_t **, nv_alloc_t *);
167 168 int nvlist_xdup(nvlist_t *, nvlist_t **, nv_alloc_t *);
168 169 nv_alloc_t *nvlist_lookup_nv_alloc(nvlist_t *);
169 170
170 171 int nvlist_add_nvpair(nvlist_t *, nvpair_t *);
171 172 int nvlist_add_boolean(nvlist_t *, const char *);
172 173 int nvlist_add_boolean_value(nvlist_t *, const char *, boolean_t);
173 174 int nvlist_add_byte(nvlist_t *, const char *, uchar_t);
174 175 int nvlist_add_int8(nvlist_t *, const char *, int8_t);
175 176 int nvlist_add_uint8(nvlist_t *, const char *, uint8_t);
176 177 int nvlist_add_int16(nvlist_t *, const char *, int16_t);
177 178 int nvlist_add_uint16(nvlist_t *, const char *, uint16_t);
178 179 int nvlist_add_int32(nvlist_t *, const char *, int32_t);
179 180 int nvlist_add_uint32(nvlist_t *, const char *, uint32_t);
180 181 int nvlist_add_int64(nvlist_t *, const char *, int64_t);
181 182 int nvlist_add_uint64(nvlist_t *, const char *, uint64_t);
182 183 int nvlist_add_string(nvlist_t *, const char *, const char *);
183 184 int nvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *);
184 185 int nvlist_add_boolean_array(nvlist_t *, const char *, boolean_t *, uint_t);
185 186 int nvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, uint_t);
186 187 int nvlist_add_int8_array(nvlist_t *, const char *, int8_t *, uint_t);
187 188 int nvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, uint_t);
188 189 int nvlist_add_int16_array(nvlist_t *, const char *, int16_t *, uint_t);
189 190 int nvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, uint_t);
190 191 int nvlist_add_int32_array(nvlist_t *, const char *, int32_t *, uint_t);
191 192 int nvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, uint_t);
192 193 int nvlist_add_int64_array(nvlist_t *, const char *, int64_t *, uint_t);
193 194 int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t);
194 195 int nvlist_add_string_array(nvlist_t *, const char *, char *const *, uint_t);
195 196 int nvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t);
196 197 int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t);
197 198 #if !defined(_KERNEL)
198 199 int nvlist_add_double(nvlist_t *, const char *, double);
199 200 #endif
200 201
201 202 int nvlist_remove(nvlist_t *, const char *, data_type_t);
202 203 int nvlist_remove_all(nvlist_t *, const char *);
203 204 int nvlist_remove_nvpair(nvlist_t *, nvpair_t *);
204 205
205 206 int nvlist_lookup_boolean(nvlist_t *, const char *);
206 207 int nvlist_lookup_boolean_value(nvlist_t *, const char *, boolean_t *);
207 208 int nvlist_lookup_byte(nvlist_t *, const char *, uchar_t *);
208 209 int nvlist_lookup_int8(nvlist_t *, const char *, int8_t *);
209 210 int nvlist_lookup_uint8(nvlist_t *, const char *, uint8_t *);
210 211 int nvlist_lookup_int16(nvlist_t *, const char *, int16_t *);
211 212 int nvlist_lookup_uint16(nvlist_t *, const char *, uint16_t *);
212 213 int nvlist_lookup_int32(nvlist_t *, const char *, int32_t *);
213 214 int nvlist_lookup_uint32(nvlist_t *, const char *, uint32_t *);
214 215 int nvlist_lookup_int64(nvlist_t *, const char *, int64_t *);
215 216 int nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *);
216 217 int nvlist_lookup_string(nvlist_t *, const char *, char **);
217 218 int nvlist_lookup_nvlist(nvlist_t *, const char *, nvlist_t **);
218 219 int nvlist_lookup_boolean_array(nvlist_t *, const char *,
219 220 boolean_t **, uint_t *);
220 221 int nvlist_lookup_byte_array(nvlist_t *, const char *, uchar_t **, uint_t *);
221 222 int nvlist_lookup_int8_array(nvlist_t *, const char *, int8_t **, uint_t *);
222 223 int nvlist_lookup_uint8_array(nvlist_t *, const char *, uint8_t **, uint_t *);
223 224 int nvlist_lookup_int16_array(nvlist_t *, const char *, int16_t **, uint_t *);
224 225 int nvlist_lookup_uint16_array(nvlist_t *, const char *, uint16_t **, uint_t *);
225 226 int nvlist_lookup_int32_array(nvlist_t *, const char *, int32_t **, uint_t *);
226 227 int nvlist_lookup_uint32_array(nvlist_t *, const char *, uint32_t **, uint_t *);
227 228 int nvlist_lookup_int64_array(nvlist_t *, const char *, int64_t **, uint_t *);
228 229 int nvlist_lookup_uint64_array(nvlist_t *, const char *, uint64_t **, uint_t *);
229 230 int nvlist_lookup_string_array(nvlist_t *, const char *, char ***, uint_t *);
230 231 int nvlist_lookup_nvlist_array(nvlist_t *, const char *,
231 232 nvlist_t ***, uint_t *);
232 233 int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *);
233 234 int nvlist_lookup_pairs(nvlist_t *, int, ...);
234 235 #if !defined(_KERNEL)
235 236 int nvlist_lookup_double(nvlist_t *, const char *, double *);
236 237 #endif
237 238
238 239 int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **);
239 240 int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *, nvpair_t **,
240 241 int *, char **);
241 242 boolean_t nvlist_exists(nvlist_t *, const char *);
242 243 boolean_t nvlist_empty(nvlist_t *);
243 244
244 245 /* processing nvpair */
245 246 nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *);
246 247 nvpair_t *nvlist_prev_nvpair(nvlist_t *, nvpair_t *);
247 248 char *nvpair_name(nvpair_t *);
248 249 data_type_t nvpair_type(nvpair_t *);
249 250 int nvpair_type_is_array(nvpair_t *);
250 251 int nvpair_value_boolean_value(nvpair_t *, boolean_t *);
251 252 int nvpair_value_byte(nvpair_t *, uchar_t *);
252 253 int nvpair_value_int8(nvpair_t *, int8_t *);
253 254 int nvpair_value_uint8(nvpair_t *, uint8_t *);
254 255 int nvpair_value_int16(nvpair_t *, int16_t *);
255 256 int nvpair_value_uint16(nvpair_t *, uint16_t *);
256 257 int nvpair_value_int32(nvpair_t *, int32_t *);
257 258 int nvpair_value_uint32(nvpair_t *, uint32_t *);
258 259 int nvpair_value_int64(nvpair_t *, int64_t *);
259 260 int nvpair_value_uint64(nvpair_t *, uint64_t *);
260 261 int nvpair_value_string(nvpair_t *, char **);
261 262 int nvpair_value_nvlist(nvpair_t *, nvlist_t **);
262 263 int nvpair_value_boolean_array(nvpair_t *, boolean_t **, uint_t *);
263 264 int nvpair_value_byte_array(nvpair_t *, uchar_t **, uint_t *);
264 265 int nvpair_value_int8_array(nvpair_t *, int8_t **, uint_t *);
265 266 int nvpair_value_uint8_array(nvpair_t *, uint8_t **, uint_t *);
266 267 int nvpair_value_int16_array(nvpair_t *, int16_t **, uint_t *);
267 268 int nvpair_value_uint16_array(nvpair_t *, uint16_t **, uint_t *);
268 269 int nvpair_value_int32_array(nvpair_t *, int32_t **, uint_t *);
269 270 int nvpair_value_uint32_array(nvpair_t *, uint32_t **, uint_t *);
270 271 int nvpair_value_int64_array(nvpair_t *, int64_t **, uint_t *);
271 272 int nvpair_value_uint64_array(nvpair_t *, uint64_t **, uint_t *);
272 273 int nvpair_value_string_array(nvpair_t *, char ***, uint_t *);
273 274 int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *);
274 275 int nvpair_value_hrtime(nvpair_t *, hrtime_t *);
275 276 #if !defined(_KERNEL)
276 277 int nvpair_value_double(nvpair_t *, double *);
277 278 #endif
278 279
279 280 nvlist_t *fnvlist_alloc(void);
280 281 void fnvlist_free(nvlist_t *);
281 282 size_t fnvlist_size(nvlist_t *);
282 283 char *fnvlist_pack(nvlist_t *, size_t *);
283 284 void fnvlist_pack_free(char *, size_t);
284 285 nvlist_t *fnvlist_unpack(char *, size_t);
285 286 nvlist_t *fnvlist_dup(nvlist_t *);
286 287 void fnvlist_merge(nvlist_t *, nvlist_t *);
287 288
288 289 void fnvlist_add_boolean(nvlist_t *, const char *);
289 290 void fnvlist_add_boolean_value(nvlist_t *, const char *, boolean_t);
290 291 void fnvlist_add_byte(nvlist_t *, const char *, uchar_t);
291 292 void fnvlist_add_int8(nvlist_t *, const char *, int8_t);
292 293 void fnvlist_add_uint8(nvlist_t *, const char *, uint8_t);
293 294 void fnvlist_add_int16(nvlist_t *, const char *, int16_t);
294 295 void fnvlist_add_uint16(nvlist_t *, const char *, uint16_t);
295 296 void fnvlist_add_int32(nvlist_t *, const char *, int32_t);
296 297 void fnvlist_add_uint32(nvlist_t *, const char *, uint32_t);
297 298 void fnvlist_add_int64(nvlist_t *, const char *, int64_t);
298 299 void fnvlist_add_uint64(nvlist_t *, const char *, uint64_t);
299 300 void fnvlist_add_string(nvlist_t *, const char *, const char *);
300 301 void fnvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *);
301 302 void fnvlist_add_nvpair(nvlist_t *, nvpair_t *);
302 303 void fnvlist_add_boolean_array(nvlist_t *, const char *, boolean_t *, uint_t);
303 304 void fnvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, uint_t);
304 305 void fnvlist_add_int8_array(nvlist_t *, const char *, int8_t *, uint_t);
305 306 void fnvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, uint_t);
306 307 void fnvlist_add_int16_array(nvlist_t *, const char *, int16_t *, uint_t);
307 308 void fnvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, uint_t);
308 309 void fnvlist_add_int32_array(nvlist_t *, const char *, int32_t *, uint_t);
309 310 void fnvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, uint_t);
310 311 void fnvlist_add_int64_array(nvlist_t *, const char *, int64_t *, uint_t);
311 312 void fnvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t);
312 313 void fnvlist_add_string_array(nvlist_t *, const char *, char * const *, uint_t);
313 314 void fnvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t);
314 315
315 316 void fnvlist_remove(nvlist_t *, const char *);
↓ open down ↓ |
282 lines elided |
↑ open up ↑ |
316 317 void fnvlist_remove_nvpair(nvlist_t *, nvpair_t *);
317 318
318 319 nvpair_t *fnvlist_lookup_nvpair(nvlist_t *nvl, const char *name);
319 320 boolean_t fnvlist_lookup_boolean(nvlist_t *nvl, const char *name);
320 321 boolean_t fnvlist_lookup_boolean_value(nvlist_t *nvl, const char *name);
321 322 uchar_t fnvlist_lookup_byte(nvlist_t *nvl, const char *name);
322 323 int8_t fnvlist_lookup_int8(nvlist_t *nvl, const char *name);
323 324 int16_t fnvlist_lookup_int16(nvlist_t *nvl, const char *name);
324 325 int32_t fnvlist_lookup_int32(nvlist_t *nvl, const char *name);
325 326 int64_t fnvlist_lookup_int64(nvlist_t *nvl, const char *name);
326 -uint8_t fnvlist_lookup_uint8_t(nvlist_t *nvl, const char *name);
327 +uint8_t fnvlist_lookup_uint8(nvlist_t *nvl, const char *name);
327 328 uint16_t fnvlist_lookup_uint16(nvlist_t *nvl, const char *name);
328 329 uint32_t fnvlist_lookup_uint32(nvlist_t *nvl, const char *name);
329 330 uint64_t fnvlist_lookup_uint64(nvlist_t *nvl, const char *name);
330 331 char *fnvlist_lookup_string(nvlist_t *nvl, const char *name);
331 332 nvlist_t *fnvlist_lookup_nvlist(nvlist_t *nvl, const char *name);
332 333
333 334 boolean_t fnvpair_value_boolean_value(nvpair_t *nvp);
334 335 uchar_t fnvpair_value_byte(nvpair_t *nvp);
335 336 int8_t fnvpair_value_int8(nvpair_t *nvp);
336 337 int16_t fnvpair_value_int16(nvpair_t *nvp);
337 338 int32_t fnvpair_value_int32(nvpair_t *nvp);
338 339 int64_t fnvpair_value_int64(nvpair_t *nvp);
339 -uint8_t fnvpair_value_uint8_t(nvpair_t *nvp);
340 +uint8_t fnvpair_value_uint8(nvpair_t *nvp);
340 341 uint16_t fnvpair_value_uint16(nvpair_t *nvp);
341 342 uint32_t fnvpair_value_uint32(nvpair_t *nvp);
342 343 uint64_t fnvpair_value_uint64(nvpair_t *nvp);
343 344 char *fnvpair_value_string(nvpair_t *nvp);
344 345 nvlist_t *fnvpair_value_nvlist(nvpair_t *nvp);
346 +hrtime_t fnvpair_value_hrtime(nvpair_t *);
347 +#if !defined(_KERNEL)
348 +double fnvpair_value_double(nvpair_t *);
349 +#endif
345 350
346 351 #ifdef __cplusplus
347 352 }
348 353 #endif
349 354
350 355 #endif /* _SYS_NVPAIR_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX