lv_t *lv;
} lv_list_t;
+/**
+ * Return a list of LV handles for a given VG handle.
+ *
+ * \return A list of lv_list_t structures containing lv handles for this vg.
+ * If no LVs exist on the given VG, NULL is returned.
+ */
+struct dm_list *lvm_vg_list_lvs(vg_t *vg);
struct lvm; /* internal data */
vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
uint32_t flags);
+/**
+ * Return a list of PV handles for a given VG handle.
+ *
+ * \return A list of pv_list_t structures containing pv handles for this vg.
+ * If no PVs exist on the given VG, NULL is returned.
+ */
+struct dm_list *lvm_vg_list_pvs(vg_t *vg);
+
#endif /* _LIB_LVM_H */
return vg;
}
+
+struct dm_list *lvm_vg_list_pvs(vg_t *vg)
+{
+ struct dm_list *list;
+ pv_list_t *pvs;
+ struct pv_list *pvl;
+
+ if (dm_list_empty(&vg->pvs))
+ return NULL;
+
+ if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) {
+ log_error("Memory allocation fail for dm_list.\n");
+ return NULL;
+ }
+ dm_list_init(list);
+
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (!(pvs = dm_pool_zalloc(vg->vgmem, sizeof(*pvs)))) {
+ log_error("Memory allocation fail for lvm_pv_list.\n");
+ return NULL;
+ }
+ pvs->pv = pvl->pv;
+ dm_list_add(list, &pvs->list);
+ }
+ return list;
+}
+
+struct dm_list *lvm_vg_list_lvs(vg_t *vg)
+{
+ struct dm_list *list;
+ lv_list_t *lvs;
+ struct lv_list *lvl;
+
+ if (dm_list_empty(&vg->lvs))
+ return NULL;
+
+ if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) {
+ log_error("Memory allocation fail for dm_list.\n");
+ return NULL;
+ }
+ dm_list_init(list);
+
+ dm_list_iterate_items(lvl, &vg->lvs) {
+ if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
+ log_error("Memory allocation fail for lvm_lv_list.\n");
+ return NULL;
+ }
+ lvs->lv = lvl->lv;
+ dm_list_add(list, &lvs->list);
+ }
+ return list;
+}