diff options
author | Dave Wysochanski <dwysocha@redhat.com> | 2009-07-24 12:47:15 +0000 |
---|---|---|
committer | Dave Wysochanski <dwysocha@redhat.com> | 2009-07-24 12:47:15 +0000 |
commit | 122ccd0d04a64ddc31de5e466a160bf02678e14d (patch) | |
tree | ae95bf10600bf1f973da61a82054c4d3b591663b /liblvm | |
parent | fd443e0245ff6a990f933dae261d85c894440f29 (diff) | |
download | lvm2-122ccd0d04a64ddc31de5e466a160bf02678e14d.tar.gz lvm2-122ccd0d04a64ddc31de5e466a160bf02678e14d.tar.xz lvm2-122ccd0d04a64ddc31de5e466a160bf02678e14d.zip |
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>
Diffstat (limited to 'liblvm')
-rw-r--r-- | liblvm/.exported_symbols | 2 | ||||
-rw-r--r-- | liblvm/lvm.h | 31 | ||||
-rw-r--r-- | liblvm/lvm_vg.c | 10 |
3 files changed, 43 insertions, 0 deletions
diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols index cb1319c4..c652625e 100644 --- a/liblvm/.exported_symbols +++ b/liblvm/.exported_symbols @@ -18,3 +18,5 @@ lvm_errno lvm_errmsg lvm_vg_list_pvs lvm_vg_list_lvs +lvm_list_vg_names +lvm_list_vg_ids diff --git a/liblvm/lvm.h b/liblvm/lvm.h index ba2077c8..2897fc0a 100644 --- a/liblvm/lvm.h +++ b/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 */ diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c index 052f446c..44120921 100644 --- a/liblvm/lvm_vg.c +++ b/liblvm/lvm_vg.c @@ -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); +} |