Imported Upstream version 2.02.79
[platform/upstream/device-mapper.git] / liblvm / lvm2app.h
1 /*
2  * Copyright (C) 2008,2009,2010 Red Hat, Inc. All rights reserved.
3  *
4  * This file is part of LVM2.
5  *
6  * This copyrighted material is made available to anyone wishing to use,
7  * modify, copy, or redistribute it subject to the terms and conditions
8  * of the GNU Lesser General Public License v.2.1.
9  *
10  * You should have received a copy of the GNU Lesser General Public License
11  * along with this program; if not, write to the Free Software Foundation,
12  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
13  */
14 #ifndef _LIB_LVM2APP_H
15 #define _LIB_LVM2APP_H
16
17 #include <libdevmapper.h>
18
19 #include <stdint.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /******************************** WARNING ***********************************
26  *
27  * NOTE: This API is under development and subject to change at any time.
28  *
29  * Please send feedback to lvm-devel@redhat.com
30  *
31  *********************************** WARNING ********************************/
32
33 /*************************** Design Overview ********************************/
34
35 /**
36  * \mainpage LVM library API
37  *
38  * The API is designed around the following basic LVM objects:
39  * 1) Physical Volume (pv_t) 2) Volume Group (vg_t) 3) Logical Volume (lv_t).
40  *
41  * The library provides functions to list the objects in a system,
42  * get and set object properties (such as names, UUIDs, and sizes), as well
43  * as create/remove objects and perform more complex operations and
44  * transformations. Each object instance is represented by a handle, and
45  * handles are passed to and from the functions to perform the operations.
46  *
47  * A central object in the library is the Volume Group, represented by the
48  * VG handle, vg_t. Performing an operation on a PV or LV object first
49  * requires obtaining a VG handle. Once the vg_t has been obtained, it can
50  * be used to enumerate the pv_t and lv_t objects within that vg_t. Attributes
51  * of these objects can then be queried or changed.
52  *
53  * A volume group handle may be obtained with read or write permission.
54  * Any attempt to change a property of a pv_t, vg_t, or lv_t without
55  * obtaining write permission on the vg_t will fail with EPERM.
56  *
57  * An application first opening a VG read-only, then later wanting to change
58  * a property of an object must first close the VG and re-open with write
59  * permission. Currently liblvm provides no mechanism to determine whether
60  * the VG has changed on-disk in between these operations - this is the
61  * application's responsiblity. One way the application can ensure the VG
62  * has not changed is to save the "vg_seqno" field after opening the VG with
63  * READ permission. If the application later needs to modify the VG, it can
64  * close the VG and re-open with WRITE permission. It should then check
65  * whether the original "vg_seqno" obtained with READ permission matches
66  * the new one obtained with WRITE permission.
67  */
68
69 /**
70  * Retrieve the library version.
71  *
72  * The library version is the same format as the full LVM version.
73  * The format is as follows:
74  *    LVM_MAJOR.LVM_MINOR.LVM_PATCHLEVEL(LVM_LIBAPI)[-LVM_RELEASE]
75  * An application wishing to determine compatibility with a particular version
76  * of the library should check at least the LVM_MAJOR, LVM_MINOR, and
77  * LVM_LIBAPI numbers.  For example, assume the full LVM version is
78  * 2.02.50(1)-1.  The application should verify the "2.02" and the "(1)".
79  *
80  * \return  A string describing the library version.
81  */
82 const char *lvm_library_get_version(void);
83
84 /******************************** structures ********************************/
85
86 /**
87  * Opaque structures - do not use directly.  Internal structures may change
88  * without notice between releases, whereas this API will be changed much less
89  * frequently.  Backwards compatibility will normally be preserved in future
90  * releases.  On any occasion when the developers do decide to break backwards
91  * compatibility in any significant way, the LVM_LIBAPI number (included in
92  * the library's soname) will be incremented.
93  */
94 struct lvm;
95 struct physical_volume;
96 struct volume_group;
97 struct logical_volume;
98 struct lv_segment;
99 struct pv_segment;
100
101 /**
102  * \class lvm_t
103  *
104  * This is the base handle that is needed to open and create objects such as
105  * volume groups and logical volumes.  In addition, this handle provides a
106  * context for error handling information, saving any error number (see
107  * lvm_errno()) and error message (see lvm_errmsg()) that any function may
108  * generate.
109  */
110 typedef struct lvm *lvm_t;
111
112 /**
113  * \class vg_t
114  *
115  * The volume group object is a central object in the library, and can be
116  * either a read-only object or a read-write object depending on the function
117  * used to obtain the object handle. For example, lvm_vg_create() always
118  * returns a read/write handle, while lvm_vg_open() has a "mode" argument
119  * to define the read/write mode of the handle.
120  */
121 typedef struct volume_group *vg_t;
122
123 /**
124  * \class lv_t
125  *
126  * This logical volume object is bound to a vg_t and has the same
127  * read/write mode as the vg_t.  Changes will be written to disk
128  * when the vg_t gets committed to disk by calling lvm_vg_write().
129  */
130 typedef struct logical_volume *lv_t;
131
132 /**
133  * \class pv_t
134  *
135  * This physical volume object is bound to a vg_t and has the same
136  * read/write mode as the vg_t.  Changes will be written to disk
137  * when the vg_t gets committed to disk by calling lvm_vg_write().
138  */
139 typedef struct physical_volume *pv_t;
140
141 /**
142  * \class lvseg_t
143  *
144  * This lv segment object is bound to a lv_t.
145  */
146 typedef struct lv_segment *lvseg_t;
147
148 /**
149  * \class pvseg_t
150  *
151  * This pv segment object is bound to a pv_t.
152  */
153 typedef struct pv_segment *pvseg_t;
154
155 /**
156  * Logical Volume object list.
157  *
158  * Lists of these structures are returned by lvm_vg_list_lvs().
159  */
160 typedef struct lvm_lv_list {
161         struct dm_list list;
162         lv_t lv;
163 } lv_list_t;
164
165 /**
166  * Logical Volume Segment object list.
167  *
168  * Lists of these structures are returned by lvm_lv_list_lvsegs().
169  */
170 typedef struct lvm_lvseg_list {
171         struct dm_list list;
172         lvseg_t lvseg;
173 } lvseg_list_t;
174
175 /**
176  * Physical volume object list.
177  *
178  * Lists of these structures are returned by lvm_vg_list_pvs().
179  */
180 typedef struct lvm_pv_list {
181         struct dm_list list;
182         pv_t pv;
183 } pv_list_t;
184
185 /**
186  * Physical Volume Segment object list.
187  *
188  * Lists of these structures are returned by lvm_pv_list_pvsegs().
189  */
190 typedef struct lvm_pvseg_list {
191         struct dm_list list;
192         pvseg_t pvseg;
193 } pvseg_list_t;
194
195 /**
196  * String list.
197  *
198  * This string list contains read-only strings.
199  * Lists of these structures are returned by functions such as
200  * lvm_list_vg_names() and lvm_list_vg_uuids().
201  */
202 typedef struct lvm_str_list {
203         struct dm_list list;
204         const char *str;
205 } lvm_str_list_t;
206
207 /**
208  * Property Value
209  *
210  * This structure defines a single LVM property value for an LVM object.
211  * The structures are returned by functions such as
212  * lvm_vg_get_property().
213  *
214  * is_settable: indicates whether a 'set' function exists for this property
215  * is_string: indicates whether this property is a string (1) or not (0)
216  * is_integer: indicates whether this property is an integer (1) or not (0)
217  * is_valid: indicates whether 'value' is valid (1) or not (0)
218  */
219 typedef struct lvm_property_value {
220         uint32_t is_settable:1;
221         uint32_t is_string:1;
222         uint32_t is_integer:1;
223         uint32_t is_valid:1;
224         uint32_t padding:28;
225         union {
226                 const char *string;
227                 uint64_t integer;
228         } value;
229 } lvm_property_value_t;
230
231 /*************************** generic lvm handling ***************************/
232 /**
233  * Create a LVM handle.
234  *
235  * \memberof lvm_t
236  *
237  * Once all LVM operations have been completed, use lvm_quit() to release
238  * the handle and any associated resources.
239  *
240  * \param system_dir
241  * Set an alternative LVM system directory. Use NULL to use the
242  * default value. If the environment variable LVM_SYSTEM_DIR is set,
243  * it will override any system_dir setting.
244  *
245  * \return
246  * A valid LVM handle is returned or NULL if there has been a
247  * memory allocation problem. You have to check if an error occured
248  * with the lvm_error() function.
249  */
250 lvm_t lvm_init(const char *system_dir);
251
252 /**
253  * Destroy a LVM handle allocated with lvm_init().
254  *
255  * \memberof lvm_t
256  *
257  * This function should be used after all LVM operations are complete or after
258  * an unrecoverable error.  Destroying the LVM handle frees the memory and
259  * other resources associated with the handle.  Once destroyed, the handle
260  * cannot be used subsequently.
261  *
262  * \param   libh
263  * Handle obtained from lvm_init().
264  */
265 void lvm_quit(lvm_t libh);
266
267 /**
268  * Reload the original configuration from the system directory.
269  *
270  * \memberof lvm_t
271  *
272  * This function should be used when any LVM configuration changes in the LVM
273  * system_dir or by another lvm_config* function, and the change is needed by
274  * the application.
275  *
276  * \param   libh
277  * Handle obtained from lvm_init().
278  *
279  * \return
280  * 0 (success) or -1 (failure).
281  */
282 int lvm_config_reload(lvm_t libh);
283
284 /**
285  * Override the LVM configuration with a configuration string.
286  *
287  * \memberof lvm_t
288  *
289  * This function is equivalent to the --config option on lvm commands.
290  * Once this API has been used to over-ride the configuration,
291  * use lvm_config_reload() to apply the new settings.
292  *
293  * \param   libh
294  * Handle obtained from lvm_init().
295  *
296  * \param   config_string
297  * LVM configuration string to apply.  See the lvm.conf file man page
298  * for the format of the config string.
299  *
300  * \return
301  * 0 (success) or -1 (failure).
302  */
303 int lvm_config_override(lvm_t libh, const char *config_string);
304
305 /**
306  * Return stored error no describing last LVM API error.
307  *
308  * \memberof lvm_t
309  *
310  * Users of liblvm should use lvm_errno to determine the details of a any
311  * failure of the last call.  A basic success or fail is always returned by
312  * every function, either by returning a 0 or -1, or a non-NULL / NULL.
313  * If a function has failed, lvm_errno may be used to get a more specific
314  * error code describing the failure.  In this way, lvm_errno may be used
315  * after every function call, even after a 'get' function call that simply
316  * returns a value.
317  *
318  * \param   libh
319  * Handle obtained from lvm_init().
320  *
321  * \return
322  * An errno value describing the last LVM error.
323  */
324 int lvm_errno(lvm_t libh);
325
326 /**
327  * Return stored error message describing last LVM error.
328  *
329  * \memberof lvm_t
330  *
331  * This function may be used in conjunction with lvm_errno() to obtain more
332  * specific error information for a function that is known to have failed.
333  *
334  * \param   libh
335  * Handle obtained from lvm_init().
336  *
337  * \return
338  * An error string describing the last LVM error.
339  */
340 const char *lvm_errmsg(lvm_t libh);
341
342 /**
343  * Scan all devices on the system for VGs and LVM metadata.
344  *
345  * \memberof lvm_t
346  *
347  * \return
348  * 0 (success) or -1 (failure).
349  */
350 int lvm_scan(lvm_t libh);
351
352 /**
353  * Return the list of volume group names.
354  *
355  * \memberof lvm_t
356  *
357  * The memory allocated for the list is tied to the lvm_t handle and will be
358  * released when lvm_quit() is called.
359  *
360  * NOTE: This function normally does not scan devices in the system for LVM
361  * metadata.  To scan the system, use lvm_scan().
362  *
363  * To process the list, use the dm_list iterator functions.  For example:
364  *      vg_t vg;
365  *      struct dm_list *vgnames;
366  *      struct lvm_str_list *strl;
367  *
368  *      vgnames = lvm_list_vg_names(libh);
369  *      dm_list_iterate_items(strl, vgnames) {
370  *              vgname = strl->str;
371  *              vg = lvm_vg_open(libh, vgname, "r");
372  *              // do something with vg
373  *              lvm_vg_close(vg);
374  *      }
375  *
376  *
377  * \return
378  * A list with entries of type struct lvm_str_list, containing the
379  * VG name strings of the Volume Groups known to the system.
380  * NULL is returned if unable to allocate memory.
381  * An empty list (verify with dm_list_empty) is returned if no VGs
382  * exist on the system.
383  */
384 struct dm_list *lvm_list_vg_names(lvm_t libh);
385
386 /**
387  * Return the list of volume group uuids.
388  *
389  * \memberof lvm_t
390  *
391  * The memory allocated for the list is tied to the lvm_t handle and will be
392  * released when lvm_quit() is called.
393  *
394  * NOTE: This function normally does not scan devices in the system for LVM
395  * metadata.  To scan the system, use lvm_scan().
396  *
397  * \param   libh
398  * Handle obtained from lvm_init().
399  *
400  * \return
401  * A list with entries of type struct lvm_str_list, containing the
402  * VG UUID strings of the Volume Groups known to the system.
403  * NULL is returned if unable to allocate memory.
404  * An empty list (verify with dm_list_empty) is returned if no VGs
405  * exist on the system.
406  */
407 struct dm_list *lvm_list_vg_uuids(lvm_t libh);
408
409 /**
410  * Return the volume group name given a PV UUID
411  *
412  * \memberof lvm_t
413  *
414  * The memory allocated for the name is tied to the lvm_t handle and will be
415  * released when lvm_quit() is called.
416  *
417  * NOTE: This function may scan devices in the system for LVM metadata.
418  *
419  * \param   libh
420  * Handle obtained from lvm_init().
421  *
422  * \return
423  * The volume group name for the given PV UUID.
424  * NULL is returned if the PV UUID is not associated with a volume group.
425  */
426 const char *lvm_vgname_from_pvid(lvm_t libh, const char *pvid);
427
428 /**
429  * Return the volume group name given a device name
430  *
431  * \memberof lvm_t
432  *
433  * The memory allocated for the name is tied to the lvm_t handle and will be
434  * released when lvm_quit() is called.
435  *
436  * NOTE: This function may scan devices in the system for LVM metadata.
437  *
438  * \param   libh
439  * Handle obtained from lvm_init().
440  *
441  * \return
442  * The volume group name for the given device name.
443  * NULL is returned if the device is not an LVM device.
444  *
445  */
446 const char *lvm_vgname_from_device(lvm_t libh, const char *device);
447
448 /**
449  * Open an existing VG.
450  *
451  * Open a VG for reading or writing.
452  *
453  * \memberof lvm_t
454  *
455  * \param   libh
456  * Handle obtained from lvm_init().
457  *
458  * \param   vgname
459  * Name of the VG to open.
460  *
461  * \param   mode
462  * Open mode - either "r" (read) or "w" (read/write).
463  * Any other character results in an error with EINVAL set.
464  *
465  * \param   flags
466  * Open flags - currently ignored.
467  *
468  * \return  non-NULL VG handle (success) or NULL (failure).
469  */
470 vg_t lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
471                   uint32_t flags);
472
473 /**
474  * Create a VG with default parameters.
475  *
476  * \memberof lvm_t
477  *
478  * This function creates a Volume Group object in memory.
479  * Upon success, other APIs may be used to set non-default parameters.
480  * For example, to set a non-default extent size, use lvm_vg_set_extent_size().
481  * Next, to add physical storage devices to the volume group, use
482  * lvm_vg_extend() for each device.
483  * Once all parameters are set appropriately and all devices are added to the
484  * VG, use lvm_vg_write() to commit the new VG to disk, and lvm_vg_close() to
485  * release the VG handle.
486  *
487  * \param   libh
488  * Handle obtained from lvm_init().
489  *
490  * \param   vg_name
491  * Name of the VG to open.
492  *
493  * \return
494  * non-NULL vg handle (success) or NULL (failure)
495  */
496 vg_t lvm_vg_create(lvm_t libh, const char *vg_name);
497
498 /*************************** volume group handling **************************/
499
500 /**
501  * Return a list of LV handles for a given VG handle.
502  *
503  * \memberof vg_t
504  *
505  * \param   vg
506  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
507  *
508  * \return
509  * A list of lvm_lv_list structures containing lv handles for this vg.
510  * If no LVs exist on the given VG, NULL is returned.
511  */
512 struct dm_list *lvm_vg_list_lvs(vg_t vg);
513
514 /**
515  * Return a list of PV handles for a given VG handle.
516  *
517  * \memberof vg_t
518  *
519  * \param   vg
520  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
521  *
522  * \return
523  * A list of lvm_pv_list structures containing pv handles for this vg.
524  * If no PVs exist on the given VG, NULL is returned.
525  */
526 struct dm_list *lvm_vg_list_pvs(vg_t vg);
527
528 /**
529  * Write a VG to disk.
530  *
531  * \memberof vg_t
532  *
533  * This function commits the Volume Group object referenced by the VG handle
534  * to disk. Upon failure, retry the operation and/or release the VG handle
535  * with lvm_vg_close().
536  *
537  * \param   vg
538  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
539  *
540  * \return
541  * 0 (success) or -1 (failure).
542  */
543 int lvm_vg_write(vg_t vg);
544
545 /**
546  * Remove a VG from the system.
547  *
548  * \memberof vg_t
549  *
550  * This function removes a Volume Group object in memory, and requires
551  * calling lvm_vg_write() to commit the removal to disk.
552  *
553  * \param   vg
554  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
555  *
556  * \return
557  * 0 (success) or -1 (failure).
558  */
559 int lvm_vg_remove(vg_t vg);
560
561 /**
562  * Close a VG opened with lvm_vg_create or lvm_vg_open().
563  *
564  * \memberof vg_t
565  *
566  * This function releases a VG handle and any resources associated with the
567  * handle.
568  *
569  * \param   vg
570  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
571  *
572  * \return
573  * 0 (success) or -1 (failure).
574  */
575 int lvm_vg_close(vg_t vg);
576
577 /**
578  * Extend a VG by adding a device.
579  *
580  * \memberof vg_t
581  *
582  * This function requires calling lvm_vg_write() to commit the change to disk.
583  * After successfully adding a device, use lvm_vg_write() to commit the new VG
584  * to disk.  Upon failure, retry the operation or release the VG handle with
585  * lvm_vg_close().
586  * If the device is not initialized for LVM use, it will be initialized
587  * before adding to the VG.  Although some internal checks are done,
588  * the caller should be sure the device is not in use by other subsystems
589  * before calling lvm_vg_extend().
590  *
591  * \param   vg
592  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
593  *
594  * \param   device
595  * Absolute pathname of device to add to VG.
596  *
597  * \return
598  * 0 (success) or -1 (failure).
599  */
600 int lvm_vg_extend(vg_t vg, const char *device);
601
602 /**
603  * Reduce a VG by removing an unused device.
604  *
605  * \memberof vg_t
606  *
607  * This function requires calling lvm_vg_write() to commit the change to disk.
608  * After successfully removing a device, use lvm_vg_write() to commit the new VG
609  * to disk.  Upon failure, retry the operation or release the VG handle with
610  * lvm_vg_close().
611  *
612  * \param   vg
613  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
614  *
615  * \param   device
616  * Name of device to remove from VG.
617  *
618  * \return
619  * 0 (success) or -1 (failure).
620  */
621 int lvm_vg_reduce(vg_t vg, const char *device);
622
623 /**
624  * Add a tag to a VG.
625  *
626  * \memberof vg_t
627  *
628  * This function requires calling lvm_vg_write() to commit the change to disk.
629  * After successfully adding a tag, use lvm_vg_write() to commit the
630  * new VG to disk.  Upon failure, retry the operation or release the VG handle
631  * with lvm_vg_close().
632  *
633  * \param   vg
634  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
635  *
636  * \param   tag
637  * Tag to add to the VG.
638  *
639  * \return
640  * 0 (success) or -1 (failure).
641  */
642 int lvm_vg_add_tag(vg_t vg, const char *tag);
643
644 /**
645  * Remove a tag from a VG.
646  *
647  * \memberof vg_t
648  *
649  * This function requires calling lvm_vg_write() to commit the change to disk.
650  * After successfully removing a tag, use lvm_vg_write() to commit the
651  * new VG to disk.  Upon failure, retry the operation or release the VG handle
652  * with lvm_vg_close().
653  *
654  * \param   vg
655  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
656  *
657  * \param   tag
658  * Tag to remove from VG.
659  *
660  * \return
661  * 0 (success) or -1 (failure).
662  */
663 int lvm_vg_remove_tag(vg_t vg, const char *tag);
664
665 /**
666  * Set the extent size of a VG.
667  *
668  * \memberof vg_t
669  *
670  * This function requires calling lvm_vg_write() to commit the change to disk.
671  * After successfully setting a new extent size, use lvm_vg_write() to commit
672  * the new VG to disk.  Upon failure, retry the operation or release the VG
673  * handle with lvm_vg_close().
674  *
675  * \param   vg
676  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
677  *
678  * \param   new_size
679  * New extent size in bytes.
680  *
681  * \return
682  * 0 (success) or -1 (failure).
683  */
684 int lvm_vg_set_extent_size(vg_t vg, uint32_t new_size);
685
686 /**
687  * Get whether or not a volume group is clustered.
688  *
689  * \memberof vg_t
690  *
691  * \param   vg
692  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
693  *
694  * \return
695  * 1 if the VG is clustered, 0 if not
696  */
697 uint64_t lvm_vg_is_clustered(vg_t vg);
698
699 /**
700  * Get whether or not a volume group is exported.
701  *
702  * \memberof vg_t
703  *
704  * \param   vg
705  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
706  *
707  * \return
708  * 1 if the VG is exported, 0 if not
709  */
710 uint64_t lvm_vg_is_exported(vg_t vg);
711
712 /**
713  * Get whether or not a volume group is a partial volume group.
714  *
715  * \memberof vg_t
716  *
717  * When one or more physical volumes belonging to the volume group
718  * are missing from the system the volume group is a partial volume
719  * group.
720  *
721  * \param   vg
722  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
723  *
724  * \return
725  * 1 if the VG is PVs, 0 if not
726  */
727 uint64_t lvm_vg_is_partial(vg_t vg);
728
729 /**
730  * Get the current metadata sequence number of a volume group.
731  *
732  * \memberof vg_t
733  *
734  * The metadata sequence number is incrented for each metadata change.
735  * Applications may use the sequence number to determine if any LVM objects
736  * have changed from a prior query.
737  *
738  * \param   vg
739  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
740  *
741  * \return
742  * Metadata sequence number.
743  */
744 uint64_t lvm_vg_get_seqno(const vg_t vg);
745
746 /**
747  * Get the current uuid of a volume group.
748  *
749  * \memberof vg_t
750  *
751  * The memory allocated for the uuid is tied to the vg_t handle and will be
752  * released when lvm_vg_close() is called.
753  *
754  * \param   vg
755  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
756  *
757  * \return
758  * Copy of the uuid string.
759  */
760 const char *lvm_vg_get_uuid(const vg_t vg);
761
762 /**
763  * Get the current name of a volume group.
764  *
765  * \memberof vg_t
766  *
767  * The memory allocated for the name is tied to the vg_t handle and will be
768  * released when lvm_vg_close() is called.
769  *
770  * \param   vg
771  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
772  *
773  * \return
774  * Copy of the name.
775  */
776 const char *lvm_vg_get_name(const vg_t vg);
777
778 /**
779  * Get the current size in bytes of a volume group.
780  *
781  * \memberof vg_t
782  *
783  * \param   vg
784  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
785  *
786  * \return
787  * Size in bytes.
788  */
789 uint64_t lvm_vg_get_size(const vg_t vg);
790
791 /**
792  * Get the current unallocated space in bytes of a volume group.
793  *
794  * \memberof vg_t
795  *
796  * \param   vg
797  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
798  *
799  * \return
800  * Free size in bytes.
801  */
802 uint64_t lvm_vg_get_free_size(const vg_t vg);
803
804 /**
805  * Get the current extent size in bytes of a volume group.
806  *
807  * \memberof vg_t
808  *
809  * \param   vg
810  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
811  *
812  * \return
813  * Extent size in bytes.
814  */
815 uint64_t lvm_vg_get_extent_size(const vg_t vg);
816
817 /**
818  * Get the current number of total extents of a volume group.
819  *
820  * \memberof vg_t
821  *
822  * \param   vg
823  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
824  *
825  * \return
826  * Extent count.
827  */
828 uint64_t lvm_vg_get_extent_count(const vg_t vg);
829
830 /**
831  * Get the current number of free extents of a volume group.
832  *
833  * \memberof vg_t
834  *
835  * \param   vg
836  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
837  *
838  * \return
839  * Free extent count.
840  */
841 uint64_t lvm_vg_get_free_extent_count(const vg_t vg);
842
843 /**
844  * Get the current number of physical volumes of a volume group.
845  *
846  * \memberof vg_t
847  *
848  * \param   vg
849  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
850  *
851  * \return
852  * Physical volume count.
853  */
854 uint64_t lvm_vg_get_pv_count(const vg_t vg);
855
856 /**
857  * Get the maximum number of physical volumes allowed in a volume group.
858  *
859  * \memberof vg_t
860  *
861  * \param   vg
862  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
863  *
864  * \return
865  * Maximum number of physical volumes allowed in a volume group.
866  */
867 uint64_t lvm_vg_get_max_pv(const vg_t vg);
868
869 /**
870  * Get the maximum number of logical volumes allowed in a volume group.
871  *
872  * \memberof vg_t
873  *
874  * \param   vg
875  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
876  *
877  * \return
878  * Maximum number of logical volumes allowed in a volume group.
879  */
880 uint64_t lvm_vg_get_max_lv(const vg_t vg);
881
882 /**
883  * Return the list of volume group tags.
884  *
885  * \memberof vg_t
886  *
887  * The memory allocated for the list is tied to the vg_t handle and will be
888  * released when lvm_vg_close() is called.
889  *
890  * To process the list, use the dm_list iterator functions.  For example:
891  *      vg_t vg;
892  *      struct dm_list *tags;
893  *      struct lvm_str_list *strl;
894  *
895  *      tags = lvm_vg_get_tags(vg);
896  *      dm_list_iterate_items(strl, tags) {
897  *              tag = strl->str;
898  *              // do something with tag
899  *      }
900  *
901  *
902  * \return
903  * A list with entries of type struct lvm_str_list, containing the
904  * tag strings attached to volume group.
905  * If no tags are attached to the given VG, an empty list is returned
906  * (check with dm_list_empty()).
907  * If there is a problem obtaining the list of tags, NULL is returned.
908  */
909 struct dm_list *lvm_vg_get_tags(const vg_t vg);
910
911 /**
912  * Get the value of a VG property
913  *
914  * \memberof vg_t
915  *
916  * \param   vg
917  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
918  *
919  * \param   name
920  * Name of property to query.  See vgs man page for full list of properties
921  * that may be queried.
922  *
923  * The memory allocated for a string property value is tied to the vg_t
924  * handle and will be released when lvm_vg_close() is called.
925  *
926  * Example:
927  *      lvm_property_value v;
928  *      char *prop_name = "vg_mda_count";
929  *
930  *      v = lvm_vg_get_property(vg, prop_name);
931  *      if (!v.is_valid) {
932  *           printf("Invalid property name or unable to query"
933  *                  "'%s', errno = %d.\n", prop_name, lvm_errno(libh));
934  *           return;
935  *      }
936  *      if (v.is_string)
937  *           printf(", value = %s\n", v.value.string);
938  *      if (v.is_integer)
939  *           printf(", value = %"PRIu64"\n", v.value.integer);
940  *
941  *
942  * \return
943  * lvm_property_value structure that will contain the current
944  * value of the property.  Caller should check 'is_valid' flag before using
945  * the value.  If 'is_valid' is not set, caller should check lvm_errno()
946  * for specific error.
947  */
948 struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name);
949
950 /**
951  * Set the value of a VG property.  Note that the property must be
952  * a 'settable' property, as evidenced by the 'is_settable' flag
953  * when querying the property.
954  *
955  * \memberof vg_t
956  *
957  * The memory allocated for a string property value is tied to the vg_t
958  * handle and will be released when lvm_vg_close() is called.
959  *
960  * Example (integer):
961  *      lvm_property_value copies;
962  *
963  *      if (lvm_vg_get_property(vg, "vg_mda_copies", &copies) < 0) {
964  *              // Error - unable to query property
965  *      }
966  *      if (!copies.is_settable) {
967  *              // Error - property not settable
968  *      }
969  *      copies.value.integer = 2;
970  *      if (lvm_vg_set_property(vg, "vg_mda_copies", &copies) < 0) {
971  *              // handle error
972  *      }
973  *
974  * \return
975  * 0 (success) or -1 (failure).
976  */
977 int lvm_vg_set_property(const vg_t vg, const char *name,
978                         struct lvm_property_value *value);
979
980 /************************** logical volume handling *************************/
981
982 /**
983  * Create a linear logical volume.
984  * This function commits the change to disk and does _not_ require calling
985  * lvm_vg_write().
986  * NOTE: The commit behavior of this function is subject to change
987  * as the API is developed.
988  *
989  * \param   vg
990  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
991  *
992  * \param   name
993  * Name of logical volume to create.
994  *
995  * \param   size
996  * Size of logical volume in extents.
997  *
998  * \return
999  * non-NULL handle to an LV object created, or NULL if creation fails.
1000  *
1001  */
1002 lv_t lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size);
1003
1004 /**
1005  * Return a list of lvseg handles for a given LV handle.
1006  *
1007  * \memberof lv_t
1008  *
1009  * \param   lv
1010  * Logical volume handle.
1011  *
1012  * \return
1013  * A list of lvm_lvseg_list structures containing lvseg handles for this lv.
1014  */
1015 struct dm_list *lvm_lv_list_lvsegs(lv_t lv);
1016
1017 /**
1018  * Lookup an LV handle in a VG by the LV name.
1019  *
1020  * \memberof lv_t
1021  *
1022  * \param   vg
1023  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
1024  *
1025  * \param   name
1026  * Name of LV to lookup.
1027  *
1028  * \return
1029  * non-NULL handle to the LV 'name' attached to the VG.
1030  * NULL is returned if the LV name is not associated with the VG handle.
1031  */
1032 lv_t lvm_lv_from_name(vg_t vg, const char *name);
1033
1034 /**
1035  * Lookup an LV handle in a VG by the LV uuid.
1036  * The form of the uuid may be either the formatted, human-readable form,
1037  * or the non-formatted form.
1038  *
1039  * \memberof lv_t
1040  *
1041  * \param   vg
1042  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
1043  *
1044  * \param   uuid
1045  * UUID of LV to lookup.
1046  *
1047  * \return
1048  * non-NULL handle to the LV with 'uuid' attached to the VG.
1049  * NULL is returned if the LV uuid is not associated with the VG handle.
1050  */
1051 lv_t lvm_lv_from_uuid(vg_t vg, const char *uuid);
1052
1053 /**
1054  * Activate a logical volume.
1055  *
1056  * \memberof lv_t
1057  *
1058  * This function is the equivalent of the lvm command "lvchange -ay".
1059  *
1060  * NOTE: This function cannot currently handle LVs with an in-progress pvmove or
1061  * lvconvert.
1062  *
1063  * \param   lv
1064  * Logical volume handle.
1065  *
1066  * \return
1067  * 0 (success) or -1 (failure).
1068  */
1069 int lvm_lv_activate(lv_t lv);
1070
1071 /**
1072  * Deactivate a logical volume.
1073  *
1074  * \memberof lv_t
1075  *
1076  * This function is the equivalent of the lvm command "lvchange -an".
1077  *
1078  * \param   lv
1079  * Logical volume handle.
1080  *
1081  * \return
1082  * 0 (success) or -1 (failure).
1083  */
1084 int lvm_lv_deactivate(lv_t lv);
1085
1086 /**
1087  * Remove a logical volume from a volume group.
1088  *
1089  * \memberof lv_t
1090  *
1091  * This function commits the change to disk and does _not_ require calling
1092  * lvm_vg_write().
1093  * NOTE: The commit behavior of this function is subject to change
1094  * as the API is developed.
1095  * Currently only removing linear LVs are possible.
1096  *
1097  * \param   lv
1098  * Logical volume handle.
1099  *
1100  * \return
1101  * 0 (success) or -1 (failure).
1102  */
1103 int lvm_vg_remove_lv(lv_t lv);
1104
1105 /**
1106  * Get the current name of a logical volume.
1107  *
1108  * \memberof lv_t
1109  *
1110  * The memory allocated for the uuid is tied to the vg_t handle and will be
1111  * released when lvm_vg_close() is called.
1112  *
1113  * \param   lv
1114  * Logical volume handle.
1115  *
1116  * \return
1117  * Copy of the uuid string.
1118  */
1119 const char *lvm_lv_get_uuid(const lv_t lv);
1120
1121 /**
1122  * Get the current uuid of a logical volume.
1123  *
1124  * \memberof lv_t
1125  *
1126  * The memory allocated for the name is tied to the vg_t handle and will be
1127  * released when lvm_vg_close() is called.
1128  *
1129  * \param   lv
1130  * Logical volume handle.
1131  *
1132  * \return
1133  * Copy of the name.
1134  */
1135 const char *lvm_lv_get_name(const lv_t lv);
1136
1137 /**
1138  * Get the current size in bytes of a logical volume.
1139  *
1140  * \memberof lv_t
1141  *
1142  * \param   lv
1143  * Logical volume handle.
1144  *
1145  * \return
1146  * Size in bytes.
1147  */
1148 uint64_t lvm_lv_get_size(const lv_t lv);
1149
1150 /**
1151  * Get the value of a LV property
1152  *
1153  * \memberof lv_t
1154  *
1155  * \param   lv
1156  * Logical volume handle.
1157  *
1158  * \param   name
1159  * Name of property to query.  See lvs man page for full list of properties
1160  * that may be queried.
1161  *
1162  * The memory allocated for a string property value is tied to the vg_t
1163  * handle and will be released when lvm_vg_close() is called.
1164  *
1165  * Example:
1166  *      lvm_property_value v;
1167  *      char *prop_name = "seg_count";
1168  *
1169  *      v = lvm_lv_get_property(lv, prop_name);
1170  *      if (!v.is_valid) {
1171  *           printf("Invalid property name or unable to query"
1172  *                  "'%s', errno = %d.\n", prop_name, lvm_errno(libh));
1173  *           return;
1174  *      }
1175  *      if (v.is_string)
1176  *           printf(", value = %s\n", v.value.string);
1177  *      if (v.is_integer)
1178  *           printf(", value = %"PRIu64"\n", v.value.integer);
1179  *
1180  * \return
1181  * lvm_property_value structure that will contain the current
1182  * value of the property.  Caller should check 'is_valid' flag before using
1183  * the value.  If 'is_valid' is not set, caller should check lvm_errno()
1184  * for specific error.
1185  */
1186 struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name);
1187
1188 /**
1189  * Get the value of a LV segment property
1190  *
1191  * \memberof lv_t
1192  *
1193  * \param   lvseg
1194  * Logical volume segment handle.
1195  *
1196  * \param   name
1197  * Name of property to query.  See lvs man page for full list of properties
1198  * that may be queried.
1199  *
1200  * The memory allocated for a string property value is tied to the vg_t
1201  * handle and will be released when lvm_vg_close() is called.
1202  *
1203  * Example:
1204  *      lvm_property_value v;
1205  *      char *prop_name = "seg_start_pe";
1206  *
1207  *      v = lvm_lvseg_get_property(lvseg, prop_name);
1208  *      if (lvm_errno(libh) || !v.is_valid) {
1209  *           // handle error
1210  *           printf("Invalid property name or unable to query"
1211  *                  "'%s'.\n", prop_name);
1212  *           return;
1213  *      }
1214  *      if (v.is_string)
1215  *           printf(", value = %s\n", v.value.string);
1216  *      else
1217  *           printf(", value = %"PRIu64"\n", v.value.integer);
1218  *
1219  * \return
1220  * lvm_property_value structure that will contain the current
1221  * value of the property.  Caller should check lvm_errno() as well
1222  * as 'is_valid' flag before using the value.
1223  */
1224 struct lvm_property_value lvm_lvseg_get_property(const lvseg_t lvseg,
1225                                                  const char *name);
1226
1227 /**
1228  * Get the current activation state of a logical volume.
1229  *
1230  * \memberof lv_t
1231  *
1232  * \param   lv
1233  * Logical volume handle.
1234  *
1235  * \return
1236  * 1 if the LV is active in the kernel, 0 if not
1237  */
1238 uint64_t lvm_lv_is_active(const lv_t lv);
1239
1240 /**
1241  * Get the current suspended state of a logical volume.
1242  *
1243  * \memberof lv_t
1244  *
1245  * \param   lv
1246  * Logical volume handle.
1247  *
1248  * \return
1249  * 1 if the LV is suspended in the kernel, 0 if not
1250  */
1251 uint64_t lvm_lv_is_suspended(const lv_t lv);
1252
1253 /**
1254  * Add a tag to an LV.
1255  *
1256  * \memberof lv_t
1257  *
1258  * This function requires calling lvm_vg_write() to commit the change to disk.
1259  * After successfully adding a tag, use lvm_vg_write() to commit the
1260  * new VG to disk.  Upon failure, retry the operation or release the VG handle
1261  * with lvm_vg_close().
1262  *
1263  * \param   lv
1264  * Logical volume handle.
1265  *
1266  * \param   tag
1267  * Tag to add to an LV.
1268  *
1269  * \return
1270  * 0 (success) or -1 (failure).
1271  */
1272 int lvm_lv_add_tag(lv_t lv, const char *tag);
1273
1274 /**
1275  * Remove a tag from an LV.
1276  *
1277  * \memberof lv_t
1278  *
1279  * This function requires calling lvm_vg_write() to commit the change to disk.
1280  * After successfully removing a tag, use lvm_vg_write() to commit the
1281  * new VG to disk.  Upon failure, retry the operation or release the VG handle
1282  * with lvm_vg_close().
1283  *
1284  * \param   lv
1285  * Logical volume handle.
1286  *
1287  * \param   tag
1288  * Tag to remove from LV.
1289  *
1290  * \return
1291  * 0 (success) or -1 (failure).
1292  */
1293 int lvm_lv_remove_tag(lv_t lv, const char *tag);
1294
1295 /**
1296  * Return the list of logical volume tags.
1297  *
1298  * \memberof lv_t
1299  *
1300  * The memory allocated for the list is tied to the vg_t handle and will be
1301  * released when lvm_vg_close() is called.
1302  *
1303  * To process the list, use the dm_list iterator functions.  For example:
1304  *      lv_t lv;
1305  *      struct dm_list *tags;
1306  *      struct lvm_str_list *strl;
1307  *
1308  *      tags = lvm_lv_get_tags(lv);
1309  *      dm_list_iterate_items(strl, tags) {
1310  *              tag = strl->str;
1311  *              // do something with tag
1312  *      }
1313  *
1314  *
1315  * \return
1316  * A list with entries of type struct lvm_str_list, containing the
1317  * tag strings attached to volume group.
1318  * If no tags are attached to the LV, an empty list is returned
1319  * (check with dm_list_empty()).
1320  * If there is a problem obtaining the list of tags, NULL is returned.
1321  */
1322 struct dm_list *lvm_lv_get_tags(const lv_t lv);
1323
1324
1325 /**
1326  * Resize logical volume to new_size bytes.
1327  *
1328  * \memberof lv_t
1329  *
1330  * NOTE: This function is currently not implemented.
1331  *
1332  * \param   lv
1333  * Logical volume handle.
1334  *
1335  * \param   new_size
1336  * New size in bytes.
1337  *
1338  * \return
1339  * 0 (success) or -1 (failure).
1340  *
1341  */
1342 int lvm_lv_resize(const lv_t lv, uint64_t new_size);
1343
1344 /************************** physical volume handling ************************/
1345
1346 /**
1347  * Physical volume handling should not be needed anymore. Only physical volumes
1348  * bound to a vg contain useful information. Therefore the creation,
1349  * modification and the removal of orphan physical volumes is not suported.
1350  */
1351
1352 /**
1353  * Get the current uuid of a physical volume.
1354  *
1355  * \memberof pv_t
1356  *
1357  * The memory allocated for the uuid is tied to the vg_t handle and will be
1358  * released when lvm_vg_close() is called.
1359  *
1360  * \param   pv
1361  * Physical volume handle.
1362  *
1363  * \return
1364  * Copy of the uuid string.
1365  */
1366 const char *lvm_pv_get_uuid(const pv_t pv);
1367
1368 /**
1369  * Get the current name of a physical volume.
1370  *
1371  * \memberof pv_t
1372  *
1373  * The memory allocated for the name is tied to the vg_t handle and will be
1374  * released when lvm_vg_close() is called.
1375  *
1376  * \param   pv
1377  * Physical volume handle.
1378  *
1379  * \return
1380  * Copy of the name.
1381  */
1382 const char *lvm_pv_get_name(const pv_t pv);
1383
1384 /**
1385  * Get the current number of metadata areas in the physical volume.
1386  *
1387  * \memberof pv_t
1388  *
1389  * \param   pv
1390  * Physical volume handle.
1391  *
1392  * \return
1393  * Number of metadata areas in the PV.
1394  */
1395 uint64_t lvm_pv_get_mda_count(const pv_t pv);
1396
1397 /**
1398  * Get the current size in bytes of a device underlying a
1399  * physical volume.
1400  *
1401  * \memberof pv_t
1402  *
1403  * \param   pv
1404  * Physical volume handle.
1405  *
1406  * \return
1407  * Size in bytes.
1408  */
1409 uint64_t lvm_pv_get_dev_size(const pv_t pv);
1410
1411 /**
1412  * Get the current size in bytes of a physical volume.
1413  *
1414  * \memberof pv_t
1415  *
1416  * \param   pv
1417  * Physical volume handle.
1418  *
1419  * \return
1420  * Size in bytes.
1421  */
1422 uint64_t lvm_pv_get_size(const pv_t pv);
1423
1424 /**
1425  * Get the current unallocated space in bytes of a physical volume.
1426  *
1427  * \memberof pv_t
1428  *
1429  * \param   pv
1430  * Physical volume handle.
1431  *
1432  * \return
1433  * Free size in bytes.
1434  */
1435 uint64_t lvm_pv_get_free(const pv_t pv);
1436
1437 /**
1438  * Get the value of a PV property
1439  *
1440  * \memberof pv_t
1441  *
1442  * \param   pv
1443  * Physical volume handle.
1444  *
1445  * \param   name
1446  * Name of property to query.  See pvs man page for full list of properties
1447  * that may be queried.
1448  *
1449  * The memory allocated for a string property value is tied to the vg_t handle
1450  * and will be released when lvm_vg_close() is called. For "percent" values
1451  * (those obtained for copy_percent and snap_percent properties), please see
1452  * percent_range_t and lvm_percent_to_float().
1453  *
1454  * Example:
1455  *      lvm_property_value value;
1456  *      char *prop_name = "pv_mda_count";
1457  *
1458  *      v = lvm_pv_get_property(pv, prop_name);
1459  *      if (!v.is_valid) {
1460  *           printf("Invalid property name or unable to query"
1461  *                  "'%s', errno = %d.\n", prop_name, lvm_errno(libh));
1462  *           return;
1463  *      }
1464  *      if (v.is_string)
1465  *           printf(", value = %s\n", v.value.string);
1466  *      if (v.is_integer)
1467  *           printf(", value = %"PRIu64"\n", v.value.integer);
1468  *
1469  * \return
1470  * lvm_property_value structure that will contain the current
1471  * value of the property.  Caller should check 'is_valid' flag before using
1472  * the value.  If 'is_valid' is not set, caller should check lvm_errno()
1473  * for specific error.
1474  */
1475 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name);
1476
1477 /**
1478  * Get the value of a PV segment property
1479  *
1480  * \memberof pv_t
1481  *
1482  * \param   pvseg
1483  * Physical volume segment handle.
1484  *
1485  * \param   name
1486  * Name of property to query.  See pvs man page for full list of properties
1487  * that may be queried.
1488  *
1489  * The memory allocated for a string property value is tied to the vg_t
1490  * handle and will be released when lvm_vg_close() is called.
1491  *
1492  * Example:
1493  *      lvm_property_value v;
1494  *      char *prop_name = "pvseg_start";
1495  *
1496  *      v = lvm_pvseg_get_property(pvseg, prop_name);
1497  *      if (lvm_errno(libh) || !v.is_valid) {
1498  *           // handle error
1499  *           printf("Invalid property name or unable to query"
1500  *                  "'%s'.\n", prop_name);
1501  *           return;
1502  *      }
1503  *      if (v.is_string)
1504  *           printf(", value = %s\n", v.value.string);
1505  *      else
1506  *           printf(", value = %"PRIu64"\n", v.value.integer);
1507  *
1508  * \return
1509  * lvm_property_value structure that will contain the current
1510  * value of the property.  Caller should check lvm_errno() as well
1511  * as 'is_valid' flag before using the value.
1512  */
1513 struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
1514                                                  const char *name);
1515
1516 /**
1517  * Return a list of pvseg handles for a given PV handle.
1518  *
1519  * \memberof pv_t
1520  *
1521  * \param   pv
1522  * Physical volume handle.
1523  *
1524  * \return
1525  * A list of lvm_pvseg_list structures containing pvseg handles for this pv.
1526  */
1527 struct dm_list *lvm_pv_list_pvsegs(pv_t pv);
1528
1529 /**
1530  * Lookup an PV handle in a VG by the PV name.
1531  *
1532  * \memberof pv_t
1533  *
1534  * \param   vg
1535  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
1536  *
1537  * \param   name
1538  * Name of PV to lookup.
1539  *
1540  * \return
1541  * non-NULL handle to the PV 'name' attached to the VG.
1542  * NULL is returned if the PV name is not associated with the VG handle.
1543  */
1544 pv_t lvm_pv_from_name(vg_t vg, const char *name);
1545
1546 /**
1547  * Lookup an PV handle in a VG by the PV uuid.
1548  * The form of the uuid may be either the formatted, human-readable form,
1549  * or the non-formatted form.
1550  *
1551  * \memberof pv_t
1552  *
1553  * \param   vg
1554  * VG handle obtained from lvm_vg_create() or lvm_vg_open().
1555  *
1556  * \param   uuid
1557  * UUID of PV to lookup.
1558  *
1559  * \return
1560  * non-NULL handle to the PV with 'uuid' attached to the VG.
1561  * NULL is returned if the PV uuid is not associated with the VG handle.
1562  */
1563 pv_t lvm_pv_from_uuid(vg_t vg, const char *uuid);
1564
1565 /**
1566  * Resize physical volume to new_size bytes.
1567  *
1568  * \memberof pv_t
1569  *
1570  * NOTE: This function is currently not implemented.
1571  *
1572  * \param   pv
1573  * Physical volume handle.
1574  *
1575  * \param   new_size
1576  * New size in bytes.
1577  *
1578  * \return
1579  * 0 (success) or -1 (failure).
1580  */
1581 int lvm_pv_resize(const pv_t pv, uint64_t new_size);
1582
1583 #ifndef _LVM_PERCENT_H
1584
1585 /**
1586  * This type defines a couple of special percent values. The PERCENT_0 and
1587  * PERCENT_100 constants designate *exact* percentages: values are never
1588  * rounded to either of these two.
1589  */
1590 typedef enum {
1591         PERCENT_0 = 0,
1592         PERCENT_1 = 1000000,
1593         PERCENT_100 = 100 * PERCENT_1,
1594         PERCENT_INVALID = -1
1595 } percent_range_t;
1596
1597 typedef int32_t percent_t;
1598
1599 #endif
1600
1601 /**
1602  * Convert a (fixed-point) value obtained from the percent-denominated
1603  * *_get_property functions into a floating-point value.
1604  */
1605 float lvm_percent_to_float(percent_t v);
1606
1607 #ifdef __cplusplus
1608 }
1609 #endif
1610 #endif /* _LIB_LVM2APP_H */