xref: /titanic_41/usr/src/cmd/lvm/metassist/common/volume_nvpair.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
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  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _VOLUME_NVPAIR_H
28 #define	_VOLUME_NVPAIR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <libnvpair.h>
37 
38 /*
39  * Get the named uint16 from the given nvlist_t.
40  *
41  * @param       attrs
42  *              the nvlist_t to search
43  *
44  * @param       which
45  *              the string key for this element in the list
46  *
47  * @param       val
48  *              RETURN: the value of the requested uint16
49  *
50  * @return      0
51  *              if successful
52  *
53  * @return      ENOENT
54  *              if no matching name-value pair is found
55  *
56  * @return      ENOTSUP
57  *              if an encode/decode method is not supported
58  *
59  * @return      EINVAL
60  *              if there is an invalid argument
61  */
62 extern int get_uint16(nvlist_t *attrs, char *which, uint16_t *val);
63 
64 /*
65  * Set the named uint16 in the given nvlist_t.
66  *
67  * @param       attrs
68  *              the nvlist_t to search
69  *
70  * @param       which
71  *              the string key for this element in the list
72  *
73  * @param       val
74  *              the value to set
75  *
76  * @return      0
77  *              if successful
78  *
79  * @return      EINVAL
80  *              if there is an invalid argument
81  *
82  * @return      ENOMEM
83  *              if there is insufficient memory
84  */
85 extern int set_uint16(nvlist_t *attrs, char *which, uint16_t val);
86 
87 /*
88  * Get the named uint32 from the given nvlist_t.
89  *
90  * @param       attrs
91  *              the nvlist_t to search
92  *
93  * @param       which
94  *              the string key for this element in the list
95  *
96  * @param       val
97  *              RETURN: the value of the requested uint32
98  *
99  * @return      0
100  *              if successful
101  *
102  * @return      ENOENT
103  *              if no matching name-value pair is found
104  *
105  * @return      ENOTSUP
106  *              if an encode/decode method is not supported
107  *
108  * @return      EINVAL
109  *              if there is an invalid argument
110  */
111 extern int get_uint32(nvlist_t *attrs, char *which, uint32_t *val);
112 
113 /*
114  * Set the named uint32 in the given nvlist_t.
115  *
116  * @param       attrs
117  *              the nvlist_t to search
118  *
119  * @param       which
120  *              the string key for this element in the list
121  *
122  * @param       val
123  *              the value to set
124  *
125  * @return      0
126  *              if successful
127  *
128  * @return      EINVAL
129  *              if there is an invalid argument
130  *
131  * @return      ENOMEM
132  *              if there is insufficient memory
133  */
134 extern int set_uint32(nvlist_t *attrs, char *which, uint32_t val);
135 
136 /*
137  * Get the named uint64 from the given nvlist_t.
138  *
139  * @param       attrs
140  *              the nvlist_t to search
141  *
142  * @param       which
143  *              the string key for this element in the list
144  *
145  * @param       val
146  *              RETURN: the value of the requested uint64
147  *
148  * @return      0
149  *              if successful
150  *
151  * @return      ENOENT
152  *              if no matching name-value pair is found
153  *
154  * @return      ENOTSUP
155  *              if an encode/decode method is not supported
156  *
157  * @return      EINVAL
158  *              if there is an invalid argument
159  */
160 extern int get_uint64(nvlist_t *attrs, char *which, uint64_t *val);
161 
162 /*
163  * Set the named uint64 in the given nvlist_t.
164  *
165  * @param       attrs
166  *              the nvlist_t to search
167  *
168  * @param       which
169  *              the string key for this element in the list
170  *
171  * @param       val
172  *              the value to set
173  *
174  * @return      0
175  *              if successful
176  *
177  * @return      EINVAL
178  *              if there is an invalid argument
179  *
180  * @return      ENOMEM
181  *              if there is insufficient memory
182  */
183 extern int set_uint64(nvlist_t *attrs, char *which, uint64_t val);
184 
185 /*
186  * Set the named boolean in the given nvlist_t.
187  *
188  * @param       attrs
189  *              the nvlist_t to search
190  *
191  * @param       which
192  *              the string key for this element in the list
193  *
194  * @param       val
195  *              the value to set
196  *
197  * @return      0
198  *              if successful
199  *
200  * @return      EINVAL
201  *              if there is an invalid argument
202  *
203  * @return      ENOMEM
204  *              if there is insufficient memory
205  */
206 extern int set_boolean(nvlist_t *attrs, char *which, boolean_t val);
207 
208 /*
209  * Get the named boolean from the given nvlist_t.
210  *
211  * @param       attrs
212  *              the nvlist_t to search
213  *
214  * @param       which
215  *              the string key for this element in the list
216  *
217  * @param       boolval
218  *              RETURN: the value of the requested boolean
219  *
220  * @return      0
221  *              if successful
222  *
223  * @return      ENOENT
224  *              if no matching name-value pair is found
225  *
226  * @return      ENOTSUP
227  *              if an encode/decode method is not supported
228  *
229  * @return      EINVAL
230  *              if there is an invalid argument
231  */
232 extern int get_boolean(nvlist_t *attrs, char *which, boolean_t *boolval);
233 
234 /*
235  * Get the named string from the given nvlist_t.
236  *
237  * @param       attrs
238  *              the nvlist_t to search
239  *
240  * @param       which
241  *              the string key for this element in the list
242  *
243  * @param       str
244  *              RETURN: the requested string
245  *
246  * @return      0
247  *              if successful
248  *
249  * @return      ENOENT
250  *              if no matching name-value pair is found
251  *
252  * @return      ENOTSUP
253  *              if an encode/decode method is not supported
254  *
255  * @return      EINVAL
256  *              if there is an invalid argument
257  */
258 extern int get_string(nvlist_t *attrs, char *which, char **str);
259 
260 /*
261  * Set the named string in the given nvlist_t.
262  *
263  * @param       attrs
264  *              the nvlist_t to search
265  *
266  * @param       which
267  *              the string key for this element in the list
268  *
269  * @param       val
270  *              the value to set
271  *
272  * @return      0
273  *              if successful
274  *
275  * @return      EINVAL
276  *              if there is an invalid argument
277  *
278  * @return      ENOMEM
279  *              if there is insufficient memory
280  */
281 extern int set_string(nvlist_t *attrs, char *which, char *val);
282 
283 /*
284  * Get the named uint16 array from the given nvlist_t.
285  *
286  * @param       attrs
287  *              the nvlist_t to search
288  *
289  * @param       which
290  *              the string key for this element in the list
291  *
292  * @param       val
293  *              RETURN: the value of the requested uint16 array
294  *
295  * @param       nelem
296  *              RETURN: the number of elements in the array
297  *
298  * @return      0
299  *              if successful
300  *
301  * @return      ENOENT
302  *              if no matching name-value pair is found
303  *
304  * @return      ENOTSUP
305  *              if an encode/decode method is not supported
306  *
307  * @return      EINVAL
308  *              if there is an invalid argument
309  */
310 extern int get_uint16_array(
311 	nvlist_t *attrs, char *which, uint16_t **val, uint_t *nelem);
312 
313 /*
314  * Set the named uint16 array from the given nvlist_t.
315  *
316  * @param       attrs
317  *              the nvlist_t to search
318  *
319  * @param       which
320  *              the string key for this element in the list
321  *
322  * @param       val
323  *              the value of the requested uint16 array
324  *
325  * @param       nelem
326  *              the number of elements in the array
327  *
328  * @return      0
329  *              if successful
330  *
331  * @return      ENOENT
332  *              if no matching name-value pair is found
333  *
334  * @return      ENOTSUP
335  *              if an encode/decode method is not supported
336  *
337  * @return      EINVAL
338  *              if there is an invalid argument
339  */
340 extern int set_uint16_array(
341 	nvlist_t *attrs, char *which, uint16_t *val, uint_t nelem);
342 
343 /*
344  * Get the named uint64 array from the given nvlist_t.
345  *
346  * @param       attrs
347  *              the nvlist_t to search
348  *
349  * @param       which
350  *              the string key for this element in the list
351  *
352  * @param       val
353  *              RETURN: the value of the requested uint64 array
354  *
355  * @param       nelem
356  *              RETURN: the number of elements in the array
357  *
358  * @return      0
359  *              if successful
360  *
361  * @return      ENOENT
362  *              if no matching name-value pair is found
363  *
364  * @return      ENOTSUP
365  *              if an encode/decode method is not supported
366  *
367  * @return      EINVAL
368  *              if there is an invalid argument
369  */
370 extern int get_uint64_array(
371 	nvlist_t *attrs, char *which, uint64_t **val, uint_t *nelem);
372 
373 /*
374  * Set the named uint64 array from the given nvlist_t.
375  *
376  * @param       attrs
377  *              the nvlist_t to search
378  *
379  * @param       which
380  *              the string key for this element in the list
381  *
382  * @param       val
383  *              the value of the requested uint64 array
384  *
385  * @param       nelem
386  *              the number of elements in the array
387  *
388  * @return      0
389  *              if successful
390  *
391  * @return      ENOENT
392  *              if no matching name-value pair is found
393  *
394  * @return      ENOTSUP
395  *              if an encode/decode method is not supported
396  *
397  * @return      EINVAL
398  *              if there is an invalid argument
399  */
400 extern int set_uint64_array(
401 	nvlist_t *attrs, char *which, uint64_t *val, uint_t nelem);
402 
403 /*
404  * Get the named string array from the given nvlist_t.
405  *
406  * @param       attrs
407  *              the nvlist_t to search
408  *
409  * @param       which
410  *              the string key for this element in the list
411  *
412  * @param       val
413  *              RETURN: the value of the requested string array
414  *
415  * @param       nelem
416  *              RETURN: the number of elements in the array
417  *
418  * @return      0
419  *              if successful
420  *
421  * @return      ENOENT
422  *              if no matching name-value pair is found
423  *
424  * @return      ENOTSUP
425  *              if an encode/decode method is not supported
426  *
427  * @return      EINVAL
428  *              if there is an invalid argument
429  */
430 extern int get_string_array(
431 	nvlist_t *attrs, char *which, char ***val, uint_t *nelem);
432 
433 /*
434  * Set the named string array from the given nvlist_t.
435  *
436  * @param       attrs
437  *              the nvlist_t to search
438  *
439  * @param       which
440  *              the string key for this element in the list
441  *
442  * @param       val
443  *              the value of the requested string array
444  *
445  * @param       nelem
446  *              the number of elements in the array
447  *
448  * @return      0
449  *              if successful
450  *
451  * @return      ENOENT
452  *              if no matching name-value pair is found
453  *
454  * @return      ENOTSUP
455  *              if an encode/decode method is not supported
456  *
457  * @return      EINVAL
458  *              if there is an invalid argument
459  */
460 extern int set_string_array(
461 	nvlist_t *attrs, char *which, char **val, uint_t nelem);
462 
463 #ifdef __cplusplus
464 }
465 #endif
466 
467 #endif /* _VOLUME_NVPAIR_H */
468