Skip to contentSkip to conversation

LVM2/liblvm .exported_symbols lvm2app.h lvm_lv.c

PATCH [email protected] 1 participant 1 message Feb 24, 2010

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2010-02-24 18:16:26

Modified files:
liblvm : .exported_symbols lvm2app.h lvm_lv.c

Log message:
Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag().

Add lvm2app functions to manage LV tags.
For lvm_lv_get_tags(), we return a list of tags, similar to other functions that return lists. An empty list is returned if there are no tags. NULL is returned if there is a problem obtaining the list of tags.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19

liblvm/.exported_symbols +3 -0
@@ -26,6 +26,9 @@
 lvm_lv_get_size
 lvm_lv_is_active
 lvm_lv_is_suspended
+lvm_lv_add_tag
+lvm_lv_remove_tag
+lvm_lv_get_tags
 lvm_vg_create
 lvm_vg_extend
 lvm_vg_reduce
liblvm/lvm2app.h +48 -0

54 lines not on this page · raw message

liblvm/lvm_lv.c +35 -0
@@ -20,9 +20,19 @@
 #include "segtype.h"
 #include "locking.h"
 #include "activate.h"
+#include "lvm_misc.h"
 
 #include <string.h>
 
+static int _lv_check_handle(const lv_t lv, const int vg_writeable)
+{
+	if (!lv || !lv->vg || vg_read_error(lv->vg))
+		return -1;
+	if (vg_writeable && !vg_check_write_mode(lv->vg))
+		return -1;
+	return 0;
+}
+
 /* FIXME: have lib/report/report.c _disp function call lv_size()? */
 uint64_t lvm_lv_get_size(const lv_t lv)
 {
@@ -68,6 +78,31 @@
 	return 0;
 }
 
+int lvm_lv_add_tag(lv_t lv, const char *tag)
+{
+	if (_lv_check_handle(lv, 1))
+		return -1;
+	if (!lv_change_tag(lv, tag, 1))
+		return -1;
+	return 0;
+}
+
+
+int lvm_lv_remove_tag(lv_t lv, const char *tag)
+{
+	if (_lv_check_handle(lv, 1))
+		return -1;
+	if (!lv_change_tag(lv, tag, 0))
+		return -1;
+	return 0;
+}
+
+
+struct dm_list *lvm_lv_get_tags(const lv_t lv)
+{
+	return tag_list_copy(lv->vg->vgmem, &lv->tags);
+}
+
 /* Set defaults for non-segment specific LV parameters */
 static void _lv_set_default_params(struct lvcreate_params *lp,
 				   vg_t vg, const char *lvname,