xref: /dflybsd-src/contrib/lvm2/dist/include/lvm2app.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*	$NetBSD: lvm2app.h,v 1.1.1.1 2009/12/02 00:25:45 haad Exp $	*/
286d7f5d3SJohn Marino 
386d7f5d3SJohn Marino /*
486d7f5d3SJohn Marino  * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved.
586d7f5d3SJohn Marino  *
686d7f5d3SJohn Marino  * This file is part of LVM2.
786d7f5d3SJohn Marino  *
886d7f5d3SJohn Marino  * This copyrighted material is made available to anyone wishing to use,
986d7f5d3SJohn Marino  * modify, copy, or redistribute it subject to the terms and conditions
1086d7f5d3SJohn Marino  * of the GNU Lesser General Public License v.2.1.
1186d7f5d3SJohn Marino  *
1286d7f5d3SJohn Marino  * You should have received a copy of the GNU Lesser General Public License
1386d7f5d3SJohn Marino  * along with this program; if not, write to the Free Software Foundation,
1486d7f5d3SJohn Marino  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1586d7f5d3SJohn Marino  */
1686d7f5d3SJohn Marino #ifndef _LIB_LVM2APP_H
1786d7f5d3SJohn Marino #define _LIB_LVM2APP_H
1886d7f5d3SJohn Marino 
1986d7f5d3SJohn Marino #include "libdevmapper.h"
2086d7f5d3SJohn Marino 
2186d7f5d3SJohn Marino #include <stdint.h>
2286d7f5d3SJohn Marino 
2386d7f5d3SJohn Marino 
2486d7f5d3SJohn Marino /******************************** WARNING ***********************************
2586d7f5d3SJohn Marino  *
2686d7f5d3SJohn Marino  * NOTE: This API is under development and subject to change at any time.
2786d7f5d3SJohn Marino  *
2886d7f5d3SJohn Marino  * Please send feedback to lvm-devel@redhat.com
2986d7f5d3SJohn Marino  *
3086d7f5d3SJohn Marino  *********************************** WARNING ********************************/
3186d7f5d3SJohn Marino 
3286d7f5d3SJohn Marino /*************************** Design Overview ********************************/
3386d7f5d3SJohn Marino 
3486d7f5d3SJohn Marino /**
3586d7f5d3SJohn Marino  * \mainpage LVM library API
3686d7f5d3SJohn Marino  *
3786d7f5d3SJohn Marino  * The API is designed around the following basic LVM objects:
3886d7f5d3SJohn Marino  * 1) Physical Volume (PV) 2) Volume Group (VG) 3) Logical Volume (LV).
3986d7f5d3SJohn Marino  *
4086d7f5d3SJohn Marino  * The library provides functions to list the objects in a system,
4186d7f5d3SJohn Marino  * get and set object properties (such as names, UUIDs, and sizes), as well
4286d7f5d3SJohn Marino  * as create/remove objects and perform more complex operations and
4386d7f5d3SJohn Marino  * transformations. Each object instance is represented by a handle, and
4486d7f5d3SJohn Marino  * handles are passed to and from the functions to perform the operations.
4586d7f5d3SJohn Marino  *
4686d7f5d3SJohn Marino  * A central object in the library is the Volume Group, represented by the
4786d7f5d3SJohn Marino  * VG handle, vg_t. Performing an operation on a PV or LV object first
4886d7f5d3SJohn Marino  * requires obtaining a VG handle. Once the vg_t has been obtained, it can
4986d7f5d3SJohn Marino  * be used to enumerate the pv_t's and lv_t's within that vg_t. Attributes
5086d7f5d3SJohn Marino  * of these objects can then be queried.
5186d7f5d3SJohn Marino  *
5286d7f5d3SJohn Marino  * A volume group handle may be obtained with read or write permission.
5386d7f5d3SJohn Marino  * Any attempt to change a property of a pv_t, vg_t, or lv_t without
5486d7f5d3SJohn Marino  * obtaining write permission on the vg_t will fail with EPERM.
5586d7f5d3SJohn Marino  *
5686d7f5d3SJohn Marino  * An application first opening a VG read-only, then later wanting to change
5786d7f5d3SJohn Marino  * a property of an object must first close the VG and re-open with write
5886d7f5d3SJohn Marino  * permission. Currently liblvm provides no mechanism to determine whether
5986d7f5d3SJohn Marino  * the VG has changed on-disk in between these operations - this is the
6086d7f5d3SJohn Marino  * application's responsiblity. One way the application can ensure the VG
6186d7f5d3SJohn Marino  * has not changed is to save the "vg_seqno" field after opening the VG with
6286d7f5d3SJohn Marino  * READ permission. If the application later needs to modify the VG, it can
6386d7f5d3SJohn Marino  * close the VG and re-open with WRITE permission. It should then check
6486d7f5d3SJohn Marino  * whether the original "vg_seqno" obtained with READ permission matches
6586d7f5d3SJohn Marino  * the new one obtained with WRITE permission.
6686d7f5d3SJohn Marino  */
6786d7f5d3SJohn Marino 
6886d7f5d3SJohn Marino /**
6986d7f5d3SJohn Marino  * Retrieve the library version.
7086d7f5d3SJohn Marino  *
7186d7f5d3SJohn Marino  * The library version is the same format as the full LVM version.
7286d7f5d3SJohn Marino  * The format is as follows:
7386d7f5d3SJohn Marino  *    LVM_MAJOR.LVM_MINOR.LVM_PATCHLEVEL(LVM_LIBAPI)[-LVM_RELEASE]
7486d7f5d3SJohn Marino  * An application wishing to determine compatibility with a particular version
7586d7f5d3SJohn Marino  * of the library should check at least the LVM_MAJOR, LVM_MINOR, and
7686d7f5d3SJohn Marino  * LVM_LIBAPI numbers.  For example, assume the full LVM version is
7786d7f5d3SJohn Marino  * 2.02.50(1)-1.  The application should verify the "2.02" and the "(1)".
7886d7f5d3SJohn Marino  *
7986d7f5d3SJohn Marino  * \return  A string describing the library version.
8086d7f5d3SJohn Marino  */
8186d7f5d3SJohn Marino const char *lvm_library_get_version(void);
8286d7f5d3SJohn Marino 
8386d7f5d3SJohn Marino /******************************** structures ********************************/
8486d7f5d3SJohn Marino 
8586d7f5d3SJohn Marino /**
8686d7f5d3SJohn Marino  * Opaque structures - do not use directly.  Internal structures may change
8786d7f5d3SJohn Marino  * without notice between releases, whereas this API will be changed much less
8886d7f5d3SJohn Marino  * frequently.  Backwards compatibility will normally be preserved in future
8986d7f5d3SJohn Marino  * releases.  On any occasion when the developers do decide to break backwards
9086d7f5d3SJohn Marino  * compatibility in any significant way, the LVM_LIBAPI number (included in
9186d7f5d3SJohn Marino  * the library's soname) will be incremented.
9286d7f5d3SJohn Marino  */
9386d7f5d3SJohn Marino struct lvm;
9486d7f5d3SJohn Marino struct physical_volume;
9586d7f5d3SJohn Marino struct volume_group;
9686d7f5d3SJohn Marino struct logical_volume;
9786d7f5d3SJohn Marino 
9886d7f5d3SJohn Marino /**
9986d7f5d3SJohn Marino  * lvm handle.
10086d7f5d3SJohn Marino  *
10186d7f5d3SJohn Marino  * This is the base handle that is needed to open and create objects such as
10286d7f5d3SJohn Marino  * volume groups and logical volumes.  In addition, this handle provides a
10386d7f5d3SJohn Marino  * context for error handling information, saving any error number (see
10486d7f5d3SJohn Marino  * lvm_errno) and error message (see lvm_errmsg) that any function may
10586d7f5d3SJohn Marino  * generate.
10686d7f5d3SJohn Marino  */
10786d7f5d3SJohn Marino typedef struct lvm *lvm_t;
10886d7f5d3SJohn Marino 
10986d7f5d3SJohn Marino /**
11086d7f5d3SJohn Marino  * Volume group object.
11186d7f5d3SJohn Marino  *
11286d7f5d3SJohn Marino  * This object can be either a read-only object or a read-write object
11386d7f5d3SJohn Marino  * depending on the mode it was returned by a function. Create functions
11486d7f5d3SJohn Marino  * return a read-write object, but open functions have the argument mode to
11586d7f5d3SJohn Marino  * define if the object can be modified or not.
11686d7f5d3SJohn Marino  */
11786d7f5d3SJohn Marino typedef struct volume_group *vg_t;
11886d7f5d3SJohn Marino 
11986d7f5d3SJohn Marino /**
12086d7f5d3SJohn Marino  * Logical Volume object.
12186d7f5d3SJohn Marino  *
12286d7f5d3SJohn Marino  * This object is bound to a volume group and has the same mode of the volume
12386d7f5d3SJohn Marino  * group.  Changes will be written to disk when the volume group gets
12486d7f5d3SJohn Marino  * committed to disk.
12586d7f5d3SJohn Marino  */
12686d7f5d3SJohn Marino typedef struct logical_volume *lv_t;
12786d7f5d3SJohn Marino 
12886d7f5d3SJohn Marino /**
12986d7f5d3SJohn Marino  * Physical volume object.
13086d7f5d3SJohn Marino  *
13186d7f5d3SJohn Marino  * This object is bound to a volume group and has the same mode of the volume
13286d7f5d3SJohn Marino  * group.  Changes will be written to disk when the volume group gets
13386d7f5d3SJohn Marino  * committed to disk.
13486d7f5d3SJohn Marino  */
13586d7f5d3SJohn Marino typedef struct physical_volume *pv_t;
13686d7f5d3SJohn Marino 
13786d7f5d3SJohn Marino /**
13886d7f5d3SJohn Marino  * Logical Volume object list.
13986d7f5d3SJohn Marino  *
14086d7f5d3SJohn Marino  * Lists of these structures are returned by lvm_vg_list_pvs.
14186d7f5d3SJohn Marino  */
14286d7f5d3SJohn Marino typedef struct lvm_lv_list {
14386d7f5d3SJohn Marino 	struct dm_list list;
14486d7f5d3SJohn Marino 	lv_t lv;
14586d7f5d3SJohn Marino } lv_list_t;
14686d7f5d3SJohn Marino 
14786d7f5d3SJohn Marino /**
14886d7f5d3SJohn Marino  * Physical volume object list.
14986d7f5d3SJohn Marino  *
15086d7f5d3SJohn Marino  * Lists of these structures are returned by lvm_vg_list_pvs.
15186d7f5d3SJohn Marino  */
15286d7f5d3SJohn Marino typedef struct lvm_pv_list {
15386d7f5d3SJohn Marino 	struct dm_list list;
15486d7f5d3SJohn Marino 	pv_t pv;
15586d7f5d3SJohn Marino } pv_list_t;
15686d7f5d3SJohn Marino 
15786d7f5d3SJohn Marino /**
15886d7f5d3SJohn Marino  * String list.
15986d7f5d3SJohn Marino  *
16086d7f5d3SJohn Marino  * This string list contains read-only strings.
16186d7f5d3SJohn Marino  * Lists of these structures are returned by lvm_list_vg_names and
16286d7f5d3SJohn Marino  * lvm_list_vg_uuids.
16386d7f5d3SJohn Marino  */
16486d7f5d3SJohn Marino struct lvm_str_list {
16586d7f5d3SJohn Marino 	struct dm_list list;
16686d7f5d3SJohn Marino 	const char *str;
16786d7f5d3SJohn Marino };
16886d7f5d3SJohn Marino 
16986d7f5d3SJohn Marino /*************************** generic lvm handling ***************************/
17086d7f5d3SJohn Marino /**
17186d7f5d3SJohn Marino  * Create a LVM handle.
17286d7f5d3SJohn Marino  *
17386d7f5d3SJohn Marino  * Once all LVM operations have been completed, use lvm_quit to release
17486d7f5d3SJohn Marino  * the handle and any associated resources.
17586d7f5d3SJohn Marino  *
17686d7f5d3SJohn Marino  * \param system_dir
17786d7f5d3SJohn Marino  * Set an alternative LVM system directory. Use NULL to use the
17886d7f5d3SJohn Marino  * default value. If the environment variable LVM_SYSTEM_DIR is set,
17986d7f5d3SJohn Marino  * it will override any system_dir setting.
18086d7f5d3SJohn Marino  *
18186d7f5d3SJohn Marino  * \return
18286d7f5d3SJohn Marino  * A valid LVM handle is returned or NULL if there has been a
18386d7f5d3SJohn Marino  * memory allocation problem. You have to check if an error occured
18486d7f5d3SJohn Marino  * with the lvm_error function.
18586d7f5d3SJohn Marino  */
18686d7f5d3SJohn Marino lvm_t lvm_init(const char *system_dir);
18786d7f5d3SJohn Marino 
18886d7f5d3SJohn Marino /**
18986d7f5d3SJohn Marino  * Destroy a LVM handle allocated with lvm_init.
19086d7f5d3SJohn Marino  *
19186d7f5d3SJohn Marino  * This function should be used after all LVM operations are complete or after
19286d7f5d3SJohn Marino  * an unrecoverable error.  Destroying the LVM handle frees the memory and
19386d7f5d3SJohn Marino  * other resources associated with the handle.  Once destroyed, the handle
19486d7f5d3SJohn Marino  * cannot be used subsequently.
19586d7f5d3SJohn Marino  *
19686d7f5d3SJohn Marino  * \param   libh
19786d7f5d3SJohn Marino  * Handle obtained from lvm_init.
19886d7f5d3SJohn Marino  */
19986d7f5d3SJohn Marino void lvm_quit(lvm_t libh);
20086d7f5d3SJohn Marino 
20186d7f5d3SJohn Marino /**
20286d7f5d3SJohn Marino  * Reload the original configuration from the system directory.
20386d7f5d3SJohn Marino  *
20486d7f5d3SJohn Marino  * This function should be used when any LVM configuration changes in the LVM
20586d7f5d3SJohn Marino  * system_dir or by another lvm_config* function, and the change is needed by
20686d7f5d3SJohn Marino  * the application.
20786d7f5d3SJohn Marino  *
20886d7f5d3SJohn Marino  * \param   libh
20986d7f5d3SJohn Marino  * Handle obtained from lvm_init.
21086d7f5d3SJohn Marino  *
21186d7f5d3SJohn Marino  * \return
21286d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
21386d7f5d3SJohn Marino  */
21486d7f5d3SJohn Marino int lvm_config_reload(lvm_t libh);
21586d7f5d3SJohn Marino 
21686d7f5d3SJohn Marino /**
21786d7f5d3SJohn Marino  * Override the LVM configuration with a configuration string.
21886d7f5d3SJohn Marino  *
21986d7f5d3SJohn Marino  * This function is equivalent to the --config option on lvm commands.
22086d7f5d3SJohn Marino  * Once this API has been used to over-ride the configuration,
22186d7f5d3SJohn Marino  * use lvm_config_reload to apply the new settings.
22286d7f5d3SJohn Marino  *
22386d7f5d3SJohn Marino  * \param   libh
22486d7f5d3SJohn Marino  * Handle obtained from lvm_init.
22586d7f5d3SJohn Marino  *
22686d7f5d3SJohn Marino  * \param   config_string
22786d7f5d3SJohn Marino  * LVM configuration string to apply.  See the lvm.conf file man page
22886d7f5d3SJohn Marino  * for the format of the config string.
22986d7f5d3SJohn Marino  *
23086d7f5d3SJohn Marino  * \return
23186d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
23286d7f5d3SJohn Marino  */
23386d7f5d3SJohn Marino int lvm_config_override(lvm_t libh, const char *config_string);
23486d7f5d3SJohn Marino 
23586d7f5d3SJohn Marino /**
23686d7f5d3SJohn Marino  * Return stored error no describing last LVM API error.
23786d7f5d3SJohn Marino  *
23886d7f5d3SJohn Marino  * Users of liblvm should use lvm_errno to determine the details of a any
23986d7f5d3SJohn Marino  * failure of the last call.  A basic success or fail is always returned by
24086d7f5d3SJohn Marino  * every function, either by returning a 0 or -1, or a non-NULL / NULL.
24186d7f5d3SJohn Marino  * If a function has failed, lvm_errno may be used to get a more specific
24286d7f5d3SJohn Marino  * error code describing the failure.  In this way, lvm_errno may be used
24386d7f5d3SJohn Marino  * after every function call, even after a 'get' function call that simply
24486d7f5d3SJohn Marino  * returns a value.
24586d7f5d3SJohn Marino  *
24686d7f5d3SJohn Marino  * \param   libh
24786d7f5d3SJohn Marino  * Handle obtained from lvm_init.
24886d7f5d3SJohn Marino  *
24986d7f5d3SJohn Marino  * \return
25086d7f5d3SJohn Marino  * An errno value describing the last LVM error.
25186d7f5d3SJohn Marino  */
25286d7f5d3SJohn Marino int lvm_errno(lvm_t libh);
25386d7f5d3SJohn Marino 
25486d7f5d3SJohn Marino /**
25586d7f5d3SJohn Marino  * Return stored error message describing last LVM error.
25686d7f5d3SJohn Marino  *
25786d7f5d3SJohn Marino  * This function may be used in conjunction with lvm_errno to obtain more
25886d7f5d3SJohn Marino  * specific error information for a function that is known to have failed.
25986d7f5d3SJohn Marino  *
26086d7f5d3SJohn Marino  * \param   libh
26186d7f5d3SJohn Marino  * Handle obtained from lvm_init.
26286d7f5d3SJohn Marino  *
26386d7f5d3SJohn Marino  * \return
26486d7f5d3SJohn Marino  * An error string describing the last LVM error.
26586d7f5d3SJohn Marino  */
26686d7f5d3SJohn Marino const char *lvm_errmsg(lvm_t libh);
26786d7f5d3SJohn Marino 
26886d7f5d3SJohn Marino /**
26986d7f5d3SJohn Marino  * Scan all devices on the system for VGs and LVM metadata.
27086d7f5d3SJohn Marino  *
27186d7f5d3SJohn Marino  * \return
27286d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
27386d7f5d3SJohn Marino  */
27486d7f5d3SJohn Marino int lvm_scan(lvm_t libh);
27586d7f5d3SJohn Marino 
27686d7f5d3SJohn Marino /*************************** volume group handling **************************/
27786d7f5d3SJohn Marino 
27886d7f5d3SJohn Marino /**
27986d7f5d3SJohn Marino  * Return the list of volume group names.
28086d7f5d3SJohn Marino  *
28186d7f5d3SJohn Marino  * The memory allocated for the list is tied to the lvm_t handle and will be
28286d7f5d3SJohn Marino  * released when lvm_quit is called.
28386d7f5d3SJohn Marino  *
28486d7f5d3SJohn Marino  * NOTE: This function normally does not scan devices in the system for LVM
28586d7f5d3SJohn Marino  * metadata.  To scan the system, use lvm_scan.
28686d7f5d3SJohn Marino  * NOTE: This function currently returns hidden VG names.  These names always
28786d7f5d3SJohn Marino  * begin with a "#" and should be filtered out and not used.
28886d7f5d3SJohn Marino  *
28986d7f5d3SJohn Marino  * To process the list, use the dm_list iterator functions.  For example:
29086d7f5d3SJohn Marino  *      vg_t vg;
29186d7f5d3SJohn Marino  *      struct dm_list *vgnames;
29286d7f5d3SJohn Marino  *      struct lvm_str_list *strl;
29386d7f5d3SJohn Marino  *
29486d7f5d3SJohn Marino  *      vgnames = lvm_list_vg_names(libh);
29586d7f5d3SJohn Marino  *	dm_list_iterate_items(strl, vgnames) {
29686d7f5d3SJohn Marino  *		vgname = strl->str;
29786d7f5d3SJohn Marino  *              vg = lvm_vg_open(libh, vgname, "r");
29886d7f5d3SJohn Marino  *              // do something with vg
29986d7f5d3SJohn Marino  *              lvm_vg_close(vg);
30086d7f5d3SJohn Marino  *      }
30186d7f5d3SJohn Marino  *
30286d7f5d3SJohn Marino  *
30386d7f5d3SJohn Marino  * \return
30486d7f5d3SJohn Marino  * A list with entries of type struct lvm_str_list, containing the
30586d7f5d3SJohn Marino  * VG name strings of the Volume Groups known to the system.
30686d7f5d3SJohn Marino  * NULL is returned if unable to allocate memory.
30786d7f5d3SJohn Marino  * An empty list (verify with dm_list_empty) is returned if no VGs
30886d7f5d3SJohn Marino  * exist on the system.
30986d7f5d3SJohn Marino  */
31086d7f5d3SJohn Marino struct dm_list *lvm_list_vg_names(lvm_t libh);
31186d7f5d3SJohn Marino 
31286d7f5d3SJohn Marino /**
31386d7f5d3SJohn Marino  * Return the list of volume group uuids.
31486d7f5d3SJohn Marino  *
31586d7f5d3SJohn Marino  * The memory allocated for the list is tied to the lvm_t handle and will be
31686d7f5d3SJohn Marino  * released when lvm_quit is called.
31786d7f5d3SJohn Marino  *
31886d7f5d3SJohn Marino  * NOTE: This function normally does not scan devices in the system for LVM
31986d7f5d3SJohn Marino  * metadata.  To scan the system, use lvm_scan.
32086d7f5d3SJohn Marino  * NOTE: This function currently returns hidden VG names.  These names always
32186d7f5d3SJohn Marino  * begin with a "#" and should be filtered out and not used.
32286d7f5d3SJohn Marino  *
32386d7f5d3SJohn Marino  * \param   libh
32486d7f5d3SJohn Marino  * Handle obtained from lvm_init.
32586d7f5d3SJohn Marino  *
32686d7f5d3SJohn Marino  * \return
32786d7f5d3SJohn Marino  * A list with entries of type struct lvm_str_list, containing the
32886d7f5d3SJohn Marino  * VG UUID strings of the Volume Groups known to the system.
32986d7f5d3SJohn Marino  * NULL is returned if unable to allocate memory.
33086d7f5d3SJohn Marino  * An empty list (verify with dm_list_empty) is returned if no VGs
33186d7f5d3SJohn Marino  * exist on the system.
33286d7f5d3SJohn Marino  */
33386d7f5d3SJohn Marino struct dm_list *lvm_list_vg_uuids(lvm_t libh);
33486d7f5d3SJohn Marino 
33586d7f5d3SJohn Marino /**
33686d7f5d3SJohn Marino  * Open an existing VG.
33786d7f5d3SJohn Marino  *
33886d7f5d3SJohn Marino  * Open a VG for reading or writing.
33986d7f5d3SJohn Marino  *
34086d7f5d3SJohn Marino  * \param   libh
34186d7f5d3SJohn Marino  * Handle obtained from lvm_init.
34286d7f5d3SJohn Marino  *
34386d7f5d3SJohn Marino  * \param   vgname
34486d7f5d3SJohn Marino  * Name of the VG to open.
34586d7f5d3SJohn Marino  *
34686d7f5d3SJohn Marino  * \param   mode
34786d7f5d3SJohn Marino  * Open mode - either "r" (read) or "w" (read/write).
34886d7f5d3SJohn Marino  * Any other character results in an error with EINVAL set.
34986d7f5d3SJohn Marino  *
35086d7f5d3SJohn Marino  * \param   flags
35186d7f5d3SJohn Marino  * Open flags - currently ignored.
35286d7f5d3SJohn Marino  *
35386d7f5d3SJohn Marino  * \return  non-NULL VG handle (success) or NULL (failure).
35486d7f5d3SJohn Marino  */
35586d7f5d3SJohn Marino vg_t lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
35686d7f5d3SJohn Marino 		  uint32_t flags);
35786d7f5d3SJohn Marino 
35886d7f5d3SJohn Marino /**
35986d7f5d3SJohn Marino  * Create a VG with default parameters.
36086d7f5d3SJohn Marino  *
36186d7f5d3SJohn Marino  * This function creates a Volume Group object in memory.
36286d7f5d3SJohn Marino  * Upon success, other APIs may be used to set non-default parameters.
36386d7f5d3SJohn Marino  * For example, to set a non-default extent size, use lvm_vg_set_extent_size.
36486d7f5d3SJohn Marino  * Next, to add physical storage devices to the volume group, use
36586d7f5d3SJohn Marino  * lvm_vg_extend for each device.
36686d7f5d3SJohn Marino  * Once all parameters are set appropriately and all devices are added to the
36786d7f5d3SJohn Marino  * VG, use lvm_vg_write to commit the new VG to disk, and lvm_vg_close to
36886d7f5d3SJohn Marino  * release the VG handle.
36986d7f5d3SJohn Marino  *
37086d7f5d3SJohn Marino  * \param   libh
37186d7f5d3SJohn Marino  * Handle obtained from lvm_init.
37286d7f5d3SJohn Marino  *
37386d7f5d3SJohn Marino  * \param   vg_name
37486d7f5d3SJohn Marino  * Name of the VG to open.
37586d7f5d3SJohn Marino  *
37686d7f5d3SJohn Marino  * \return
37786d7f5d3SJohn Marino  * non-NULL vg handle (success) or NULL (failure)
37886d7f5d3SJohn Marino  */
37986d7f5d3SJohn Marino vg_t lvm_vg_create(lvm_t libh, const char *vg_name);
38086d7f5d3SJohn Marino 
38186d7f5d3SJohn Marino  /**
38286d7f5d3SJohn Marino  * Write a VG to disk.
38386d7f5d3SJohn Marino  *
38486d7f5d3SJohn Marino  * This function commits the Volume Group object referenced by the VG handle
38586d7f5d3SJohn Marino  * to disk. Upon failure, retry the operation and/or release the VG handle
38686d7f5d3SJohn Marino  * with lvm_vg_close.
38786d7f5d3SJohn Marino  *
38886d7f5d3SJohn Marino  * \param   vg
38986d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
39086d7f5d3SJohn Marino  *
39186d7f5d3SJohn Marino  * \return
39286d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
39386d7f5d3SJohn Marino  */
39486d7f5d3SJohn Marino int lvm_vg_write(vg_t vg);
39586d7f5d3SJohn Marino 
39686d7f5d3SJohn Marino /**
39786d7f5d3SJohn Marino  * Remove a VG from the system.
39886d7f5d3SJohn Marino  *
39986d7f5d3SJohn Marino  * This function removes a Volume Group object in memory, and requires
40086d7f5d3SJohn Marino  * calling lvm_vg_write to commit the removal to disk.
40186d7f5d3SJohn Marino  *
40286d7f5d3SJohn Marino  * \param   vg
40386d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
40486d7f5d3SJohn Marino  *
40586d7f5d3SJohn Marino  * \return
40686d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
40786d7f5d3SJohn Marino  */
40886d7f5d3SJohn Marino int lvm_vg_remove(vg_t vg);
40986d7f5d3SJohn Marino 
41086d7f5d3SJohn Marino /**
41186d7f5d3SJohn Marino  * Close a VG opened with lvm_vg_create or lvm_vg_open.
41286d7f5d3SJohn Marino  *
41386d7f5d3SJohn Marino  * This function releases a VG handle and any resources associated with the
41486d7f5d3SJohn Marino  * handle.
41586d7f5d3SJohn Marino  *
41686d7f5d3SJohn Marino  * \param   vg
41786d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
41886d7f5d3SJohn Marino  *
41986d7f5d3SJohn Marino  * \return
42086d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
42186d7f5d3SJohn Marino  */
42286d7f5d3SJohn Marino int lvm_vg_close(vg_t vg);
42386d7f5d3SJohn Marino 
42486d7f5d3SJohn Marino /**
42586d7f5d3SJohn Marino  * Extend a VG by adding a device.
42686d7f5d3SJohn Marino  *
42786d7f5d3SJohn Marino  * This function requires calling lvm_vg_write to commit the change to disk.
42886d7f5d3SJohn Marino  * After successfully adding a device, use lvm_vg_write to commit the new VG
42986d7f5d3SJohn Marino  * to disk.  Upon failure, retry the operation or release the VG handle with
43086d7f5d3SJohn Marino  * lvm_vg_close.
43186d7f5d3SJohn Marino  * If the device is not initialized for LVM use, it will be initialized
43286d7f5d3SJohn Marino  * before adding to the VG.  Although some internal checks are done,
43386d7f5d3SJohn Marino  * the caller should be sure the device is not in use by other subsystems
43486d7f5d3SJohn Marino  * before calling lvm_vg_extend.
43586d7f5d3SJohn Marino  *
43686d7f5d3SJohn Marino  * \param   vg
43786d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
43886d7f5d3SJohn Marino  *
43986d7f5d3SJohn Marino  * \param   device
44086d7f5d3SJohn Marino  * Absolute pathname of device to add to VG.
44186d7f5d3SJohn Marino  *
44286d7f5d3SJohn Marino  * \return
44386d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
44486d7f5d3SJohn Marino  */
44586d7f5d3SJohn Marino int lvm_vg_extend(vg_t vg, const char *device);
44686d7f5d3SJohn Marino 
44786d7f5d3SJohn Marino /**
44886d7f5d3SJohn Marino  * Reduce a VG by removing an unused device.
44986d7f5d3SJohn Marino  *
45086d7f5d3SJohn Marino  * This function requires calling lvm_vg_write to commit the change to disk.
45186d7f5d3SJohn Marino  * After successfully removing a device, use lvm_vg_write to commit the new VG
45286d7f5d3SJohn Marino  * to disk.  Upon failure, retry the operation or release the VG handle with
45386d7f5d3SJohn Marino  * lvm_vg_close.
45486d7f5d3SJohn Marino  *
45586d7f5d3SJohn Marino  * \param   vg
45686d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
45786d7f5d3SJohn Marino  *
45886d7f5d3SJohn Marino  * \param   device
45986d7f5d3SJohn Marino  * Name of device to remove from VG.
46086d7f5d3SJohn Marino  *
46186d7f5d3SJohn Marino  * \return
46286d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
46386d7f5d3SJohn Marino  */
46486d7f5d3SJohn Marino int lvm_vg_reduce(vg_t vg, const char *device);
46586d7f5d3SJohn Marino 
46686d7f5d3SJohn Marino /**
46786d7f5d3SJohn Marino  * Set the extent size of a VG.
46886d7f5d3SJohn Marino  *
46986d7f5d3SJohn Marino  * This function requires calling lvm_vg_write to commit the change to disk.
47086d7f5d3SJohn Marino  * After successfully setting a new extent size, use lvm_vg_write to commit
47186d7f5d3SJohn Marino  * the new VG to disk.  Upon failure, retry the operation or release the VG
47286d7f5d3SJohn Marino  * handle with lvm_vg_close.
47386d7f5d3SJohn Marino  *
47486d7f5d3SJohn Marino  * \param   vg
47586d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
47686d7f5d3SJohn Marino  *
47786d7f5d3SJohn Marino  * \param   new_size
47886d7f5d3SJohn Marino  * New extent size in bytes.
47986d7f5d3SJohn Marino  *
48086d7f5d3SJohn Marino  * \return
48186d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
48286d7f5d3SJohn Marino  */
48386d7f5d3SJohn Marino int lvm_vg_set_extent_size(vg_t vg, uint32_t new_size);
48486d7f5d3SJohn Marino 
48586d7f5d3SJohn Marino /**
48686d7f5d3SJohn Marino  * Get whether or not a volume group is clustered.
48786d7f5d3SJohn Marino  *
48886d7f5d3SJohn Marino  * \param   vg
48986d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
49086d7f5d3SJohn Marino  *
49186d7f5d3SJohn Marino  * \return
49286d7f5d3SJohn Marino  * 1 if the VG is clustered, 0 if not
49386d7f5d3SJohn Marino  */
49486d7f5d3SJohn Marino uint64_t lvm_vg_is_clustered(vg_t vg);
49586d7f5d3SJohn Marino 
49686d7f5d3SJohn Marino /**
49786d7f5d3SJohn Marino  * Get whether or not a volume group is exported.
49886d7f5d3SJohn Marino  *
49986d7f5d3SJohn Marino  * \param   vg
50086d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
50186d7f5d3SJohn Marino  *
50286d7f5d3SJohn Marino  * \return
50386d7f5d3SJohn Marino  * 1 if the VG is exported, 0 if not
50486d7f5d3SJohn Marino  */
50586d7f5d3SJohn Marino uint64_t lvm_vg_is_exported(vg_t vg);
50686d7f5d3SJohn Marino 
50786d7f5d3SJohn Marino /**
50886d7f5d3SJohn Marino  * Get whether or not a volume group is a partial volume group.
50986d7f5d3SJohn Marino  *
51086d7f5d3SJohn Marino  * When one or more physical volumes belonging to the volume group
51186d7f5d3SJohn Marino  * are missing from the system the volume group is a partial volume
51286d7f5d3SJohn Marino  * group.
51386d7f5d3SJohn Marino  *
51486d7f5d3SJohn Marino  * \param   vg
51586d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
51686d7f5d3SJohn Marino  *
51786d7f5d3SJohn Marino  * \return
51886d7f5d3SJohn Marino  * 1 if the VG is PVs, 0 if not
51986d7f5d3SJohn Marino  */
52086d7f5d3SJohn Marino uint64_t lvm_vg_is_partial(vg_t vg);
52186d7f5d3SJohn Marino 
52286d7f5d3SJohn Marino /**
52386d7f5d3SJohn Marino  * Get the current metadata sequence number of a volume group.
52486d7f5d3SJohn Marino  *
52586d7f5d3SJohn Marino  * The metadata sequence number is incrented for each metadata change.
52686d7f5d3SJohn Marino  * Applications may use the sequence number to determine if any LVM objects
52786d7f5d3SJohn Marino  * have changed from a prior query.
52886d7f5d3SJohn Marino  *
52986d7f5d3SJohn Marino  * \param   vg
53086d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
53186d7f5d3SJohn Marino  *
53286d7f5d3SJohn Marino  * \return
53386d7f5d3SJohn Marino  * Metadata sequence number.
53486d7f5d3SJohn Marino  */
53586d7f5d3SJohn Marino uint64_t lvm_vg_get_seqno(const vg_t vg);
53686d7f5d3SJohn Marino 
53786d7f5d3SJohn Marino /**
53886d7f5d3SJohn Marino  * Get the current name of a volume group.
53986d7f5d3SJohn Marino  *
54086d7f5d3SJohn Marino  * Memory is allocated using dm_malloc() and caller must free the memory
54186d7f5d3SJohn Marino  * using dm_free().
54286d7f5d3SJohn Marino  *
54386d7f5d3SJohn Marino  * \param   vg
54486d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
54586d7f5d3SJohn Marino  *
54686d7f5d3SJohn Marino  * \return
54786d7f5d3SJohn Marino  * Copy of the uuid string.
54886d7f5d3SJohn Marino  */
54986d7f5d3SJohn Marino char *lvm_vg_get_uuid(const vg_t vg);
55086d7f5d3SJohn Marino 
55186d7f5d3SJohn Marino /**
55286d7f5d3SJohn Marino  * Get the current uuid of a volume group.
55386d7f5d3SJohn Marino  *
55486d7f5d3SJohn Marino  * Memory is allocated using dm_malloc() and caller must free the memory
55586d7f5d3SJohn Marino  * using dm_free().
55686d7f5d3SJohn Marino  *
55786d7f5d3SJohn Marino  * \param   vg
55886d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
55986d7f5d3SJohn Marino  *
56086d7f5d3SJohn Marino  * \return
56186d7f5d3SJohn Marino  * Copy of the name.
56286d7f5d3SJohn Marino  */
56386d7f5d3SJohn Marino char *lvm_vg_get_name(const vg_t vg);
56486d7f5d3SJohn Marino 
56586d7f5d3SJohn Marino /**
56686d7f5d3SJohn Marino  * Get the current size in bytes of a volume group.
56786d7f5d3SJohn Marino  *
56886d7f5d3SJohn Marino  * \param   vg
56986d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
57086d7f5d3SJohn Marino  *
57186d7f5d3SJohn Marino  * \return
57286d7f5d3SJohn Marino  * Size in bytes.
57386d7f5d3SJohn Marino  */
57486d7f5d3SJohn Marino uint64_t lvm_vg_get_size(const vg_t vg);
57586d7f5d3SJohn Marino 
57686d7f5d3SJohn Marino /**
57786d7f5d3SJohn Marino  * Get the current unallocated space in bytes of a volume group.
57886d7f5d3SJohn Marino  *
57986d7f5d3SJohn Marino  * \param   vg
58086d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
58186d7f5d3SJohn Marino  *
58286d7f5d3SJohn Marino  * \return
58386d7f5d3SJohn Marino  * Free size in bytes.
58486d7f5d3SJohn Marino  */
58586d7f5d3SJohn Marino uint64_t lvm_vg_get_free_size(const vg_t vg);
58686d7f5d3SJohn Marino 
58786d7f5d3SJohn Marino /**
58886d7f5d3SJohn Marino  * Get the current extent size in bytes of a volume group.
58986d7f5d3SJohn Marino  *
59086d7f5d3SJohn Marino  * \param   vg
59186d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
59286d7f5d3SJohn Marino  *
59386d7f5d3SJohn Marino  * \return
59486d7f5d3SJohn Marino  * Extent size in bytes.
59586d7f5d3SJohn Marino  */
59686d7f5d3SJohn Marino uint64_t lvm_vg_get_extent_size(const vg_t vg);
59786d7f5d3SJohn Marino 
59886d7f5d3SJohn Marino /**
59986d7f5d3SJohn Marino  * Get the current number of total extents of a volume group.
60086d7f5d3SJohn Marino  *
60186d7f5d3SJohn Marino  * \param   vg
60286d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
60386d7f5d3SJohn Marino  *
60486d7f5d3SJohn Marino  * \return
60586d7f5d3SJohn Marino  * Extent count.
60686d7f5d3SJohn Marino  */
60786d7f5d3SJohn Marino uint64_t lvm_vg_get_extent_count(const vg_t vg);
60886d7f5d3SJohn Marino 
60986d7f5d3SJohn Marino /**
61086d7f5d3SJohn Marino  * Get the current number of free extents of a volume group.
61186d7f5d3SJohn Marino  *
61286d7f5d3SJohn Marino  * \param   vg
61386d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
61486d7f5d3SJohn Marino  *
61586d7f5d3SJohn Marino  * \return
61686d7f5d3SJohn Marino  * Free extent count.
61786d7f5d3SJohn Marino  */
61886d7f5d3SJohn Marino uint64_t lvm_vg_get_free_extent_count(const vg_t vg);
61986d7f5d3SJohn Marino 
62086d7f5d3SJohn Marino /**
62186d7f5d3SJohn Marino  * Get the current number of physical volumes of a volume group.
62286d7f5d3SJohn Marino  *
62386d7f5d3SJohn Marino  * \param   vg
62486d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
62586d7f5d3SJohn Marino  *
62686d7f5d3SJohn Marino  * \return
62786d7f5d3SJohn Marino  * Physical volume count.
62886d7f5d3SJohn Marino  */
62986d7f5d3SJohn Marino uint64_t lvm_vg_get_pv_count(const vg_t vg);
63086d7f5d3SJohn Marino 
63186d7f5d3SJohn Marino /**
63286d7f5d3SJohn Marino  * Get the maximum number of physical volumes allowed in a volume group.
63386d7f5d3SJohn Marino  *
63486d7f5d3SJohn Marino  * \param   vg
63586d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
63686d7f5d3SJohn Marino  *
63786d7f5d3SJohn Marino  * \return
63886d7f5d3SJohn Marino  * Maximum number of physical volumes allowed in a volume group.
63986d7f5d3SJohn Marino  */
64086d7f5d3SJohn Marino uint64_t lvm_vg_get_max_pv(const vg_t vg);
64186d7f5d3SJohn Marino 
64286d7f5d3SJohn Marino /**
64386d7f5d3SJohn Marino  * Get the maximum number of logical volumes allowed in a volume group.
64486d7f5d3SJohn Marino  *
64586d7f5d3SJohn Marino  * \param   vg
64686d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
64786d7f5d3SJohn Marino  *
64886d7f5d3SJohn Marino  * \return
64986d7f5d3SJohn Marino  * Maximum number of logical volumes allowed in a volume group.
65086d7f5d3SJohn Marino  */
65186d7f5d3SJohn Marino uint64_t lvm_vg_get_max_lv(const vg_t vg);
65286d7f5d3SJohn Marino 
65386d7f5d3SJohn Marino /************************** logical volume handling *************************/
65486d7f5d3SJohn Marino 
65586d7f5d3SJohn Marino /**
65686d7f5d3SJohn Marino  * Return a list of LV handles for a given VG handle.
65786d7f5d3SJohn Marino  *
65886d7f5d3SJohn Marino  * \param   vg
65986d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
66086d7f5d3SJohn Marino  *
66186d7f5d3SJohn Marino  * \return
66286d7f5d3SJohn Marino  * A list of lv_list_t structures containing lv handles for this vg.
66386d7f5d3SJohn Marino  * If no LVs exist on the given VG, NULL is returned.
66486d7f5d3SJohn Marino  */
66586d7f5d3SJohn Marino struct dm_list *lvm_vg_list_lvs(vg_t vg);
66686d7f5d3SJohn Marino 
66786d7f5d3SJohn Marino /**
66886d7f5d3SJohn Marino  * Create a linear logical volume.
66986d7f5d3SJohn Marino  * This function commits the change to disk and does _not_ require calling
67086d7f5d3SJohn Marino  * lvm_vg_write.
67186d7f5d3SJohn Marino  * NOTE: The commit behavior of this function is subject to change
67286d7f5d3SJohn Marino  * as the API is developed.
67386d7f5d3SJohn Marino  *
67486d7f5d3SJohn Marino  * \param   vg
67586d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
67686d7f5d3SJohn Marino  *
67786d7f5d3SJohn Marino  * \param   name
67886d7f5d3SJohn Marino  * Name of logical volume to create.
67986d7f5d3SJohn Marino  *
68086d7f5d3SJohn Marino  * \param   size
68186d7f5d3SJohn Marino  * Size of logical volume in extents.
68286d7f5d3SJohn Marino  *
68386d7f5d3SJohn Marino  * \return
68486d7f5d3SJohn Marino  * non-NULL handle to an LV object created, or NULL if creation fails.
68586d7f5d3SJohn Marino  *
68686d7f5d3SJohn Marino  */
68786d7f5d3SJohn Marino lv_t lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size);
68886d7f5d3SJohn Marino 
68986d7f5d3SJohn Marino /**
69086d7f5d3SJohn Marino  * Activate a logical volume.
69186d7f5d3SJohn Marino  *
69286d7f5d3SJohn Marino  * This function is the equivalent of the lvm command "lvchange -ay".
69386d7f5d3SJohn Marino  *
69486d7f5d3SJohn Marino  * NOTE: This function cannot currently handle LVs with an in-progress pvmove or
69586d7f5d3SJohn Marino  * lvconvert.
69686d7f5d3SJohn Marino  *
69786d7f5d3SJohn Marino  * \param   lv
69886d7f5d3SJohn Marino  * Logical volume handle.
69986d7f5d3SJohn Marino  *
70086d7f5d3SJohn Marino  * \return
70186d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
70286d7f5d3SJohn Marino  */
70386d7f5d3SJohn Marino int lvm_lv_activate(lv_t lv);
70486d7f5d3SJohn Marino 
70586d7f5d3SJohn Marino /**
70686d7f5d3SJohn Marino  * Deactivate a logical volume.
70786d7f5d3SJohn Marino  *
70886d7f5d3SJohn Marino  * This function is the equivalent of the lvm command "lvchange -an".
70986d7f5d3SJohn Marino  *
71086d7f5d3SJohn Marino  * \param   lv
71186d7f5d3SJohn Marino  * Logical volume handle.
71286d7f5d3SJohn Marino  *
71386d7f5d3SJohn Marino  * \return
71486d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
71586d7f5d3SJohn Marino  */
71686d7f5d3SJohn Marino int lvm_lv_deactivate(lv_t lv);
71786d7f5d3SJohn Marino 
71886d7f5d3SJohn Marino /**
71986d7f5d3SJohn Marino  * Remove a logical volume from a volume group.
72086d7f5d3SJohn Marino  *
72186d7f5d3SJohn Marino  * This function commits the change to disk and does _not_ require calling
72286d7f5d3SJohn Marino  * lvm_vg_write.
72386d7f5d3SJohn Marino  * NOTE: The commit behavior of this function is subject to change
72486d7f5d3SJohn Marino  * as the API is developed.
72586d7f5d3SJohn Marino  * Currently only removing linear LVs are possible.
72686d7f5d3SJohn Marino  *
72786d7f5d3SJohn Marino  * \param   lv
72886d7f5d3SJohn Marino  * Logical volume handle.
72986d7f5d3SJohn Marino  *
73086d7f5d3SJohn Marino  * \return
73186d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
73286d7f5d3SJohn Marino  */
73386d7f5d3SJohn Marino int lvm_vg_remove_lv(lv_t lv);
73486d7f5d3SJohn Marino 
73586d7f5d3SJohn Marino /**
73686d7f5d3SJohn Marino  * Get the current name of a logical volume.
73786d7f5d3SJohn Marino  *
73886d7f5d3SJohn Marino  * Memory is allocated using dm_malloc() and caller must free the memory
73986d7f5d3SJohn Marino  * using dm_free().
74086d7f5d3SJohn Marino  *
74186d7f5d3SJohn Marino  * \param   lv
74286d7f5d3SJohn Marino  * Logical volume handle.
74386d7f5d3SJohn Marino  *
74486d7f5d3SJohn Marino  * \return
74586d7f5d3SJohn Marino  * Copy of the uuid string.
74686d7f5d3SJohn Marino  */
74786d7f5d3SJohn Marino char *lvm_lv_get_uuid(const lv_t lv);
74886d7f5d3SJohn Marino 
74986d7f5d3SJohn Marino /**
75086d7f5d3SJohn Marino  * Get the current uuid of a logical volume.
75186d7f5d3SJohn Marino  *
75286d7f5d3SJohn Marino  * Memory is allocated using dm_malloc() and caller must free the memory
75386d7f5d3SJohn Marino  * using dm_free().
75486d7f5d3SJohn Marino  *
75586d7f5d3SJohn Marino  * \param   lv
75686d7f5d3SJohn Marino  * Logical volume handle.
75786d7f5d3SJohn Marino  *
75886d7f5d3SJohn Marino  * \return
75986d7f5d3SJohn Marino  * Copy of the name.
76086d7f5d3SJohn Marino  */
76186d7f5d3SJohn Marino char *lvm_lv_get_name(const lv_t lv);
76286d7f5d3SJohn Marino 
76386d7f5d3SJohn Marino /**
76486d7f5d3SJohn Marino  * Get the current size in bytes of a logical volume.
76586d7f5d3SJohn Marino  *
76686d7f5d3SJohn Marino  * \param   lv
76786d7f5d3SJohn Marino  * Logical volume handle.
76886d7f5d3SJohn Marino  *
76986d7f5d3SJohn Marino  * \return
77086d7f5d3SJohn Marino  * Size in bytes.
77186d7f5d3SJohn Marino  */
77286d7f5d3SJohn Marino uint64_t lvm_lv_get_size(const lv_t lv);
77386d7f5d3SJohn Marino 
77486d7f5d3SJohn Marino /**
77586d7f5d3SJohn Marino  * Get the current activation state of a logical volume.
77686d7f5d3SJohn Marino  *
77786d7f5d3SJohn Marino  * \param   lv
77886d7f5d3SJohn Marino  * Logical volume handle.
77986d7f5d3SJohn Marino  *
78086d7f5d3SJohn Marino  * \return
78186d7f5d3SJohn Marino  * 1 if the LV is active in the kernel, 0 if not
78286d7f5d3SJohn Marino  */
78386d7f5d3SJohn Marino uint64_t lvm_lv_is_active(const lv_t lv);
78486d7f5d3SJohn Marino 
78586d7f5d3SJohn Marino /**
78686d7f5d3SJohn Marino  * Get the current suspended state of a logical volume.
78786d7f5d3SJohn Marino  *
78886d7f5d3SJohn Marino  * \param   lv
78986d7f5d3SJohn Marino  * Logical volume handle.
79086d7f5d3SJohn Marino  *
79186d7f5d3SJohn Marino  * \return
79286d7f5d3SJohn Marino  * 1 if the LV is suspended in the kernel, 0 if not
79386d7f5d3SJohn Marino  */
79486d7f5d3SJohn Marino uint64_t lvm_lv_is_suspended(const lv_t lv);
79586d7f5d3SJohn Marino 
79686d7f5d3SJohn Marino /**
79786d7f5d3SJohn Marino  * Resize logical volume to new_size bytes.
79886d7f5d3SJohn Marino  *
79986d7f5d3SJohn Marino  * NOTE: This function is currently not implemented.
80086d7f5d3SJohn Marino  *
80186d7f5d3SJohn Marino  * \param   lv
80286d7f5d3SJohn Marino  * Logical volume handle.
80386d7f5d3SJohn Marino  *
80486d7f5d3SJohn Marino  * \param   new_size
80586d7f5d3SJohn Marino  * New size in bytes.
80686d7f5d3SJohn Marino  *
80786d7f5d3SJohn Marino  * \return
80886d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
80986d7f5d3SJohn Marino  *
81086d7f5d3SJohn Marino  */
81186d7f5d3SJohn Marino int lvm_lv_resize(const lv_t lv, uint64_t new_size);
81286d7f5d3SJohn Marino 
81386d7f5d3SJohn Marino /************************** physical volume handling ************************/
81486d7f5d3SJohn Marino 
81586d7f5d3SJohn Marino /**
81686d7f5d3SJohn Marino  * Physical volume handling should not be needed anymore. Only physical volumes
81786d7f5d3SJohn Marino  * bound to a vg contain useful information. Therefore the creation,
81886d7f5d3SJohn Marino  * modification and the removal of orphan physical volumes is not suported.
81986d7f5d3SJohn Marino  */
82086d7f5d3SJohn Marino 
82186d7f5d3SJohn Marino /**
82286d7f5d3SJohn Marino  * Return a list of PV handles for a given VG handle.
82386d7f5d3SJohn Marino  *
82486d7f5d3SJohn Marino  * \param   vg
82586d7f5d3SJohn Marino  * VG handle obtained from lvm_vg_create or lvm_vg_open.
82686d7f5d3SJohn Marino  *
82786d7f5d3SJohn Marino  * \return
82886d7f5d3SJohn Marino  * A list of pv_list_t structures containing pv handles for this vg.
82986d7f5d3SJohn Marino  * If no PVs exist on the given VG, NULL is returned.
83086d7f5d3SJohn Marino  */
83186d7f5d3SJohn Marino struct dm_list *lvm_vg_list_pvs(vg_t vg);
83286d7f5d3SJohn Marino 
83386d7f5d3SJohn Marino /**
83486d7f5d3SJohn Marino  * Get the current uuid of a logical volume.
83586d7f5d3SJohn Marino  *
83686d7f5d3SJohn Marino  * Memory is allocated using dm_malloc() and caller must free the memory
83786d7f5d3SJohn Marino  * using dm_free().
83886d7f5d3SJohn Marino  *
83986d7f5d3SJohn Marino  * \param   pv
84086d7f5d3SJohn Marino  * Physical volume handle.
84186d7f5d3SJohn Marino  *
84286d7f5d3SJohn Marino  * \return
84386d7f5d3SJohn Marino  * Copy of the uuid string.
84486d7f5d3SJohn Marino  */
84586d7f5d3SJohn Marino char *lvm_pv_get_uuid(const pv_t pv);
84686d7f5d3SJohn Marino 
84786d7f5d3SJohn Marino /**
84886d7f5d3SJohn Marino  * Get the current name of a logical volume.
84986d7f5d3SJohn Marino  *
85086d7f5d3SJohn Marino  * Memory is allocated using dm_malloc() and caller must free the memory
85186d7f5d3SJohn Marino  * using dm_free().
85286d7f5d3SJohn Marino  *
85386d7f5d3SJohn Marino  * \param   pv
85486d7f5d3SJohn Marino  * Physical volume handle.
85586d7f5d3SJohn Marino  *
85686d7f5d3SJohn Marino  * \return
85786d7f5d3SJohn Marino  * Copy of the name.
85886d7f5d3SJohn Marino  */
85986d7f5d3SJohn Marino char *lvm_pv_get_name(const pv_t pv);
86086d7f5d3SJohn Marino 
86186d7f5d3SJohn Marino /**
86286d7f5d3SJohn Marino  * Get the current number of metadata areas in the physical volume.
86386d7f5d3SJohn Marino  *
86486d7f5d3SJohn Marino  * \param   pv
86586d7f5d3SJohn Marino  * Physical volume handle.
86686d7f5d3SJohn Marino  *
86786d7f5d3SJohn Marino  * \return
86886d7f5d3SJohn Marino  * Number of metadata areas in the PV.
86986d7f5d3SJohn Marino  */
87086d7f5d3SJohn Marino uint64_t lvm_pv_get_mda_count(const pv_t pv);
87186d7f5d3SJohn Marino 
87286d7f5d3SJohn Marino /**
87386d7f5d3SJohn Marino  * Resize physical volume to new_size bytes.
87486d7f5d3SJohn Marino  *
87586d7f5d3SJohn Marino  * NOTE: This function is currently not implemented.
87686d7f5d3SJohn Marino  *
87786d7f5d3SJohn Marino  * \param   pv
87886d7f5d3SJohn Marino  * Physical volume handle.
87986d7f5d3SJohn Marino  *
88086d7f5d3SJohn Marino  * \param   new_size
88186d7f5d3SJohn Marino  * New size in bytes.
88286d7f5d3SJohn Marino  *
88386d7f5d3SJohn Marino  * \return
88486d7f5d3SJohn Marino  * 0 (success) or -1 (failure).
88586d7f5d3SJohn Marino  */
88686d7f5d3SJohn Marino int lvm_pv_resize(const pv_t pv, uint64_t new_size);
88786d7f5d3SJohn Marino 
88886d7f5d3SJohn Marino #endif /* _LIB_LVM2APP_H */
889