]> sourceware.org Git - lvm2.git/commitdiff
Add a new type and function to lvm2app to enumerate lvsegs.
authorPetr Rockai <prockai@redhat.com>
Wed, 17 Nov 2010 20:07:01 +0000 (20:07 +0000)
committerPetr Rockai <prockai@redhat.com>
Wed, 17 Nov 2010 20:07:01 +0000 (20:07 +0000)
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
liblvm/lvm2app.h
liblvm/lvm_lv.c

index a871df3981be15b7badb52828e7f55e877d3b484..5a3109c79406d4acc278dadc0303459c880f4cc4 100644 (file)
@@ -95,6 +95,7 @@ struct lvm;
 struct physical_volume;
 struct volume_group;
 struct logical_volume;
+struct lv_segment;
 
 /**
  * \class lvm_t
@@ -136,6 +137,13 @@ typedef struct logical_volume *lv_t;
  */
 typedef struct physical_volume *pv_t;
 
+/**
+ * \class lvseg_t
+ *
+ * This lv segment object is bound to a lv_t.
+ */
+typedef struct lv_segment *lvseg_t;
+
 /**
  * Logical Volume object list.
  *
@@ -146,6 +154,16 @@ typedef struct lvm_lv_list {
        lv_t lv;
 } lv_list_t;
 
+/**
+ * Logical Volume Segment object list.
+ *
+ * Lists of these structures are returned by lvm_lv_list_lvsegs().
+ */
+typedef struct lvm_lvseg_list {
+       struct dm_list list;
+       lvseg_t lvseg;
+} lvseg_list_t;
+
 /**
  * Physical volume object list.
  *
@@ -965,6 +983,19 @@ int lvm_vg_set_property(const vg_t vg, const char *name,
  */
 lv_t lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size);
 
+/**
+ * Return a list of lvseg handles for a given LV handle.
+ *
+ * \memberof lv_t
+ *
+ * \param   lv
+ * Logical volume handle.
+ *
+ * \return
+ * A list of lvm_lvseg_list structures containing lvseg handles for this lv.
+ */
+struct dm_list *lvm_lv_list_lvsegs(lv_t lv);
+
 /**
  * Activate a logical volume.
  *
index 825de57148599addf7d91d7205f9f00ebd4c831e..538c158c23982c0e8ff5e22244677f0758e12148 100644 (file)
@@ -216,6 +216,33 @@ int lvm_lv_deactivate(lv_t lv)
        return 0;
 }
 
+struct dm_list *lvm_lv_list_lvsegs(lv_t lv)
+{
+       struct dm_list *list;
+       lvseg_list_t *lvseg;
+       struct lv_segment *lvl;
+
+       if (dm_list_empty(&lv->segments))
+               return NULL;
+
+       if (!(list = dm_pool_zalloc(lv->vg->vgmem, sizeof(*list)))) {
+               log_errno(ENOMEM, "Memory allocation fail for dm_list.");
+               return NULL;
+       }
+       dm_list_init(list);
+
+       dm_list_iterate_items(lvl, &lv->segments) {
+               if (!(lvseg = dm_pool_zalloc(lv->vg->vgmem, sizeof(*lvseg)))) {
+                       log_errno(ENOMEM,
+                               "Memory allocation fail for lvm_lvseg_list.");
+                       return NULL;
+               }
+               lvseg->lvseg = lvl;
+               dm_list_add(list, &lvseg->list);
+       }
+       return list;
+}
+
 int lvm_lv_resize(const lv_t lv, uint64_t new_size)
 {
        /* FIXME: add lv resize code here */
This page took 0.030879 seconds and 5 git commands to generate.