mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
Add lvm_list_vg_names and lvm_list_vg_ids liblvm functions.
These functions provide the capability of enumerating all vgnames and vgids in the system. They do not do a scan of the system. Author: Dave Wysochanski <dwysocha@redhat.com>
This commit is contained in:
parent
fd443e0245
commit
122ccd0d04
@ -18,3 +18,5 @@ lvm_errno
|
||||
lvm_errmsg
|
||||
lvm_vg_list_pvs
|
||||
lvm_vg_list_lvs
|
||||
lvm_list_vg_names
|
||||
lvm_list_vg_ids
|
||||
|
31
liblvm/lvm.h
31
liblvm/lvm.h
@ -44,6 +44,11 @@ typedef struct lvm_lv_list {
|
||||
lv_t *lv;
|
||||
} lv_list_t;
|
||||
|
||||
struct lvm_str_list {
|
||||
struct dm_list list;
|
||||
const char *str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a list of LV handles for a given VG handle.
|
||||
*
|
||||
@ -256,4 +261,30 @@ vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
|
||||
*/
|
||||
struct dm_list *lvm_vg_list_pvs(vg_t *vg);
|
||||
|
||||
/**
|
||||
* Return a list of VG names or VG uuids in the system.
|
||||
*
|
||||
* NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
|
||||
* To process the list, use the dm_list iterator functions. For example:
|
||||
* vg_t *vg;
|
||||
* struct dm_list *vgnames;
|
||||
* struct lvm_str_list *strl;
|
||||
*
|
||||
* vgnames = lvm_list_vg_names(libh);
|
||||
* dm_list_iterate_items(strl, vgnames) {
|
||||
* vgname = strl->str;
|
||||
* vg = lvm_vg_open(libh, vgname, "r");
|
||||
* // do something with vg
|
||||
* lvm_vg_close(vg);
|
||||
* }
|
||||
*
|
||||
*
|
||||
* \return A list of struct lvm_str_list
|
||||
* If no VGs exist on the system, NULL is returned.
|
||||
* FIXME: handle list memory cleanup
|
||||
*/
|
||||
struct dm_list *lvm_list_vg_names(lvm_t libh);
|
||||
struct dm_list *lvm_list_vg_ids(lvm_t libh);
|
||||
|
||||
|
||||
#endif /* _LIB_LVM_H */
|
||||
|
@ -188,3 +188,13 @@ char *lvm_vg_get_name(const vg_t *vg)
|
||||
name[NAME_LEN] = '\0';
|
||||
return name;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_list_vg_names(lvm_t libh)
|
||||
{
|
||||
return get_vgnames((struct cmd_context *)libh, 0);
|
||||
}
|
||||
|
||||
struct dm_list *lvm_list_vg_ids(lvm_t libh)
|
||||
{
|
||||
return get_vgids((struct cmd_context *)libh, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user