All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8]: liblvm object attribute baseline
@ 2009-04-29 19:55 Dave Wysochanski
  2009-04-29 19:55 ` [PATCH 1/8] Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg Dave Wysochanski
  2009-04-29 20:23 ` [PATCH 0/8]: liblvm object attribute baseline Dave Wysochanski
  0 siblings, 2 replies; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

The following 8 patches implement a baseline for liblvm objects and their
attributes.  The primary focus/goal of these patches are:
1. Define / clarify the main liblvm objects and their handles
2. Get the object properties for a specific handle

Together with the handles, the 'get' functions will provide equivalent
functionality to the reporting commands (pvs, vgs, lvs) while keeping with
the object model of liblvm.




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

* [PATCH 1/8] Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg.
  2009-04-29 19:55 [PATCH 0/8]: liblvm object attribute baseline Dave Wysochanski
@ 2009-04-29 19:55 ` Dave Wysochanski
  2009-04-29 19:55   ` [PATCH 2/8] Add lvm_object_prop.pl to generate liblvm object property function prototype Dave Wysochanski
  2009-04-29 20:23 ` [PATCH 0/8]: liblvm object attribute baseline Dave Wysochanski
  1 sibling, 1 reply; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

Define the 5 main liblvm objects to be the pv, vg, lv, lvseg, and pvseg.
We need handles defined to all these objects in order for liblvm to be
equivalent to the reporting commands pvs, vgs, and lvs.

- move vg_t, lv_t, and pv_t from metadata-exported.h into lvm.h
- move lv_segment and pv_segment forward declarations into lvm.h
- add lvseg_t and pvseg_t to lvm.h

NOTE: We currently have an inconsistency in handle definitions.
lvm_t is defined as a pointer, while these other handles are just
structures.  We should pick one scheme and be consistent - perhaps
define all handles as pointers (this is what I've seen elsewhere).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 lib/metadata/metadata-exported.h |   11 +----------
 liblvm/lvm.h                     |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 3b13e37..6f5d73b 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -22,16 +22,7 @@
 #define _LVM_METADATA_EXPORTED_H
 
 #include "uuid.h"
-
-struct physical_volume;
-typedef struct physical_volume pv_t;
-struct volume_group;
-typedef struct volume_group vg_t;
-
-struct logical_volume;
-
-struct lv_segment;
-struct pv_segment;
+#include "lvm.h"
 
 #define MAX_STRIPES 128U
 #define SECTOR_SHIFT 9L
diff --git a/liblvm/lvm.h b/liblvm/lvm.h
index 3b60510..4e71e15 100644
--- a/liblvm/lvm.h
+++ b/liblvm/lvm.h
@@ -18,6 +18,20 @@
 
 #include <stdint.h>
 
+/* Internal object structures */
+struct volume_group;
+struct physical_volume;
+struct logical_volume;
+struct lv_segment;
+struct pv_segment;
+
+/* liblvm handles to objects pv, vg, lv, pvseg, lvseg */
+typedef struct volume_group vg_t;
+typedef struct physical_volume pv_t;
+typedef struct logical_volume lv_t;
+typedef struct pv_segment pvseg_t;
+typedef struct lv_segment lvseg_t;
+
 struct lvm; /* internal data */
 
 /**
@@ -54,4 +68,5 @@ void lvm_destroy(lvm_t libh);
  */
 int lvm_reload_config(lvm_t libh);
 
+
 #endif /* _LIB_LVM_H */
-- 
1.6.0.6



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

* [PATCH 2/8] Add lvm_object_prop.pl to generate liblvm object property function prototype
  2009-04-29 19:55 ` [PATCH 1/8] Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg Dave Wysochanski
@ 2009-04-29 19:55   ` Dave Wysochanski
  2009-04-29 19:55     ` [PATCH 3/8] Add generated files, lvm_object_prop.[ch], to liblvm build Dave Wysochanski
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

The term 'attribute' is used in some of the reporting fields (e.g. vg_attr),
so we avoid it here and instead use the term 'properties' or 'prop'.

NOTE: The intent of the perl code, lvm_object_prop.pl, is to help maintain
liblvm object property consistency with the reporting commands pvs, vgs, lvs
As new fields get added to columns.h, we should re-run this script on the ne
FIELD line(s), take the generated code, edit as appropriate, and place into
appropriate liblvm code file.

This patch adds the perl file, lvm_object_prop.pl.  A later patch will
add the files this code generates, namely the liblvm object property
function header and C file, lvm_object_prop.[ch].

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/lvm_object_prop.pl |  221 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 221 insertions(+), 0 deletions(-)
 create mode 100644 liblvm/lvm_object_prop.pl

diff --git a/liblvm/lvm_object_prop.pl b/liblvm/lvm_object_prop.pl
new file mode 100644
index 0000000..08c492d
--- /dev/null
+++ b/liblvm/lvm_object_prop.pl
@@ -0,0 +1,221 @@
+#!/usr/bin/perl
+#
+# Take the colunms.h file as input and produce a header and
+# default code for liblvm object property accessor and mutator functions.
+# To run: perl lvm_object_prop.pl < ../lib/report/columns.h
+#
+# For maintenance purposes, when adding a new line to columns.h,
+# we can pipe the diff to this program to generate the new prototypes
+# and C code, then cut/paste into the proper liblvm files.
+#
+
+sub write_code_header;
+sub write_code_body;
+sub write_code_footer;
+sub write_include_header;
+sub write_include_body;
+sub write_include_footer;
+
+#
+# Open the files and write the headers
+#
+$outfile = "lvm_object_prop";
+open(INCLUDE_FILE, ">./$outfile.h") || die "Cannot open $outfile.h!\n";
+write_include_header(INCLUDE_FILE);
+open(CODE_FILE, ">./$outfile.c") || die "Cannot open $outfile.c!\n";
+write_code_header(CODE_FILE);
+
+#
+# Write the include and code body
+#
+while(<>) {
+    # Skip if line does not begin w/"FIELD" - not perfect but does the job
+    if ($_ !~ /^FIELD/) {
+	next;
+    }
+    # Pull out the actual parameters to the FIELD macro
+    m%FIELD\((.*)\)%;
+    $_ = $1;
+
+    #FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid", "Unique identifier")
+    # NOTE: I tried using Text:CSV but could not make it work.
+    # Parse using brute force regex
+    m%(\S+),\s*(\S+),\s*(\S+),\s*(\".*\"),\s*(\S+),\s*(\S+),\s*(\S+),\s*(\".*\"),\s*(\".*\")%;
+    ($type, $strct, $sorttype, $head, $field, $width, $func, $id, $desc) =
+	    ($1, $2, $3, $4, $5, $6, $7, $8, $9);
+
+    #
+    # Fixup the id / field name / attribute name
+    #
+
+    # Unquote 'id' (field name) and description
+    $id =~ tr/"//d;
+    $desc =~ tr/"//d;
+
+    # Skip redundant fields
+    if ($id =~ /^(stripesize|regionsize|chunksize)$/) {
+        next;
+    }
+
+    # Map report type to liblvm object name
+    # - PVS, VGS, LVS reports, the liblvm object is pv/vg/lv
+    # - PVSEG, the object is pvseg
+    # - SEG, the object is lvseg
+    # - LABEL, the object is pv
+    if ($type =~ /^PVS$/) {
+	$object = "pv";
+    } elsif ($type =~ /^VGS$/) {
+	$object = "vg";
+    } elsif ($type =~ /^LVS$/) {
+	$object = "lv";
+    } elsif ($type =~ /^LABEL$/) {
+	$object = "pv";
+    } elsif ($type =~ /^SEGS$/) {
+	$object = "lvseg";
+    } elsif ($type =~ /^PVSEGS$/) {
+	$object = "pvseg";
+    } else {
+	print "Skipping type: $type, line: $_\n"; #DEBUG
+	next;
+    }
+    # Some field names/ids contain the struct name, while others don't.
+    # For consistency, if the field name contains the struct name, remove
+    # it (we always put the object name in the function name.
+    #
+    if ($id =~ /^$strct/) {
+	$id = substr($id,length($strct)+1,length($id));
+    }
+    if ($sorttype =~ m/STR/) {
+	$attr_type = "const char *";
+    } else {
+	$attr_type = "const uint64_t ";
+    }
+    # Write 'get' prototype to header and code to C file.
+    write_include_body(INCLUDE_FILE, $object, $id, $desc, $attr_type);
+    write_code_body(CODE_FILE, $object, $sorttype, $id, $desc, $attr_type);
+
+}
+
+write_include_footer(INCLUDE_FILE);
+write_code_footer(CODE_FILE);
+close(INCLUDE_FILE);
+close(CODE_FILE);
+
+sub write_include_header
+{
+    my($file) = @_;
+    print $file <<ENDHEADER;
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _LVM_OBJECT_PROP_H
+#define _LVM_OBJECT_PROP_H
+
+ENDHEADER
+}
+
+sub write_include_body
+{
+    my($file, $object, $id, $desc, $attr_type) = @_;
+    #
+    # Use the description and field name in the comment
+    #
+    print $file "/**\n";
+    print $file " * "."lvm_"."$object"."_{get|set}_$id\n";
+    print $file " * $id - $desc\n";
+    print $file " */\n";
+    # Write out 'get' method prototype
+    $fun_name = "lvm_"."$object"."_get_$id";
+    $fun_args = "($object"."_t *$object)";
+    print $file "$attr_type"."$fun_name"."$fun_args".";\n";
+    # Write out 'set' method prototype
+    $fun_name = "lvm_"."$object"."_set_$id";
+    $fun_args = "($object"."_t *$object, $attr_type"."value)";
+    print $file "int "."$fun_name"."$fun_args".";\n\n";
+}
+
+sub write_include_footer
+{
+    my($file) = @_;
+    print $file <<ENDFOOTER;
+#endif
+ENDFOOTER
+}
+
+sub write_code_header
+{
+    my($file) = @_;
+    print $file <<ENDCODE1;
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "lvm.h"
+
+ENDCODE1
+}
+
+sub write_code_body
+{
+    my($file, $object, $sorttype, $id, $desc, $attr_type) = @_;
+    print $file "/**\n";
+    print $file " * "."lvm_"."$object"."_{get|set}_$id\n";
+    print $file " * $id - $desc\n";
+    print $file " */\n";
+    # Write out 'get' method
+    $fun_name = "lvm_"."$object"."_get_$id";
+    $fun_args = "($object"."_t *$object)";
+    print $file "$attr_type"."$fun_name"."$fun_args"."\n";
+    if ($sorttype =~ m/STR/) {
+        print $file <<ENDCODE4;
+{
+    /* FIXME: implement function body */
+    return ($attr_type)0;
+}
+ENDCODE4
+	} else {
+    print $file <<ENDCODE5;
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+ENDCODE5
+    }
+    # Write out 'set' method
+    $fun_name = "lvm_"."$object"."_set_$id";
+    $fun_args = "($object"."_t *$object, $attr_type"."value)";
+    print $file "int "."$fun_name"."$fun_args"."\n";
+    print $file <<ENDCODE2;
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+ENDCODE2
+}
+
+
+sub write_code_footer
+{
+# nothing to do
+}
-- 
1.6.0.6



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

* [PATCH 3/8] Add generated files, lvm_object_prop.[ch], to liblvm build.
  2009-04-29 19:55   ` [PATCH 2/8] Add lvm_object_prop.pl to generate liblvm object property function prototype Dave Wysochanski
@ 2009-04-29 19:55     ` Dave Wysochanski
  2009-04-29 19:55       ` [PATCH 4/8] Implement lvm_{vg|lv}_get_{name|uuid} Dave Wysochanski
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

These files were generated from using the current columns.h file as input
into lvm_object_prop.pl.  They are a starting point for liblvm object
property get/set functions.  Actual code implementing the functions will
be added later.

Include lvm_object_prop.h in lvm.h

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 include/.symlinks        |    1 +
 liblvm/Makefile.in       |    3 +-
 liblvm/lvm.h             |    1 +
 liblvm/lvm_object_prop.c | 1009 ++++++++++++++++++++++++++++++++++++++++++++++
 liblvm/lvm_object_prop.h |  494 +++++++++++++++++++++++
 5 files changed, 1507 insertions(+), 1 deletions(-)
 create mode 100644 liblvm/lvm_object_prop.c
 create mode 100644 liblvm/lvm_object_prop.h

diff --git a/include/.symlinks b/include/.symlinks
index 28da67f..35461af 100644
--- a/include/.symlinks
+++ b/include/.symlinks
@@ -1,6 +1,7 @@
 ../daemons/clvmd/clvm.h
 ../daemons/dmeventd/libdevmapper-event.h
 ../liblvm/lvm.h
+../liblvm/lvm_object_prop.h
 ../lib/activate/activate.h
 ../lib/activate/targets.h
 ../lib/cache/lvmcache.h
diff --git a/liblvm/Makefile.in b/liblvm/Makefile.in
index 3ab4950..a560533 100644
--- a/liblvm/Makefile.in
+++ b/liblvm/Makefile.in
@@ -17,7 +17,8 @@ top_srcdir = @top_srcdir@
 VPATH = @srcdir@
 
 SOURCES =\
-	lvm_base.c
+	lvm_base.c \
+	lvm_object_prop.c
 
 LIB_NAME = liblvm
 LIB_VERSION = $(LIB_VERSION_LVM)
diff --git a/liblvm/lvm.h b/liblvm/lvm.h
index 4e71e15..55dcb68 100644
--- a/liblvm/lvm.h
+++ b/liblvm/lvm.h
@@ -68,5 +68,6 @@ void lvm_destroy(lvm_t libh);
  */
 int lvm_reload_config(lvm_t libh);
 
+#include "lvm_object_prop.h"
 
 #endif /* _LIB_LVM_H */
diff --git a/liblvm/lvm_object_prop.c b/liblvm/lvm_object_prop.c
new file mode 100644
index 0000000..2b02457
--- /dev/null
+++ b/liblvm/lvm_object_prop.c
@@ -0,0 +1,1009 @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "lvm.h"
+
+/**
+ * lvm_lv_{get|set}_uuid
+ * uuid - Unique identifier.
+ */
+const char *lvm_lv_get_uuid(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_uuid(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_name
+ * name - Name.  LVs created for internal use are enclosed in brackets.
+ */
+const char *lvm_lv_get_name(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_name(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_attr
+ * attr - Various attributes - see man page.
+ */
+const char *lvm_lv_get_attr(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_attr(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_major
+ * major - Persistent major number or -1 if not persistent.
+ */
+const uint64_t lvm_lv_get_major(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_major(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_minor
+ * minor - Persistent minor number or -1 if not persistent.
+ */
+const uint64_t lvm_lv_get_minor(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_minor(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_read_ahead
+ * read_ahead - Read ahead setting in current units.
+ */
+const uint64_t lvm_lv_get_read_ahead(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_read_ahead(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_kernel_major
+ * kernel_major - Currently assigned major number or -1 if LV is not active.
+ */
+const char *lvm_lv_get_kernel_major(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_kernel_major(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_kernel_minor
+ * kernel_minor - Currently assigned minor number or -1 if LV is not active.
+ */
+const char *lvm_lv_get_kernel_minor(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_kernel_minor(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_kernel_read_ahead
+ * kernel_read_ahead - Currently-in-use read ahead setting in current units.
+ */
+const uint64_t lvm_lv_get_kernel_read_ahead(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_kernel_read_ahead(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_size
+ * size - Size of LV in current units.
+ */
+const uint64_t lvm_lv_get_size(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_size(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_seg_count
+ * seg_count - Number of segments in LV.
+ */
+const uint64_t lvm_lv_get_seg_count(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_seg_count(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_origin
+ * origin - For snapshots, the origin device of this LV.
+ */
+const char *lvm_lv_get_origin(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_origin(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_origin_size
+ * origin_size - For snapshots, the size of the origin device of this LV.
+ */
+const uint64_t lvm_lv_get_origin_size(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_origin_size(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_snap_percent
+ * snap_percent - For snapshots, the percentage full if LV is active.
+ */
+const uint64_t lvm_lv_get_snap_percent(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_snap_percent(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_copy_percent
+ * copy_percent - For mirrors and pvmove, current percentage in-sync.
+ */
+const uint64_t lvm_lv_get_copy_percent(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lv_set_copy_percent(lv_t *lv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_move_pv
+ * move_pv - For pvmove, Source PV of temporary LV created by pvmove.
+ */
+const char *lvm_lv_get_move_pv(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_move_pv(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_convert_lv
+ * convert_lv - For lvconvert, Name of temporary LV created by lvconvert.
+ */
+const char *lvm_lv_get_convert_lv(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_convert_lv(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_lv_get_tags(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_tags(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_mirror_log
+ * mirror_log - For mirrors, the LV holding the synchronisation log.
+ */
+const char *lvm_lv_get_mirror_log(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_mirror_log(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lv_{get|set}_modules
+ * modules - Kernel device-mapper modules required for this LV.
+ */
+const char *lvm_lv_get_modules(lv_t *lv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lv_set_modules(lv_t *lv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_fmt
+ * fmt - Type of metadata.
+ */
+const char *lvm_pv_get_fmt(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_pv_set_fmt(pv_t *pv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_uuid
+ * uuid - Unique identifier.
+ */
+const char *lvm_pv_get_uuid(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_pv_set_uuid(pv_t *pv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_dev_size
+ * dev_size - Size of underlying device in current units.
+ */
+const uint64_t lvm_pv_get_dev_size(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_dev_size(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_name
+ * name - Name.
+ */
+const char *lvm_pv_get_name(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_pv_set_name(pv_t *pv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_mda_free
+ * mda_free - Free metadata area space on this device in current units.
+ */
+const uint64_t lvm_pv_get_mda_free(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_mda_free(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_mda_size
+ * mda_size - Size of smallest metadata area on this device in current units.
+ */
+const uint64_t lvm_pv_get_mda_size(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_mda_size(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_pe_start
+ * pe_start - Offset to the start of data on the underlying device.
+ */
+const uint64_t lvm_pv_get_pe_start(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_pe_start(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_size
+ * size - Size of PV in current units.
+ */
+const uint64_t lvm_pv_get_size(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_size(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_free
+ * free - Total amount of unallocated space in current units.
+ */
+const uint64_t lvm_pv_get_free(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_free(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_used
+ * used - Total amount of allocated space in current units.
+ */
+const uint64_t lvm_pv_get_used(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_used(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_attr
+ * attr - Various attributes - see man page.
+ */
+const char *lvm_pv_get_attr(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_pv_set_attr(pv_t *pv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_pe_count
+ * pe_count - Total number of Physical Extents.
+ */
+const uint64_t lvm_pv_get_pe_count(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_pe_count(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_pe_alloc_count
+ * pe_alloc_count - Total number of allocated Physical Extents.
+ */
+const uint64_t lvm_pv_get_pe_alloc_count(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_pe_alloc_count(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_pv_get_tags(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_pv_set_tags(pv_t *pv, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pv_{get|set}_mda_count
+ * mda_count - Number of metadata areas on this device.
+ */
+const uint64_t lvm_pv_get_mda_count(pv_t *pv)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pv_set_mda_count(pv_t *pv, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_fmt
+ * fmt - Type of metadata.
+ */
+const char *lvm_vg_get_fmt(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_vg_set_fmt(vg_t *vg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_uuid
+ * uuid - Unique identifier.
+ */
+const char *lvm_vg_get_uuid(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_vg_set_uuid(vg_t *vg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_name
+ * name - Name.
+ */
+const char *lvm_vg_get_name(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_vg_set_name(vg_t *vg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_attr
+ * attr - Various attributes - see man page.
+ */
+const char *lvm_vg_get_attr(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_vg_set_attr(vg_t *vg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_size
+ * size - Total size of VG in current units.
+ */
+const uint64_t lvm_vg_get_size(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_size(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_free
+ * free - Total amount of free space in current units.
+ */
+const uint64_t lvm_vg_get_free(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_free(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_sysid
+ * sysid - System ID indicating when and where it was created.
+ */
+const char *lvm_vg_get_sysid(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_vg_set_sysid(vg_t *vg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_extent_size
+ * extent_size - Size of Physical Extents in current units.
+ */
+const uint64_t lvm_vg_get_extent_size(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_extent_size(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_extent_count
+ * extent_count - Total number of Physical Extents.
+ */
+const uint64_t lvm_vg_get_extent_count(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_extent_count(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_free_count
+ * free_count - Total number of unallocated Physical Extents.
+ */
+const uint64_t lvm_vg_get_free_count(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_free_count(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_max_lv
+ * max_lv - Maximum number of LVs allowed in VG or 0 if unlimited.
+ */
+const uint64_t lvm_vg_get_max_lv(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_max_lv(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_max_pv
+ * max_pv - Maximum number of PVs allowed in VG or 0 if unlimited.
+ */
+const uint64_t lvm_vg_get_max_pv(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_max_pv(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_pv_count
+ * pv_count - Number of PVs.
+ */
+const uint64_t lvm_vg_get_pv_count(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_pv_count(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_lv_count
+ * lv_count - Number of LVs.
+ */
+const uint64_t lvm_vg_get_lv_count(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_lv_count(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_snap_count
+ * snap_count - Number of snapshots.
+ */
+const uint64_t lvm_vg_get_snap_count(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_snap_count(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_seqno
+ * seqno - Revision number of internal metadata.  Incremented whenever it changes.
+ */
+const uint64_t lvm_vg_get_seqno(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_seqno(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_vg_get_tags(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_vg_set_tags(vg_t *vg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_mda_count
+ * mda_count - Number of metadata areas in use by this VG.
+ */
+const uint64_t lvm_vg_get_mda_count(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_mda_count(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_mda_free
+ * mda_free - Free metadata area space for this VG in current units.
+ */
+const uint64_t lvm_vg_get_mda_free(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_mda_free(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_vg_{get|set}_mda_size
+ * mda_size - Size of smallest metadata area for this VG in current units.
+ */
+const uint64_t lvm_vg_get_mda_size(vg_t *vg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_vg_set_mda_size(vg_t *vg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_ype
+ * ype - Type of LV segment.
+ */
+const char *lvm_lvseg_get_ype(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lvseg_set_ype(lvseg_t *lvseg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_stripes
+ * stripes - Number of stripes or mirror legs.
+ */
+const uint64_t lvm_lvseg_get_stripes(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lvseg_set_stripes(lvseg_t *lvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_stripe_size
+ * stripe_size - For stripes, amount of data placed on one device before switching to the next.
+ */
+const uint64_t lvm_lvseg_get_stripe_size(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lvseg_set_stripe_size(lvseg_t *lvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_region_size
+ * region_size - For mirrors, the unit of data copied when synchronising devices.
+ */
+const uint64_t lvm_lvseg_get_region_size(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lvseg_set_region_size(lvseg_t *lvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_chunk_size
+ * chunk_size - For snapshots, the unit of data used when tracking changes.
+ */
+const uint64_t lvm_lvseg_get_chunk_size(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lvseg_set_chunk_size(lvseg_t *lvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_start
+ * start - Offset within the LV to the start of the segment in current units.
+ */
+const uint64_t lvm_lvseg_get_start(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lvseg_set_start(lvseg_t *lvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_start_pe
+ * start_pe - Offset within the LV to the start of the segment in physical extents.
+ */
+const uint64_t lvm_lvseg_get_start_pe(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lvseg_set_start_pe(lvseg_t *lvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_size
+ * size - Size of segment in current units.
+ */
+const uint64_t lvm_lvseg_get_size(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_lvseg_set_size(lvseg_t *lvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_lvseg_get_tags(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lvseg_set_tags(lvseg_t *lvseg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_pe_ranges
+ * pe_ranges - Ranges of Physical Extents of underlying devices in command line format.
+ */
+const char *lvm_lvseg_get_pe_ranges(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lvseg_set_pe_ranges(lvseg_t *lvseg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_lvseg_{get|set}_devices
+ * devices - Underlying devices used with starting extent numbers.
+ */
+const char *lvm_lvseg_get_devices(lvseg_t *lvseg)
+{
+    /* FIXME: implement function body */
+    return (const char *)0;
+}
+int lvm_lvseg_set_devices(lvseg_t *lvseg, const char *value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pvseg_{get|set}_start
+ * start - Physical Extent number of start of segment.
+ */
+const uint64_t lvm_pvseg_get_start(pvseg_t *pvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pvseg_set_start(pvseg_t *pvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+/**
+ * lvm_pvseg_{get|set}_size
+ * size - Number of extents in segment.
+ */
+const uint64_t lvm_pvseg_get_size(pvseg_t *pvseg)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
+
+int lvm_pvseg_set_size(pvseg_t *pvseg, const uint64_t value)
+{
+    /* FIXME: implement function body */
+    return -1;
+}
diff --git a/liblvm/lvm_object_prop.h b/liblvm/lvm_object_prop.h
new file mode 100644
index 0000000..9ef3337
--- /dev/null
+++ b/liblvm/lvm_object_prop.h
@@ -0,0 +1,494 @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _LVM_OBJECT_PROP_H
+#define _LVM_OBJECT_PROP_H
+
+/**
+ * lvm_lv_{get|set}_uuid
+ * uuid - Unique identifier.
+ */
+const char *lvm_lv_get_uuid(lv_t *lv);
+int lvm_lv_set_uuid(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_name
+ * name - Name.  LVs created for internal use are enclosed in brackets.
+ */
+const char *lvm_lv_get_name(lv_t *lv);
+int lvm_lv_set_name(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_attr
+ * attr - Various attributes - see man page.
+ */
+const char *lvm_lv_get_attr(lv_t *lv);
+int lvm_lv_set_attr(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_major
+ * major - Persistent major number or -1 if not persistent.
+ */
+const uint64_t lvm_lv_get_major(lv_t *lv);
+int lvm_lv_set_major(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_minor
+ * minor - Persistent minor number or -1 if not persistent.
+ */
+const uint64_t lvm_lv_get_minor(lv_t *lv);
+int lvm_lv_set_minor(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_read_ahead
+ * read_ahead - Read ahead setting in current units.
+ */
+const uint64_t lvm_lv_get_read_ahead(lv_t *lv);
+int lvm_lv_set_read_ahead(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_kernel_major
+ * kernel_major - Currently assigned major number or -1 if LV is not active.
+ */
+const char *lvm_lv_get_kernel_major(lv_t *lv);
+int lvm_lv_set_kernel_major(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_kernel_minor
+ * kernel_minor - Currently assigned minor number or -1 if LV is not active.
+ */
+const char *lvm_lv_get_kernel_minor(lv_t *lv);
+int lvm_lv_set_kernel_minor(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_kernel_read_ahead
+ * kernel_read_ahead - Currently-in-use read ahead setting in current units.
+ */
+const uint64_t lvm_lv_get_kernel_read_ahead(lv_t *lv);
+int lvm_lv_set_kernel_read_ahead(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_size
+ * size - Size of LV in current units.
+ */
+const uint64_t lvm_lv_get_size(lv_t *lv);
+int lvm_lv_set_size(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_seg_count
+ * seg_count - Number of segments in LV.
+ */
+const uint64_t lvm_lv_get_seg_count(lv_t *lv);
+int lvm_lv_set_seg_count(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_origin
+ * origin - For snapshots, the origin device of this LV.
+ */
+const char *lvm_lv_get_origin(lv_t *lv);
+int lvm_lv_set_origin(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_origin_size
+ * origin_size - For snapshots, the size of the origin device of this LV.
+ */
+const uint64_t lvm_lv_get_origin_size(lv_t *lv);
+int lvm_lv_set_origin_size(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_snap_percent
+ * snap_percent - For snapshots, the percentage full if LV is active.
+ */
+const uint64_t lvm_lv_get_snap_percent(lv_t *lv);
+int lvm_lv_set_snap_percent(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_copy_percent
+ * copy_percent - For mirrors and pvmove, current percentage in-sync.
+ */
+const uint64_t lvm_lv_get_copy_percent(lv_t *lv);
+int lvm_lv_set_copy_percent(lv_t *lv, const uint64_t value);
+
+/**
+ * lvm_lv_{get|set}_move_pv
+ * move_pv - For pvmove, Source PV of temporary LV created by pvmove.
+ */
+const char *lvm_lv_get_move_pv(lv_t *lv);
+int lvm_lv_set_move_pv(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_convert_lv
+ * convert_lv - For lvconvert, Name of temporary LV created by lvconvert.
+ */
+const char *lvm_lv_get_convert_lv(lv_t *lv);
+int lvm_lv_set_convert_lv(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_lv_get_tags(lv_t *lv);
+int lvm_lv_set_tags(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_mirror_log
+ * mirror_log - For mirrors, the LV holding the synchronisation log.
+ */
+const char *lvm_lv_get_mirror_log(lv_t *lv);
+int lvm_lv_set_mirror_log(lv_t *lv, const char *value);
+
+/**
+ * lvm_lv_{get|set}_modules
+ * modules - Kernel device-mapper modules required for this LV.
+ */
+const char *lvm_lv_get_modules(lv_t *lv);
+int lvm_lv_set_modules(lv_t *lv, const char *value);
+
+/**
+ * lvm_pv_{get|set}_fmt
+ * fmt - Type of metadata.
+ */
+const char *lvm_pv_get_fmt(pv_t *pv);
+int lvm_pv_set_fmt(pv_t *pv, const char *value);
+
+/**
+ * lvm_pv_{get|set}_uuid
+ * uuid - Unique identifier.
+ */
+const char *lvm_pv_get_uuid(pv_t *pv);
+int lvm_pv_set_uuid(pv_t *pv, const char *value);
+
+/**
+ * lvm_pv_{get|set}_dev_size
+ * dev_size - Size of underlying device in current units.
+ */
+const uint64_t lvm_pv_get_dev_size(pv_t *pv);
+int lvm_pv_set_dev_size(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_name
+ * name - Name.
+ */
+const char *lvm_pv_get_name(pv_t *pv);
+int lvm_pv_set_name(pv_t *pv, const char *value);
+
+/**
+ * lvm_pv_{get|set}_mda_free
+ * mda_free - Free metadata area space on this device in current units.
+ */
+const uint64_t lvm_pv_get_mda_free(pv_t *pv);
+int lvm_pv_set_mda_free(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_mda_size
+ * mda_size - Size of smallest metadata area on this device in current units.
+ */
+const uint64_t lvm_pv_get_mda_size(pv_t *pv);
+int lvm_pv_set_mda_size(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_pe_start
+ * pe_start - Offset to the start of data on the underlying device.
+ */
+const uint64_t lvm_pv_get_pe_start(pv_t *pv);
+int lvm_pv_set_pe_start(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_size
+ * size - Size of PV in current units.
+ */
+const uint64_t lvm_pv_get_size(pv_t *pv);
+int lvm_pv_set_size(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_free
+ * free - Total amount of unallocated space in current units.
+ */
+const uint64_t lvm_pv_get_free(pv_t *pv);
+int lvm_pv_set_free(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_used
+ * used - Total amount of allocated space in current units.
+ */
+const uint64_t lvm_pv_get_used(pv_t *pv);
+int lvm_pv_set_used(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_attr
+ * attr - Various attributes - see man page.
+ */
+const char *lvm_pv_get_attr(pv_t *pv);
+int lvm_pv_set_attr(pv_t *pv, const char *value);
+
+/**
+ * lvm_pv_{get|set}_pe_count
+ * pe_count - Total number of Physical Extents.
+ */
+const uint64_t lvm_pv_get_pe_count(pv_t *pv);
+int lvm_pv_set_pe_count(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_pe_alloc_count
+ * pe_alloc_count - Total number of allocated Physical Extents.
+ */
+const uint64_t lvm_pv_get_pe_alloc_count(pv_t *pv);
+int lvm_pv_set_pe_alloc_count(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_pv_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_pv_get_tags(pv_t *pv);
+int lvm_pv_set_tags(pv_t *pv, const char *value);
+
+/**
+ * lvm_pv_{get|set}_mda_count
+ * mda_count - Number of metadata areas on this device.
+ */
+const uint64_t lvm_pv_get_mda_count(pv_t *pv);
+int lvm_pv_set_mda_count(pv_t *pv, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_fmt
+ * fmt - Type of metadata.
+ */
+const char *lvm_vg_get_fmt(vg_t *vg);
+int lvm_vg_set_fmt(vg_t *vg, const char *value);
+
+/**
+ * lvm_vg_{get|set}_uuid
+ * uuid - Unique identifier.
+ */
+const char *lvm_vg_get_uuid(vg_t *vg);
+int lvm_vg_set_uuid(vg_t *vg, const char *value);
+
+/**
+ * lvm_vg_{get|set}_name
+ * name - Name.
+ */
+const char *lvm_vg_get_name(vg_t *vg);
+int lvm_vg_set_name(vg_t *vg, const char *value);
+
+/**
+ * lvm_vg_{get|set}_attr
+ * attr - Various attributes - see man page.
+ */
+const char *lvm_vg_get_attr(vg_t *vg);
+int lvm_vg_set_attr(vg_t *vg, const char *value);
+
+/**
+ * lvm_vg_{get|set}_size
+ * size - Total size of VG in current units.
+ */
+const uint64_t lvm_vg_get_size(vg_t *vg);
+int lvm_vg_set_size(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_free
+ * free - Total amount of free space in current units.
+ */
+const uint64_t lvm_vg_get_free(vg_t *vg);
+int lvm_vg_set_free(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_sysid
+ * sysid - System ID indicating when and where it was created.
+ */
+const char *lvm_vg_get_sysid(vg_t *vg);
+int lvm_vg_set_sysid(vg_t *vg, const char *value);
+
+/**
+ * lvm_vg_{get|set}_extent_size
+ * extent_size - Size of Physical Extents in current units.
+ */
+const uint64_t lvm_vg_get_extent_size(vg_t *vg);
+int lvm_vg_set_extent_size(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_extent_count
+ * extent_count - Total number of Physical Extents.
+ */
+const uint64_t lvm_vg_get_extent_count(vg_t *vg);
+int lvm_vg_set_extent_count(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_free_count
+ * free_count - Total number of unallocated Physical Extents.
+ */
+const uint64_t lvm_vg_get_free_count(vg_t *vg);
+int lvm_vg_set_free_count(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_max_lv
+ * max_lv - Maximum number of LVs allowed in VG or 0 if unlimited.
+ */
+const uint64_t lvm_vg_get_max_lv(vg_t *vg);
+int lvm_vg_set_max_lv(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_max_pv
+ * max_pv - Maximum number of PVs allowed in VG or 0 if unlimited.
+ */
+const uint64_t lvm_vg_get_max_pv(vg_t *vg);
+int lvm_vg_set_max_pv(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_pv_count
+ * pv_count - Number of PVs.
+ */
+const uint64_t lvm_vg_get_pv_count(vg_t *vg);
+int lvm_vg_set_pv_count(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_lv_count
+ * lv_count - Number of LVs.
+ */
+const uint64_t lvm_vg_get_lv_count(vg_t *vg);
+int lvm_vg_set_lv_count(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_snap_count
+ * snap_count - Number of snapshots.
+ */
+const uint64_t lvm_vg_get_snap_count(vg_t *vg);
+int lvm_vg_set_snap_count(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_seqno
+ * seqno - Revision number of internal metadata.  Incremented whenever it changes.
+ */
+const uint64_t lvm_vg_get_seqno(vg_t *vg);
+int lvm_vg_set_seqno(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_vg_get_tags(vg_t *vg);
+int lvm_vg_set_tags(vg_t *vg, const char *value);
+
+/**
+ * lvm_vg_{get|set}_mda_count
+ * mda_count - Number of metadata areas in use by this VG.
+ */
+const uint64_t lvm_vg_get_mda_count(vg_t *vg);
+int lvm_vg_set_mda_count(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_mda_free
+ * mda_free - Free metadata area space for this VG in current units.
+ */
+const uint64_t lvm_vg_get_mda_free(vg_t *vg);
+int lvm_vg_set_mda_free(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_vg_{get|set}_mda_size
+ * mda_size - Size of smallest metadata area for this VG in current units.
+ */
+const uint64_t lvm_vg_get_mda_size(vg_t *vg);
+int lvm_vg_set_mda_size(vg_t *vg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_ype
+ * ype - Type of LV segment.
+ */
+const char *lvm_lvseg_get_ype(lvseg_t *lvseg);
+int lvm_lvseg_set_ype(lvseg_t *lvseg, const char *value);
+
+/**
+ * lvm_lvseg_{get|set}_stripes
+ * stripes - Number of stripes or mirror legs.
+ */
+const uint64_t lvm_lvseg_get_stripes(lvseg_t *lvseg);
+int lvm_lvseg_set_stripes(lvseg_t *lvseg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_stripe_size
+ * stripe_size - For stripes, amount of data placed on one device before switching to the next.
+ */
+const uint64_t lvm_lvseg_get_stripe_size(lvseg_t *lvseg);
+int lvm_lvseg_set_stripe_size(lvseg_t *lvseg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_region_size
+ * region_size - For mirrors, the unit of data copied when synchronising devices.
+ */
+const uint64_t lvm_lvseg_get_region_size(lvseg_t *lvseg);
+int lvm_lvseg_set_region_size(lvseg_t *lvseg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_chunk_size
+ * chunk_size - For snapshots, the unit of data used when tracking changes.
+ */
+const uint64_t lvm_lvseg_get_chunk_size(lvseg_t *lvseg);
+int lvm_lvseg_set_chunk_size(lvseg_t *lvseg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_start
+ * start - Offset within the LV to the start of the segment in current units.
+ */
+const uint64_t lvm_lvseg_get_start(lvseg_t *lvseg);
+int lvm_lvseg_set_start(lvseg_t *lvseg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_start_pe
+ * start_pe - Offset within the LV to the start of the segment in physical extents.
+ */
+const uint64_t lvm_lvseg_get_start_pe(lvseg_t *lvseg);
+int lvm_lvseg_set_start_pe(lvseg_t *lvseg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_size
+ * size - Size of segment in current units.
+ */
+const uint64_t lvm_lvseg_get_size(lvseg_t *lvseg);
+int lvm_lvseg_set_size(lvseg_t *lvseg, const uint64_t value);
+
+/**
+ * lvm_lvseg_{get|set}_tags
+ * tags - Tags, if any.
+ */
+const char *lvm_lvseg_get_tags(lvseg_t *lvseg);
+int lvm_lvseg_set_tags(lvseg_t *lvseg, const char *value);
+
+/**
+ * lvm_lvseg_{get|set}_pe_ranges
+ * pe_ranges - Ranges of Physical Extents of underlying devices in command line format.
+ */
+const char *lvm_lvseg_get_pe_ranges(lvseg_t *lvseg);
+int lvm_lvseg_set_pe_ranges(lvseg_t *lvseg, const char *value);
+
+/**
+ * lvm_lvseg_{get|set}_devices
+ * devices - Underlying devices used with starting extent numbers.
+ */
+const char *lvm_lvseg_get_devices(lvseg_t *lvseg);
+int lvm_lvseg_set_devices(lvseg_t *lvseg, const char *value);
+
+/**
+ * lvm_pvseg_{get|set}_start
+ * start - Physical Extent number of start of segment.
+ */
+const uint64_t lvm_pvseg_get_start(pvseg_t *pvseg);
+int lvm_pvseg_set_start(pvseg_t *pvseg, const uint64_t value);
+
+/**
+ * lvm_pvseg_{get|set}_size
+ * size - Number of extents in segment.
+ */
+const uint64_t lvm_pvseg_get_size(pvseg_t *pvseg);
+int lvm_pvseg_set_size(pvseg_t *pvseg, const uint64_t value);
+
+#endif
-- 
1.6.0.6



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

* [PATCH 4/8] Implement lvm_{vg|lv}_get_{name|uuid}
  2009-04-29 19:55     ` [PATCH 3/8] Add generated files, lvm_object_prop.[ch], to liblvm build Dave Wysochanski
@ 2009-04-29 19:55       ` Dave Wysochanski
  2009-04-29 19:55         ` [PATCH 5/8] Add list structure definitions for liblvm objects Dave Wysochanski
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

- use vg->vgmem pool to dup names and uuids
- add exports for lvm_{vg|lv}_get_{name|uuid}.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/.exported_symbols |    6 +++++-
 liblvm/lvm_object_prop.c |   20 ++++++++++++--------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols
index 1b65e10..f00bb19 100644
--- a/liblvm/.exported_symbols
+++ b/liblvm/.exported_symbols
@@ -1,3 +1,7 @@
 lvm_create
 lvm_destroy
-lvm_reload_config
\ No newline at end of file
+lvm_reload_config
+lvm_lv_get_name
+lvm_lv_get_uuid
+lvm_vg_get_name
+lvm_vg_get_uuid
diff --git a/liblvm/lvm_object_prop.c b/liblvm/lvm_object_prop.c
index 2b02457..768f2bd 100644
--- a/liblvm/lvm_object_prop.c
+++ b/liblvm/lvm_object_prop.c
@@ -12,6 +12,8 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "lvm.h"
+#include "metadata-exported.h"
+#include "lvm-string.h"
 
 /**
  * lvm_lv_{get|set}_uuid
@@ -19,8 +21,9 @@
  */
 const char *lvm_lv_get_uuid(lv_t *lv)
 {
-    /* FIXME: implement function body */
-    return (const char *)0;
+    return (const char *)dm_pool_strndup(lv->vg->vgmem,
+					(const char *)lv->lvid.id[1].uuid,
+					sizeof(lv->lvid.id[1].uuid));
 }
 int lvm_lv_set_uuid(lv_t *lv, const char *value)
 {
@@ -33,8 +36,8 @@ int lvm_lv_set_uuid(lv_t *lv, const char *value)
  */
 const char *lvm_lv_get_name(lv_t *lv)
 {
-    /* FIXME: implement function body */
-    return (const char *)0;
+    return (const char *)dm_pool_strndup(lv->vg->vgmem, lv->name,
+					 NAME_LEN);
 }
 int lvm_lv_set_name(lv_t *lv, const char *value)
 {
@@ -542,8 +545,9 @@ int lvm_vg_set_fmt(vg_t *vg, const char *value)
  */
 const char *lvm_vg_get_uuid(vg_t *vg)
 {
-    /* FIXME: implement function body */
-    return (const char *)0;
+    return (const char *)dm_pool_strndup(vg->vgmem,
+					(const char *)vg->id.uuid,
+					sizeof(vg->id.uuid));
 }
 int lvm_vg_set_uuid(vg_t *vg, const char *value)
 {
@@ -556,8 +560,8 @@ int lvm_vg_set_uuid(vg_t *vg, const char *value)
  */
 const char *lvm_vg_get_name(vg_t *vg)
 {
-    /* FIXME: implement function body */
-    return (const char *)0;
+    return (const char *)dm_pool_strndup(vg->vgmem, vg->name,
+					 NAME_LEN);
 }
 int lvm_vg_set_name(vg_t *vg, const char *value)
 {
-- 
1.6.0.6



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

* [PATCH 5/8] Add list structure definitions for liblvm objects.
  2009-04-29 19:55       ` [PATCH 4/8] Implement lvm_{vg|lv}_get_{name|uuid} Dave Wysochanski
@ 2009-04-29 19:55         ` Dave Wysochanski
  2009-04-29 19:55           ` [PATCH 6/8] Add lvm_lvs_in_vg() - returns a list of lv handles for a given vg Dave Wysochanski
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

- pv_t, vg_t, lv_t, lvseg_t, pvseg_t
- include libdevmapper.h: needed for struct dm_list

These list structures will be needed in later APIs to return a list of
handles to one object, given another object.  For example, lvm_lvs_in_vg()
will return a list of LV handles (lv_t's) given a VG handle (vg_t).  We
need a structure to do this so we define the LV structure, as well as the
other structures at this point.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/lvm.h |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/liblvm/lvm.h b/liblvm/lvm.h
index 55dcb68..b345b36 100644
--- a/liblvm/lvm.h
+++ b/liblvm/lvm.h
@@ -15,6 +15,7 @@
 #define _LIB_LVM_H
 
 #include "lvm-version.h"
+#include "libdevmapper.h"
 
 #include <stdint.h>
 
@@ -32,6 +33,32 @@ typedef struct logical_volume lv_t;
 typedef struct pv_segment pvseg_t;
 typedef struct lv_segment lvseg_t;
 
+typedef struct lvm_lvseg_list {
+	struct dm_list list;
+	lvseg_t *lvseg;
+} lvseg_list_t;
+
+typedef struct lvm_pvseg_list {
+	struct dm_list list;
+	pvseg_t *pvseg;
+} pvseg_list_t;
+
+typedef struct lvm_vg_list {
+	struct dm_list list;
+	vg_t *vg;
+} vg_list_t;
+
+typedef struct lvm_pv_list {
+	struct dm_list list;
+	pv_t *pv;
+} pv_list_t;
+
+typedef struct lvm_lv_list {
+	struct dm_list list;
+	lv_t *lv;
+} lv_list_t;
+
+
 struct lvm; /* internal data */
 
 /**
-- 
1.6.0.6



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

* [PATCH 6/8] Add lvm_lvs_in_vg() - returns a list of lv handles for a given vg.
  2009-04-29 19:55         ` [PATCH 5/8] Add list structure definitions for liblvm objects Dave Wysochanski
@ 2009-04-29 19:55           ` Dave Wysochanski
  2009-04-29 19:55             ` [PATCH 7/8] Add lvm_vg_open() and lvm_vg_close for testing Dave Wysochanski
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

- Use vgmem pool to allocate a list of lvm_lv_list structs
- Allocate a new list each call (list may have changed since last call)
- Add lvm_lvs_in_vg to liblvm's exported symbols

NOTE: we may want to think about memory management beyond using the
vgmem pool.  Another possibility is to have a list handle that is allocated
and freed, then the memory is attached to that.  With a list handle you
would not have to close/release the vg to free the list memory.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/.exported_symbols |    1 +
 liblvm/lvm.h             |    7 +++++++
 liblvm/lvm_base.c        |   26 ++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols
index f00bb19..d05be6f 100644
--- a/liblvm/.exported_symbols
+++ b/liblvm/.exported_symbols
@@ -5,3 +5,4 @@ lvm_lv_get_name
 lvm_lv_get_uuid
 lvm_vg_get_name
 lvm_vg_get_uuid
+lvm_lvs_in_vg
diff --git a/liblvm/lvm.h b/liblvm/lvm.h
index b345b36..9574991 100644
--- a/liblvm/lvm.h
+++ b/liblvm/lvm.h
@@ -58,6 +58,13 @@ typedef struct lvm_lv_list {
 	lv_t *lv;
 } lv_list_t;
 
+/**
+ * Return a list of LV handles for a given VG handle.
+ *
+ * \return  A list of lv_list_t structures containing lv handles for this vg.
+ *          If no LVs exist on the given VG, NULL is returned.
+ */
+struct dm_list *lvm_lvs_in_vg(vg_t *vg);
 
 struct lvm; /* internal data */
 
diff --git a/liblvm/lvm_base.c b/liblvm/lvm_base.c
index 213246a..4e235ab 100644
--- a/liblvm/lvm_base.c
+++ b/liblvm/lvm_base.c
@@ -60,3 +60,29 @@ int lvm_reload_config(lvm_t libh)
 	/* FIXME: re-init locking needed here? */
 	return refresh_toolcontext((struct cmd_context *)libh);
 }
+
+struct dm_list *lvm_lvs_in_vg(vg_t *vg)
+{
+	struct dm_list *list;
+	lv_list_t *lvs;
+	struct lv_list *lvl;
+
+	if (dm_list_empty(&vg->lvs))
+		return NULL;
+
+	if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) {
+		log_error("Memory allocation fail for dm_list.\n");
+		return NULL;
+	}
+	dm_list_init(list);
+
+	dm_list_iterate_items(lvl, &vg->lvs) {
+		if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
+			log_error("Memory allocation fail for lvm_lv_list.\n");
+			return NULL;
+		}
+		lvs->lv = lvl->lv;
+		dm_list_add(list, &lvs->list);
+	}
+	return list;
+}
-- 
1.6.0.6



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

* [PATCH 7/8] Add lvm_vg_open() and lvm_vg_close for testing.
  2009-04-29 19:55           ` [PATCH 6/8] Add lvm_lvs_in_vg() - returns a list of lv handles for a given vg Dave Wysochanski
@ 2009-04-29 19:55             ` Dave Wysochanski
  2009-04-29 19:55               ` [PATCH 8/8] Update test/api/test.c for simple tests involving vg/lv name/uuid attributes Dave Wysochanski
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

- lvm_vg_open: very simplistic version of vg_read()
- export lvm_vg_open and lvm_vg_close

NOTE: This patch is mainly to allow testing of the attribute patches.
I view this patch as peripheral to the attribute patches and is mainly
included for testing so please don't get hung up on it.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 liblvm/.exported_symbols |    2 ++
 liblvm/lvm.h             |    4 ++++
 liblvm/lvm_base.c        |   25 +++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols
index d05be6f..3b0ffb8 100644
--- a/liblvm/.exported_symbols
+++ b/liblvm/.exported_symbols
@@ -6,3 +6,5 @@ lvm_lv_get_uuid
 lvm_vg_get_name
 lvm_vg_get_uuid
 lvm_lvs_in_vg
+lvm_vg_open
+lvm_vg_close
diff --git a/liblvm/lvm.h b/liblvm/lvm.h
index 9574991..47a5270 100644
--- a/liblvm/lvm.h
+++ b/liblvm/lvm.h
@@ -18,6 +18,7 @@
 #include "libdevmapper.h"
 
 #include <stdint.h>
+#include <fcntl.h>
 
 /* Internal object structures */
 struct volume_group;
@@ -104,4 +105,7 @@ int lvm_reload_config(lvm_t libh);
 
 #include "lvm_object_prop.h"
 
+vg_t *lvm_vg_open(lvm_t libh, const char *vg_name, const mode_t mode);
+void lvm_vg_close(vg_t *vg);
+
 #endif /* _LIB_LVM_H */
diff --git a/liblvm/lvm_base.c b/liblvm/lvm_base.c
index 4e235ab..a4a3deb 100644
--- a/liblvm/lvm_base.c
+++ b/liblvm/lvm_base.c
@@ -16,6 +16,8 @@
 #include "lvm.h"
 #include "toolcontext.h"
 #include "locking.h"
+#include "metadata-exported.h"
+#include "lvmcache.h"
 
 lvm_t lvm_create(const char *system_dir)
 {
@@ -86,3 +88,26 @@ struct dm_list *lvm_lvs_in_vg(vg_t *vg)
 	}
 	return list;
 }
+
+/*
+ * Open / read a VG.
+ * FIXME: Only read access allowed.
+ */
+vg_t *lvm_vg_open(lvm_t libh, const char *vg_name, mode_t mode)
+{
+	if ((mode & O_ACCMODE) != O_RDONLY) {
+		log_error("Invalid access mode 0x%x for lvm_vg_read()\n",
+			  mode);
+		return NULL;
+	}
+	return vg_lock_and_read((struct cmd_context *)libh,
+				vg_name, NULL, LCK_VG_READ, CLUSTERED, 0);
+}
+
+void lvm_vg_close(vg_t *vg)
+{
+	if (vgname_is_locked(vg->name))
+	    unlock_vg(vg->cmd, vg->name);
+	vg_release(vg);
+}
+
-- 
1.6.0.6



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

* [PATCH 8/8] Update test/api/test.c for simple tests involving vg/lv name/uuid attributes.
  2009-04-29 19:55             ` [PATCH 7/8] Add lvm_vg_open() and lvm_vg_close for testing Dave Wysochanski
@ 2009-04-29 19:55               ` Dave Wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 19:55 UTC (permalink / raw)
  To: lvm-devel

Tests the following APIs:
- lvm_{vg|lv}_get_{name|uuid}()
- lvm_lvs_in_vg()

Example:
./test
lvm> vg_open vg1
Success opening vg vg1
lvm> vgs_open
vg1 (VeMEO8rGOfY44H8MWieFxIf26CKKpJNj): mode = READ
lvm> lvs_in_vg vg1
LVs in VG vg1:
vg1/lv1 (7phxOHwNPWS9wsqjkD22Fmd1vvLImYjm)
lvm> vg_close vg1
lvm> exit
Exiting.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 test/api/test.c |  204 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 196 insertions(+), 8 deletions(-)

diff --git a/test/api/test.c b/test/api/test.c
index b742976..8217301 100644
--- a/test/api/test.c
+++ b/test/api/test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
  * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
@@ -29,7 +29,7 @@ static int lvm_split(char *str, int *argc, char **argv, int max)
 		while (*b && isspace(*b))
 			b++;
 
-		if ((!*b) || (*b == '#'))
+		if ((!*b) || ((*argc == 0)&&(*b == '#')))
 			break;
 
 		e = b;
@@ -48,11 +48,190 @@ static int lvm_split(char *str, int *argc, char **argv, int max)
 	return *argc;
 }
 
+static void _show_help(void)
+{
+	printf("'lvs_in_vg vgname': "
+	       "List the LVs that exist in VG vgname\n");
+	printf("'vgs_open': "
+	       "List the VGs that are currently open\n");
+	printf("'vgs': "
+	       "List all VGs known to the system\n");
+	printf("'vg_open vgname ['r' | 'w']': "
+	       "Issue a lvm_vg_open() API call on VG 'vgname'\n");
+	printf("'vg_close vgname': "
+	       "Issue a lvm_vg_close() API call on VG 'vgname'\n");
+	printf("'quit': exit the program\n");
+}
+
+static struct dm_hash_table *_vgid_hash = NULL;
+static struct dm_hash_table *_vgname_hash = NULL;
+static struct dm_hash_table *_pvname_hash = NULL;
+static struct dm_hash_table *_lvname_hash = NULL;
+
+static void _hash_destroy_single(struct dm_hash_table **htable)
+{
+	if (htable && *htable) {
+		dm_hash_destroy(*htable);
+		*htable = NULL;
+	}
+}
+
+static void _hash_destroy(void)
+{
+	_hash_destroy_single(&_vgname_hash);
+	_hash_destroy_single(&_vgid_hash);
+	_hash_destroy_single(&_pvname_hash);
+	_hash_destroy_single(&_lvname_hash);
+}
+
+static int _hash_create(void)
+{
+	if (!(_vgname_hash = dm_hash_create(128)))
+		return 0;
+	if (!(_pvname_hash = dm_hash_create(128))) {
+		_hash_destroy_single(&_vgname_hash);
+		return 0;
+	}
+	if (!(_lvname_hash = dm_hash_create(128))) {
+		_hash_destroy_single(&_vgname_hash);
+		_hash_destroy_single(&_pvname_hash);
+		return 0;
+	}
+	if (!(_vgid_hash = dm_hash_create(128))) {
+		_hash_destroy_single(&_vgname_hash);
+		_hash_destroy_single(&_pvname_hash);
+		_hash_destroy_single(&_lvname_hash);
+		return 0;
+	}
+	return 1;
+}
+
+static vg_t *_lookup_vg_by_name(char **argv, int argc)
+{
+	vg_t *vg;
+
+	if (argc < 2) {
+		printf ("Please enter vg_name\n");
+		return NULL;
+	}
+	if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
+	    !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
+		printf ("Can't find %s in open VGs - run vg_open first\n",
+			argv[1]);
+		return NULL;
+	}
+	return vg;
+}
+
+static void _vg_open(char **argv, int argc, lvm_t libh)
+{
+	vg_t *vg;
+	struct dm_list *lvs;
+	struct lvm_lv_list *lvl;
+#if 0
+	struct dm_list *pvs;
+	struct lvm_pv_list *pvl;
+#endif
+	mode_t mode;
+
+	if (argc < 2) {
+		printf ("Please enter vg_name\n");
+		return;
+	}
+	if ((vg = dm_hash_lookup(_vgid_hash, argv[1])) ||
+	    (vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
+		printf ("VG already open\n");
+		return;
+	}
+	if ((argc == 3) && (argv[2][0] == 'w')) {
+		mode = O_RDWR;
+	} else
+		mode = O_RDONLY;
+	vg = lvm_vg_open(libh, argv[1], mode);
+	if (!vg || !lvm_vg_get_name(vg)) {
+		printf("Error opening %s\n", argv[1]);
+		return;
+	}
+
+	printf("Success opening vg %s\n", argv[1]);
+	dm_hash_insert(_vgname_hash, lvm_vg_get_name(vg), vg);
+	dm_hash_insert(_vgid_hash, lvm_vg_get_uuid(vg), vg);
+
+	/*
+	 * Add the LVs and PVs into the hashes for lookups
+	 */
+	lvs = lvm_lvs_in_vg(vg);
+	dm_list_iterate_items(lvl, lvs) {
+		/* Concatenate VG name with LV name */
+		dm_hash_insert(_lvname_hash, lvm_lv_get_name(lvl->lv), lvl->lv);
+	}
+#if 0
+	pvs = lvm_pvs_in_vg(vg);
+	dm_list_iterate_items(pvl, pvs) {
+		dm_hash_insert(_pvname_hash, lvm_pv_name(pvl->pv), pvl->pv);
+	}
+#endif
+}
+
+static void _vg_close(char **argv, int argc)
+{
+	vg_t *vg;
+
+	if (argc < 2) {
+		printf ("Please enter vg_name\n");
+		return;
+	}
+	while((vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
+		dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
+		dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
+		lvm_vg_close(vg);
+	}
+	while((vg = dm_hash_lookup(_vgid_hash, argv[1]))) {
+		dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
+		dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
+		lvm_vg_close(vg);
+	}
+}
+
+static void _show_one_vg(vg_t *vg)
+{
+	/* FIXME: uuid is not null terminated */
+	printf("%s (%s): mode = %s\n", lvm_vg_get_name(vg),
+	       lvm_vg_get_uuid(vg), "READ");
+}
+
+static void _list_open_vgs(void)
+{
+	dm_hash_iter(_vgid_hash, (dm_hash_iterate_fn) _show_one_vg);
+}
+
+static void _lvs_in_vg(char **argv, int argc)
+{
+	struct dm_list *lvs;
+	struct lvm_lv_list *lvl;
+	vg_t *vg;
+
+	if (!(vg = _lookup_vg_by_name(argv, argc)))
+		return;
+	lvs = lvm_lvs_in_vg(vg);
+	if (!lvs || dm_list_empty(lvs)) {
+		printf("No LVs in VG %s\n", lvm_vg_get_name(vg));
+		return;
+	}
+	printf("LVs in VG %s:\n", lvm_vg_get_name(vg));
+	dm_list_iterate_items(lvl, lvs) {
+		printf("%s/%s (%s)\n", lvm_vg_get_name(vg),
+		       lvm_lv_get_name(lvl->lv), lvm_lv_get_uuid(lvl->lv));
+	}
+}
+
 static int lvmapi_test_shell(lvm_t libh)
 {
-	int argc, i;
+	int argc;
 	char *input = NULL, *args[MAX_ARGS], **argv;
 
+	_hash_create();
+	argc=0;
 	while (1) {
 		free(input);
 		input = readline("lvm> ");
@@ -86,17 +265,26 @@ static int lvmapi_test_shell(lvm_t libh)
 			printf("Exiting.\n");
 			break;
 		} else if (!strcmp(argv[0], "?") || !strcmp(argv[0], "help")) {
-			printf("No commands defined\n");
-		} else if (!strcmp(argv[0], "scan")) {
-			for (i=1; i < argc; i++)
-				printf("Scan a path!\n");
+			_show_help();
+		} else if (!strcmp(argv[0], "vg_open")) {
+			_vg_open(argv, argc, libh);
+		} else if (!strcmp(argv[0], "vg_close")) {
+			_vg_close(argv, argc);
+		} else if (!strcmp(argv[0], "vgs_open")) {
+			_list_open_vgs();
+		} else if (!strcmp(argv[0], "lvs_in_vg")) {
+			_lvs_in_vg(argv, argc);
+		} else {
+			printf ("Unrecognized command %s\n", argv[0]);
 		}
 	}
 
+	dm_hash_iter(_vgname_hash, (dm_hash_iterate_fn) lvm_vg_close);
+	_hash_destroy();
 	free(input);
 	return 0;
 }
-		      
+
 int main (int argc, char *argv[])
 {
 	lvm_t libh;
-- 
1.6.0.6



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

* [PATCH 0/8]: liblvm object attribute baseline
  2009-04-29 19:55 [PATCH 0/8]: liblvm object attribute baseline Dave Wysochanski
  2009-04-29 19:55 ` [PATCH 1/8] Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg Dave Wysochanski
@ 2009-04-29 20:23 ` Dave Wysochanski
  1 sibling, 0 replies; 10+ messages in thread
From: Dave Wysochanski @ 2009-04-29 20:23 UTC (permalink / raw)
  To: lvm-devel

On Wed, 2009-04-29 at 15:55 -0400, Dave Wysochanski wrote:
> The following 8 patches implement a baseline for liblvm objects and their
> attributes.  The primary focus/goal of these patches are:
> 1. Define / clarify the main liblvm objects and their handles
> 2. Get the object properties for a specific handle
> 
> Together with the handles, the 'get' functions will provide equivalent
> functionality to the reporting commands (pvs, vgs, lvs) while keeping with
> the object model of liblvm.
> 
> 

I also pushed these patches on a dwysocha-liblvm-object-attr-1 branch of
the exp-git repo on git.et.redhat.com:
http://git.et.redhat.com/?p=lvm-exp.git;a=summary
http://tinyurl.com/c7m684






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

end of thread, other threads:[~2009-04-29 20:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-29 19:55 [PATCH 0/8]: liblvm object attribute baseline Dave Wysochanski
2009-04-29 19:55 ` [PATCH 1/8] Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg Dave Wysochanski
2009-04-29 19:55   ` [PATCH 2/8] Add lvm_object_prop.pl to generate liblvm object property function prototype Dave Wysochanski
2009-04-29 19:55     ` [PATCH 3/8] Add generated files, lvm_object_prop.[ch], to liblvm build Dave Wysochanski
2009-04-29 19:55       ` [PATCH 4/8] Implement lvm_{vg|lv}_get_{name|uuid} Dave Wysochanski
2009-04-29 19:55         ` [PATCH 5/8] Add list structure definitions for liblvm objects Dave Wysochanski
2009-04-29 19:55           ` [PATCH 6/8] Add lvm_lvs_in_vg() - returns a list of lv handles for a given vg Dave Wysochanski
2009-04-29 19:55             ` [PATCH 7/8] Add lvm_vg_open() and lvm_vg_close for testing Dave Wysochanski
2009-04-29 19:55               ` [PATCH 8/8] Update test/api/test.c for simple tests involving vg/lv name/uuid attributes Dave Wysochanski
2009-04-29 20:23 ` [PATCH 0/8]: liblvm object attribute baseline Dave Wysochanski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.