Skip to contentSkip to conversation

lvm2app: Add method to retrieve attr from lv.

PATCH New Tony Asleson 1 participant 2 messages Apr 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lvm2app: Add method to retrieve attr from lv.

---
 liblvm/lvm2app.h | 16 ++++++++++++++++
 liblvm/lvm_lv.c  |  5 +++++
 2 files changed, 21 insertions(+)
liblvm/lvm2app.h +16 -0
index f889f2f..15827ac 100644
@@ -1207,6 +1207,22 @@ const char *lvm_lv_get_uuid(const lv_t lv);
 const char *lvm_lv_get_name(const lv_t lv);
 
 /**
+ * Get the attributes of a logical volume.
+ *
+ * \memberof lv_t
+ *
+ * The memory allocated for the name is tied to the vg_t handle and will be
+ * released when lvm_vg_close() is called.
+ *
+ * \param   lv
+ * Logical volume handle.
+ *
+ * \return
+ * Copy of the attributes for the logical volume
+ */
+const char *lvm_lv_get_attr(const lv_t lv);
+
+/**
  * Get the current size in bytes of a logical volume.
  *
  * \memberof lv_t
liblvm/lvm_lv.c +5 -0
index 8167fc3..9d3ae79 100644
@@ -48,6 +48,11 @@ const char *lvm_lv_get_name(const lv_t lv)
 			       NAME_LEN+1);
 }
 
+const char *lvm_lv_get_attr(const lv_t lv)
+{
+	return lv_attr_dup(lv->vg->vgmem, lv);
+}
+
 struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name)
 {
 	return get_property(NULL, NULL, lv, NULL, NULL, name);
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 2/2 python-lvm: Add method to retrieve lv attr.

---
 python/liblvm.c | 8 ++++++++
 1 file changed, 8 insertions(+)
python/liblvm.c +8 -0
index c76a3d0..96e94d4 100644
@@ -1193,6 +1193,13 @@ liblvm_pv_dealloc(pvobject *self)
 		}							\
 	} while (0)
 
+static PyObject *
+liblvm_lvm_lv_get_attr(lvobject *self)
+{
+	LV_VALID(self);
+
+	return Py_BuildValue("s", lvm_lv_get_attr(self->lv));
+}
 
 static PyObject *
 liblvm_lvm_lv_get_name(lvobject *self)
@@ -1749,6 +1756,7 @@ static PyMethodDef liblvm_vg_methods[] = {
 
 static PyMethodDef liblvm_lv_methods[] = {
 	/* lv methods */
+	{ "getAttr",		(PyCFunction)liblvm_lvm_lv_get_attr, METH_NOARGS },
 	{ "getName",		(PyCFunction)liblvm_lvm_lv_get_name, METH_NOARGS },
 	{ "getUuid",		(PyCFunction)liblvm_lvm_lv_get_uuid, METH_NOARGS },
 	{ "activate",		(PyCFunction)liblvm_lvm_lv_activate, METH_NOARGS },
Signature · 1 line
1.8.1.4