public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/liblvm lvm2app.h lvm_lv.c lvm_misc.c lvm_ ...
@ 2010-11-17 20:09 mornfall
  0 siblings, 0 replies; 2+ messages in thread
From: mornfall @ 2010-11-17 20:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-11-17 20:09:42

Modified files:
	liblvm         : lvm2app.h lvm_lv.c lvm_misc.c lvm_misc.h 
	                 lvm_pv.c lvm_vg.c 

Log message:
	Add lvm2app function to query lvseg properties.
	
	Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
	Reviewed-by: Petr Rockai <prockai@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_misc.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_misc.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_pv.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47

--- LVM2/liblvm/lvm2app.h	2010/11/17 20:07:01	1.25
+++ LVM2/liblvm/lvm2app.h	2010/11/17 20:09:42	1.26
@@ -1132,6 +1132,45 @@
 struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name);
 
 /**
+ * Get the value of a LV segment property
+ *
+ * \memberof lv_t
+ *
+ * \param   lvseg
+ * Logical volume segment handle.
+ *
+ * \param   name
+ * Name of property to query.  See lvs man page for full list of properties
+ * that may be queried.
+ *
+ * The memory allocated for a string property value is tied to the vg_t
+ * handle and will be released when lvm_vg_close() is called.
+ *
+ * Example:
+ *      lvm_property_value v;
+ *      char *prop_name = "seg_start_pe";
+ *
+ *      v = lvm_lvseg_get_property(lvseg, prop_name);
+ *      if (lvm_errno(libh) || !v.is_valid) {
+ *           // handle error
+ *           printf("Invalid property name or unable to query"
+ *                  "'%s'.\n", prop_name);
+ *           return;
+ *      }
+ *      if (v.is_string)
+ *           printf(", value = %s\n", v.value.string);
+ *	else
+ *           printf(", value = %"PRIu64"\n", v.value.integer);
+ *
+ * \return
+ * lvm_property_value structure that will contain the current
+ * value of the property.  Caller should check lvm_errno() as well
+ * as 'is_valid' flag before using the value.
+ */
+struct lvm_property_value lvm_lvseg_get_property(const lvseg_t lvseg,
+						 const char *name);
+
+/**
  * Get the current activation state of a logical volume.
  *
  * \memberof lv_t
--- LVM2/liblvm/lvm_lv.c	2010/11/17 20:07:01	1.29
+++ LVM2/liblvm/lvm_lv.c	2010/11/17 20:09:42	1.30
@@ -50,7 +50,13 @@
 
 struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name)
 {
-	return get_property(NULL, NULL, lv, name);
+	return get_property(NULL, NULL, lv, NULL, name);
+}
+
+struct lvm_property_value lvm_lvseg_get_property(const lvseg_t lvseg,
+						 const char *name)
+{
+	return get_property(NULL, NULL, NULL, lvseg, name);
 }
 
 uint64_t lvm_lv_is_active(const lv_t lv)
--- LVM2/liblvm/lvm_misc.c	2010/11/17 19:16:05	1.4
+++ LVM2/liblvm/lvm_misc.c	2010/11/17 20:09:42	1.5
@@ -46,7 +46,8 @@
 }
 
 struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
-				       const lv_t lv, const char *name)
+				       const lv_t lv, const lvseg_t lvseg,
+				       const char *name)
 {
 	struct lvm_property_type prop;
 	struct lvm_property_value v;
@@ -67,6 +68,11 @@
 			v.is_valid = 0;
 			return v;
 		}
+	} else if (lvseg) {
+		if (!lvseg_get_property(lvseg, &prop)) {
+			v.is_valid = 0;
+			return v;
+		}
 	}
 	v.is_settable = prop.is_settable;
 	v.is_string = prop.is_string;
--- LVM2/liblvm/lvm_misc.h	2010/11/17 19:16:05	1.4
+++ LVM2/liblvm/lvm_misc.h	2010/11/17 20:09:42	1.5
@@ -18,7 +18,8 @@
 
 struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list);
 struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
-				       const lv_t lv, const char *name);
+				       const lv_t lv, const lvseg_t lvseg,
+                                       const char *name);
 int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
 		 const char *name, struct lvm_property_value *value);
 
--- LVM2/liblvm/lvm_pv.c	2010/10/25 14:08:55	1.14
+++ LVM2/liblvm/lvm_pv.c	2010/11/17 20:09:42	1.15
@@ -51,7 +51,7 @@
 
 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
 {
-	return get_property(pv, NULL, NULL, name);
+	return get_property(pv, NULL, NULL, NULL, name);
 }
 
 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
--- LVM2/liblvm/lvm_vg.c	2010/11/17 19:16:05	1.46
+++ LVM2/liblvm/lvm_vg.c	2010/11/17 20:09:42	1.47
@@ -338,7 +338,7 @@
 
 struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name)
 {
-	return get_property(NULL, vg, NULL, name);
+	return get_property(NULL, vg, NULL, NULL, name);
 }
 
 int lvm_vg_set_property(const vg_t vg, const char *name,


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2/liblvm lvm2app.h lvm_lv.c lvm_misc.c lvm_ ...
@ 2010-11-17 20:12 mornfall
  0 siblings, 0 replies; 2+ messages in thread
From: mornfall @ 2010-11-17 20:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-11-17 20:12:40

Modified files:
	liblvm         : lvm2app.h lvm_lv.c lvm_misc.c lvm_misc.h 
	                 lvm_pv.c lvm_vg.c 

Log message:
	Add lvm2app function to query pvseg properties.
	
	Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
	Reviewed-by: Petr Rockai <prockai@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_misc.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_misc.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_pv.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48

--- LVM2/liblvm/lvm2app.h	2010/11/17 20:10:42	1.27
+++ LVM2/liblvm/lvm2app.h	2010/11/17 20:12:39	1.28
@@ -1437,6 +1437,45 @@
 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name);
 
 /**
+ * Get the value of a PV segment property
+ *
+ * \memberof pv_t
+ *
+ * \param   pvseg
+ * Physical volume segment handle.
+ *
+ * \param   name
+ * Name of property to query.  See pvs man page for full list of properties
+ * that may be queried.
+ *
+ * The memory allocated for a string property value is tied to the vg_t
+ * handle and will be released when lvm_vg_close() is called.
+ *
+ * Example:
+ *      lvm_property_value v;
+ *      char *prop_name = "pvseg_start";
+ *
+ *      v = lvm_pvseg_get_property(pvseg, prop_name);
+ *      if (lvm_errno(libh) || !v.is_valid) {
+ *           // handle error
+ *           printf("Invalid property name or unable to query"
+ *                  "'%s'.\n", prop_name);
+ *           return;
+ *      }
+ *      if (v.is_string)
+ *           printf(", value = %s\n", v.value.string);
+ *	else
+ *           printf(", value = %"PRIu64"\n", v.value.integer);
+ *
+ * \return
+ * lvm_property_value structure that will contain the current
+ * value of the property.  Caller should check lvm_errno() as well
+ * as 'is_valid' flag before using the value.
+ */
+struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
+						 const char *name);
+
+/**
  * Return a list of pvseg handles for a given PV handle.
  *
  * \memberof pv_t
--- LVM2/liblvm/lvm_lv.c	2010/11/17 20:09:42	1.30
+++ LVM2/liblvm/lvm_lv.c	2010/11/17 20:12:39	1.31
@@ -50,13 +50,13 @@
 
 struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name)
 {
-	return get_property(NULL, NULL, lv, NULL, name);
+	return get_property(NULL, NULL, lv, NULL, NULL, name);
 }
 
 struct lvm_property_value lvm_lvseg_get_property(const lvseg_t lvseg,
 						 const char *name)
 {
-	return get_property(NULL, NULL, NULL, lvseg, name);
+	return get_property(NULL, NULL, NULL, lvseg, NULL, name);
 }
 
 uint64_t lvm_lv_is_active(const lv_t lv)
--- LVM2/liblvm/lvm_misc.c	2010/11/17 20:09:42	1.5
+++ LVM2/liblvm/lvm_misc.c	2010/11/17 20:12:40	1.6
@@ -47,7 +47,7 @@
 
 struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
 				       const lv_t lv, const lvseg_t lvseg,
-				       const char *name)
+				       const pvseg_t pvseg, const char *name)
 {
 	struct lvm_property_type prop;
 	struct lvm_property_value v;
@@ -73,6 +73,11 @@
 			v.is_valid = 0;
 			return v;
 		}
+	} else if (pvseg) {
+		if (!pvseg_get_property(pvseg, &prop)) {
+			v.is_valid = 0;
+			return v;
+		}
 	}
 	v.is_settable = prop.is_settable;
 	v.is_string = prop.is_string;
--- LVM2/liblvm/lvm_misc.h	2010/11/17 20:09:42	1.5
+++ LVM2/liblvm/lvm_misc.h	2010/11/17 20:12:40	1.6
@@ -19,7 +19,7 @@
 struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list);
 struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
 				       const lv_t lv, const lvseg_t lvseg,
-                                       const char *name);
+				       const pvseg_t pvseg, const char *name);
 int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
 		 const char *name, struct lvm_property_value *value);
 
--- LVM2/liblvm/lvm_pv.c	2010/11/17 20:10:42	1.16
+++ LVM2/liblvm/lvm_pv.c	2010/11/17 20:12:40	1.17
@@ -51,7 +51,13 @@
 
 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
 {
-	return get_property(pv, NULL, NULL, NULL, name);
+	return get_property(pv, NULL, NULL, NULL, NULL, name);
+}
+
+struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
+						 const char *name)
+{
+	return get_property(NULL, NULL, NULL, NULL, pvseg, name);
 }
 
 struct dm_list *lvm_pv_list_pvsegs(pv_t pv)
--- LVM2/liblvm/lvm_vg.c	2010/11/17 20:09:42	1.47
+++ LVM2/liblvm/lvm_vg.c	2010/11/17 20:12:40	1.48
@@ -338,7 +338,7 @@
 
 struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name)
 {
-	return get_property(NULL, vg, NULL, NULL, name);
+	return get_property(NULL, vg, NULL, NULL, NULL, name);
 }
 
 int lvm_vg_set_property(const vg_t vg, const char *name,


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-17 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-17 20:09 LVM2/liblvm lvm2app.h lvm_lv.c lvm_misc.c lvm_ mornfall
2010-11-17 20:12 mornfall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).