summaryrefslogtreecommitdiffstats
path: root/liblvm
diff options
context:
space:
mode:
authorDave Wysochanski <dwysocha@redhat.com>2009-07-27 11:00:17 +0000
committerDave Wysochanski <dwysocha@redhat.com>2009-07-27 11:00:17 +0000
commit0589e19fd7d7ee1c864fa814845d2ed5f46fc15d (patch)
tree523635883b70eed1e7c6c9f87640698ccab5d679 /liblvm
parentf6b1eaf7005f847e3230537feb47306d68b17b44 (diff)
downloadlvm2-0589e19fd7d7ee1c864fa814845d2ed5f46fc15d.tar.gz
lvm2-0589e19fd7d7ee1c864fa814845d2ed5f46fc15d.tar.xz
lvm2-0589e19fd7d7ee1c864fa814845d2ed5f46fc15d.zip
Update error return and comments for lvm_list_vg_names/uuids.
The two liblvm functions that return a list of vgnames and vguuids use cmd->mem to allocate the list. Make it clear to the caller that this memory will be freed when the LVM handle is freed. Clean up and clarify the return value of the functions. In the case of a memory allocation error, add a couple log_errnos to the internal code, and make it clear that memory allocation returns a NULL pointer. If there are no VGs in the system, the list returned is an empty list. Make a note of the fact that currently we return hidden VG names, how these can be detected (always start with "#"), and that they should not be used. Author: Dave Wysochanski <dwysocha@redhat.com>
Diffstat (limited to 'liblvm')
-rw-r--r--liblvm/lvm.h20
-rw-r--r--liblvm/lvm_vg.c5
2 files changed, 21 insertions, 4 deletions
diff --git a/liblvm/lvm.h b/liblvm/lvm.h
index 328b33e4..73ba6d94 100644
--- a/liblvm/lvm.h
+++ b/liblvm/lvm.h
@@ -185,8 +185,13 @@ int lvm_scan(lvm_t libh);
/**
* Return the list of volume group names.
*
+ * The memory allocated for the list is tied to the lvm_t handle and will be
+ * released when lvm_destroy is called.
+ *
* NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
* To scan the system, use lvm_scan.
+ * NOTE: This function currently returns hidden VG names. These names always
+ * begin with a "#" and should be filtered out and not used.
*
* To process the list, use the dm_list iterator functions. For example:
* vg_t *vg;
@@ -203,23 +208,30 @@ int lvm_scan(lvm_t libh);
*
*
* \return A list of struct lvm_str_list
- * If no VGs exist on the system, NULL is returned.
- *
- * FIXME: handle list memory cleanup
+ * NULL is returned if unable to allocate memory.
+ * An empty list (verify with dm_list_empty) is returned if no VGs
+ * exist on the system.
*/
struct dm_list *lvm_list_vg_names(lvm_t libh);
/**
* Return the list of volume group uuids.
*
+ * The memory allocated for the list is tied to the lvm_t handle and will be
+ * released when lvm_destroy is called.
+ *
* NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
* To scan the system, use lvm_scan.
+ * NOTE: This function currently returns hidden VG names. These names always
+ * begin with a "#" and should be filtered out and not used.
*
* \param libh
* Handle obtained from lvm_create.
*
* \return List of copied uuid strings.
- * If no VGs exist on the system, NULL is returned.
+ * NULL is returned if unable to allocate memory.
+ * An empty list (verify with dm_list_empty) is returned if no VGs
+ * exist on the system.
*/
struct dm_list *lvm_list_vg_uuids(lvm_t libh);
diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c
index 48005558..cd2ef46c 100644
--- a/liblvm/lvm_vg.c
+++ b/liblvm/lvm_vg.c
@@ -240,6 +240,11 @@ char *lvm_vg_get_name(const vg_t *vg)
return name;
}
+/*
+ * FIXME: These functions currently return hidden VGs. We should either filter
+ * these out and not return them in the list, or export something like
+ * is_orphan_vg and tell the caller to filter.
+ */
struct dm_list *lvm_list_vg_names(lvm_t libh)
{
return get_vgnames((struct cmd_context *)libh, 0);