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

index 1158bc5e99d26ac9862de0e08ac679e245095fce..b9c70d6c31aaee6d146964ba657c3cb21bcc653d 100644 (file)
@@ -96,6 +96,7 @@ struct physical_volume;
 struct volume_group;
 struct logical_volume;
 struct lv_segment;
+struct pv_segment;
 
 /**
  * \class lvm_t
@@ -144,6 +145,13 @@ typedef struct physical_volume *pv_t;
  */
 typedef struct lv_segment *lvseg_t;
 
+/**
+ * \class pvseg_t
+ *
+ * This pv segment object is bound to a pv_t.
+ */
+typedef struct pv_segment *pvseg_t;
+
 /**
  * Logical Volume object list.
  *
@@ -174,6 +182,16 @@ typedef struct lvm_pv_list {
        pv_t pv;
 } pv_list_t;
 
+/**
+ * Physical Volume Segment object list.
+ *
+ * Lists of these structures are returned by lvm_pv_list_pvsegs().
+ */
+typedef struct lvm_pvseg_list {
+       struct dm_list list;
+       pvseg_t pvseg;
+} pvseg_list_t;
+
 /**
  * String list.
  *
@@ -1418,6 +1436,19 @@ uint64_t lvm_pv_get_free(const pv_t pv);
  */
 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name);
 
+/**
+ * Return a list of pvseg handles for a given PV handle.
+ *
+ * \memberof pv_t
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * A list of lvm_pvseg_list structures containing pvseg handles for this pv.
+ */
+struct dm_list *lvm_pv_list_pvsegs(pv_t pv);
+
 /**
  * Resize physical volume to new_size bytes.
  *
index 6705dd81859fa9baacbdefb4e4286b424564da1d..aaaca92291dc33775bbeac82e72c4c867f9326d1 100644 (file)
@@ -54,6 +54,33 @@ struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
        return get_property(pv, NULL, NULL, NULL, name);
 }
 
+struct dm_list *lvm_pv_list_pvsegs(pv_t pv)
+{
+       struct dm_list *list;
+       pvseg_list_t *pvseg;
+       struct pv_segment *pvl;
+
+       if (dm_list_empty(&pv->segments))
+               return NULL;
+
+       if (!(list = dm_pool_zalloc(pv->vg->vgmem, sizeof(*list)))) {
+               log_errno(ENOMEM, "Memory allocation fail for dm_list.");
+               return NULL;
+       }
+       dm_list_init(list);
+
+       dm_list_iterate_items(pvl, &pv->segments) {
+               if (!(pvseg = dm_pool_zalloc(pv->vg->vgmem, sizeof(*pvseg)))) {
+                       log_errno(ENOMEM,
+                               "Memory allocation fail for lvm_pvseg_list.");
+                       return NULL;
+               }
+               pvseg->pvseg = pvl;
+               dm_list_add(list, &pvseg->list);
+       }
+       return list;
+}
+
 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
 {
        /* FIXME: add pv resize code here */
This page took 0.033699 seconds and 5 git commands to generate.