public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/liblvm lvm.h
@ 2009-07-28 15:34 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-28 15:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-28 15:33:59

Modified files:
	liblvm         : lvm.h 

Log message:
	Add doxygen mainpage tag to lvm.h

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.40&r2=1.41

--- LVM2/liblvm/lvm.h	2009/07/28 13:17:04	1.40
+++ LVM2/liblvm/lvm.h	2009/07/28 15:33:59	1.41
@@ -30,7 +30,9 @@
 
 /*************************** Design Overview ********************************/
 
-/*
+/**
+ * \mainpage LVM library API
+ *
  * The API is designed around the following basic LVM objects:
  * 1) Physical Volume (PV) 2) Volume Group (VG) 3) Logical Volume (LV).
  *


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

* LVM2/liblvm lvm.h
@ 2009-07-28 12:19 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-28 12:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-28 12:19:58

Modified files:
	liblvm         : lvm.h 

Log message:
	Fix lvm.h formatting.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.37&r2=1.38

--- LVM2/liblvm/lvm.h	2009/07/28 11:03:28	1.37
+++ LVM2/liblvm/lvm.h	2009/07/28 12:19:58	1.38
@@ -136,18 +136,17 @@
  * Once all LVM operations have been completed, use lvm_quit to release
  * the handle and any associated resources.
  *
- * \param   system_dir
- *          Set an alternative LVM system directory. Use NULL to use the
- *          default value. If the environment variable LVM_SYSTEM_DIR is set,
- *          it will override any system_dir setting.
- * \return  A valid LVM handle is returned or NULL if there has been a
- *          memory allocation problem. You have to check if an error occured
- *          with the lvm_error function.
+ * \param system_dir
+ * Set an alternative LVM system directory. Use NULL to use the
+ * default value. If the environment variable LVM_SYSTEM_DIR is set,
+ * it will override any system_dir setting.
+ *
+ * \return
+ * A valid LVM handle is returned or NULL if there has been a
+ * memory allocation problem. You have to check if an error occured
+ * with the lvm_error function.
  */
-// FIXME: Sort out this alignment.  "Set an" directly below "system_dir"
-// looks awful.  Indent differently?  More blank lines?
 lvm_t lvm_init(const char *system_dir);
-// FIXME Find a better name.  lvm_init.
 
 /**
  * Destroy a LVM handle allocated with lvm_init.
@@ -158,7 +157,7 @@
  * cannot be used subsequently.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
+ * Handle obtained from lvm_init.
  */
 void lvm_quit(lvm_t libh);
 
@@ -170,8 +169,10 @@
  * the application.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
- * \return  0 (success) or -1 (failure).
+ * Handle obtained from lvm_init.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_config_reload(lvm_t libh);
 
@@ -184,11 +185,14 @@
  * you should use lvm_config_reload to apply the new settings.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
+ * Handle obtained from lvm_init.
+ *
  * \param   config_string
- *          LVM configuration string to apply.  See the lvm.conf file man page
- *          for the format of the config string.
- * \return  0 (success) or -1 (failure).
+ * LVM configuration string to apply.  See the lvm.conf file man page
+ * for the format of the config string.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_config_override(lvm_t libh, const char *config_string);
 
@@ -204,9 +208,10 @@
  * returns a value.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
+ * Handle obtained from lvm_init.
  *
- * \return  An errno value describing the last LVM error.
+ * \return
+ * An errno value describing the last LVM error.
  */
 int lvm_errno(lvm_t libh);
 
@@ -217,9 +222,10 @@
  * specific error information for a function that is known to have failed.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
+ * Handle obtained from lvm_init.
  *
- * \return  An error string describing the last LVM error.
+ * \return
+ * An error string describing the last LVM error.
  */
 const char *lvm_errmsg(lvm_t libh);
 
@@ -227,7 +233,8 @@
  * Scan all devices on the system for VGs and LVM metadata.
  * FIXME: Elaborate on when to use, side-effects, .cache file, etc
  *
- * \return  0 (success) or -1 (failure).
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_scan(lvm_t libh);
 
@@ -258,11 +265,12 @@
  *      }
  *
  *
- * \return  A list with entries of type struct lvm_str_list, containing the
- *          VG name strings of the Volume Groups known to the system.
- *          NULL is returned if unable to allocate memory.
- *          An empty list (verify with dm_list_empty) is returned if no VGs
- *          exist on the system.
+ * \return
+ * A list with entries of type struct lvm_str_list, containing the
+ * VG name strings of the Volume Groups known to the system.
+ * NULL is returned if unable to allocate memory.
+ * An empty list (verify with dm_list_empty) is returned if no VGs
+ * exist on the system.
  */
 struct dm_list *lvm_list_vg_names(lvm_t libh);
 
@@ -278,13 +286,14 @@
  * begin with a "#" and should be filtered out and not used.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
+ * Handle obtained from lvm_init.
  *
- * \return  A list with entries of type struct lvm_str_list, containing the
- *          VG UUID strings of the Volume Groups known to the system.
- *          NULL is returned if unable to allocate memory.
- *          An empty list (verify with dm_list_empty) is returned if no VGs
- *          exist on the system.
+ * \return
+ * A list with entries of type struct lvm_str_list, containing the
+ * VG UUID strings of the Volume Groups known to the system.
+ * NULL is returned if unable to allocate memory.
+ * An empty list (verify with dm_list_empty) is returned if no VGs
+ * exist on the system.
  */
 struct dm_list *lvm_list_vg_uuids(lvm_t libh);
 
@@ -294,14 +303,18 @@
  * Open a VG for reading or writing.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
+ * Handle obtained from lvm_init.
+ *
  * \param   vgname
- *          Name of the VG to open.
+ * Name of the VG to open.
+ *
  * \param   mode
- *          Open mode - either "r" (read) or "w" (read/write).
- *          Any other character results in an error with EINVAL set.
+ * Open mode - either "r" (read) or "w" (read/write).
+ * Any other character results in an error with EINVAL set.
+ *
  * \param   flags
- *          Open flags - currently ignored.
+ * Open flags - currently ignored.
+ *
  * \return  non-NULL VG handle (success) or NULL (failure).
  */
 vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
@@ -320,10 +333,13 @@
  * release the VG handle.
  *
  * \param   libh
- *          Handle obtained from lvm_init.
+ * Handle obtained from lvm_init.
+ *
  * \param   vg_name
- *          Name of the VG to open.
- * \return  non-NULL vg handle (success) or NULL (failure)
+ * Name of the VG to open.
+ *
+ * \return
+ * non-NULL vg handle (success) or NULL (failure)
  */
 vg_t *lvm_vg_create(lvm_t libh, const char *vg_name);
 
@@ -335,8 +351,10 @@
  * with lvm_vg_close.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  0 (success) or -1 (failure).
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_vg_write(vg_t *vg);
 
@@ -347,8 +365,10 @@
  * lvm_vg_write.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  0 (success) or -1 (failure).
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_vg_remove(vg_t *vg);
 
@@ -359,8 +379,10 @@
  * handle.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  0 (success) or -1 (failure).
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_vg_close(vg_t *vg);
 
@@ -377,10 +399,13 @@
  * before calling lvm_vg_extend.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
  * \param   device
- *          Absolute pathname of device to add to VG.
- * \return  0 (success) or -1 (failure).
+ * Absolute pathname of device to add to VG.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_vg_extend(vg_t *vg, const char *device);
 
@@ -393,12 +418,13 @@
  * lvm_vg_close.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
  *
  * \param   device
- *          Name of device to remove from VG.
+ * Name of device to remove from VG.
  *
- * \return  0 (success) or -1 (failure).
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_vg_reduce(vg_t *vg, const char *device);
 
@@ -411,10 +437,13 @@
  * handle with lvm_vg_close.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
  * \param   new_size
- *          New extent size in bytes.
- * \return  0 (success) or -1 (failure).
+ * New extent size in bytes.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_vg_set_extent_size(vg_t *vg, uint32_t new_size);
 
@@ -425,8 +454,10 @@
  * using dm_free().
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Copy of the uuid string.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Copy of the uuid string.
  */
 char *lvm_vg_get_uuid(const vg_t *vg);
 
@@ -437,8 +468,10 @@
  * using dm_free().
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Copy of the name.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Copy of the name.
  */
 char *lvm_vg_get_name(const vg_t *vg);
 
@@ -446,8 +479,10 @@
  * Get the current size in bytes of a volume group.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Size in bytes.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Size in bytes.
  */
 uint64_t lvm_vg_get_size(const vg_t *vg);
 
@@ -455,8 +490,10 @@
  * Get the current unallocated space in bytes of a volume group.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Free size in bytes.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Free size in bytes.
  */
 uint64_t lvm_vg_get_free_size(const vg_t *vg);
 
@@ -464,8 +501,10 @@
  * Get the current extent size in bytes of a volume group.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Extent size in bytes.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Extent size in bytes.
  */
 uint64_t lvm_vg_get_extent_size(const vg_t *vg);
 
@@ -473,8 +512,10 @@
  * Get the current number of total extents of a volume group.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Extent count.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Extent count.
  */
 uint64_t lvm_vg_get_extent_count(const vg_t *vg);
 
@@ -482,8 +523,10 @@
  * Get the current number of free extents of a volume group.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Free extent count.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Free extent count.
  */
 uint64_t lvm_vg_get_free_extent_count(const vg_t *vg);
 
@@ -491,8 +534,10 @@
  * Get the current number of physical volumes of a volume group.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  Physical volume count.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Physical volume count.
  */
 uint64_t lvm_vg_get_pv_count(const vg_t *vg);
 
@@ -502,9 +547,11 @@
  * Return a list of LV handles for a given VG handle.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \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.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \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_vg_list_lvs(vg_t *vg);
 
@@ -517,12 +564,16 @@
  * lv_create_single is refactored by segtype.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
  * \param   name
- *          Name of logical volume to create.
+ * Name of logical volume to create.
+ *
  * \param   size
- *          Size of logical volume in extents.
- * \return  LV object
+ * Size of logical volume in extents.
+ *
+ * \return
+ * non-NULL handle to an LV object created, or NULL if creation fails.
  *
  */
 lv_t *lvm_vg_create_lv_linear(vg_t *vg, const char *name, uint64_t size);
@@ -536,8 +587,10 @@
  * lvconvert.
  *
  * \param   lv
- *          Logical volume handle.
- * \return  0 (success) or -1 (failure).
+ * Logical volume handle.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_lv_activate(lv_t *lv);
 
@@ -547,8 +600,10 @@
  * This function is the equivalent of the lvm command "lvchange -an".
  *
  * \param   lv
- *          Logical volume handle.
- * \return  0 (success) or -1 (failure).
+ * Logical volume handle.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_lv_deactivate(lv_t *lv);
 
@@ -563,8 +618,10 @@
  * lvm_vg_write.
  *
  * \param   lv
- *          Logical volume handle.
- * \return  0 (success) or -1 (failure).
+ * Logical volume handle.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_vg_remove_lv(lv_t *lv);
 
@@ -575,8 +632,10 @@
  * using dm_free().
  *
  * \param   lv
- *          Logical volume handle.
- * \return  Copy of the uuid string.
+ * Logical volume handle.
+ *
+ * \return
+ * Copy of the uuid string.
  */
 char *lvm_lv_get_uuid(const lv_t *lv);
 
@@ -587,8 +646,10 @@
  * using dm_free().
  *
  * \param   lv
- *          Logical volume handle.
- * \return  Copy of the name.
+ * Logical volume handle.
+ *
+ * \return
+ * Copy of the name.
  */
 char *lvm_lv_get_name(const lv_t *lv);
 
@@ -596,8 +657,10 @@
  * Get the current size in bytes of a logical volume.
  *
  * \param   lv
- *          Logical volume handle.
- * \return  Size in bytes.
+ * Logical volume handle.
+ *
+ * \return
+ * Size in bytes.
  */
 uint64_t lvm_lv_get_size(const lv_t *lv);
 
@@ -605,8 +668,10 @@
  * Get the current activation state of a logical volume.
  *
  * \param   lv
- *          Logical volume handle.
- * \return  1 if the LV is active in the kernel, 0 if not
+ * Logical volume handle.
+ *
+ * \return
+ * 1 if the LV is active in the kernel, 0 if not
  */
 uint64_t lvm_lv_is_active(const lv_t *lv);
 
@@ -614,8 +679,10 @@
  * Get the current suspended state of a logical volume.
  *
  * \param   lv
- *          Logical volume handle.
- * \return  1 if the LV is suspended in the kernel, 0 if not
+ * Logical volume handle.
+ *
+ * \return
+ * 1 if the LV is suspended in the kernel, 0 if not
  */
 uint64_t lvm_lv_is_suspended(const lv_t *lv);
 
@@ -623,10 +690,13 @@
  * Resize logical volume to new_size bytes.
  *
  * \param   lv
- *          Logical volume handle.
+ * Logical volume handle.
+ *
  * \param   new_size
- *          New size in bytes.
- * \return  0 (success) or -1 (failure).
+ * New size in bytes.
+ *
+ * \return
+ * 0 (success) or -1 (failure).
  *
  */
 int lvm_lv_resize(const lv_t *lv, uint64_t new_size);
@@ -643,9 +713,11 @@
  * Return a list of PV handles for a given VG handle.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
- * \return  A list of pv_list_t structures containing pv handles for this vg.
- *          If no PVs exist on the given VG, NULL is returned.
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * A list of pv_list_t structures containing pv handles for this vg.
+ * If no PVs exist on the given VG, NULL is returned.
  */
 struct dm_list *lvm_vg_list_pvs(vg_t *vg);
 
@@ -656,8 +728,10 @@
  * using dm_free().
  *
  * \param   pv
- *          Physical volume handle.
- * \return  Copy of the uuid string.
+ * Physical volume handle.
+ *
+ * \return
+ * Copy of the uuid string.
  */
 char *lvm_pv_get_uuid(const pv_t *pv);
 
@@ -668,8 +742,10 @@
  * using dm_free().
  *
  * \param   pv
- *          Physical volume handle.
- * \return  Copy of the name.
+ * Physical volume handle.
+ *
+ * \return
+ * Copy of the name.
  */
 char *lvm_pv_get_name(const pv_t *pv);
 
@@ -677,8 +753,10 @@
  * Get the current number of metadata areas in the physical volume.
  *
  * \param   pv
- *          Physical volume handle.
- * \return  metadata area count.
+ * Physical volume handle.
+ *
+ * \return
+ * Number of metadata areas in the PV.
  */
 uint64_t lvm_pv_get_mda_count(const pv_t *pv);
 
@@ -686,11 +764,13 @@
  * Resize physical volume to new_size bytes.
  *
  * \param   pv
- *          Physical volume handle.
+ * Physical volume handle.
+ *
  * \param   new_size
- *          New size in bytes.
- * \return  0 (success) or -1 (failure).
+ * New size in bytes.
  *
+ * \return
+ * 0 (success) or -1 (failure).
  */
 int lvm_pv_resize(const pv_t *pv, uint64_t new_size);
 


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

* LVM2/liblvm lvm.h
@ 2009-07-28  0:36 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-28  0:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-28 00:36:59

Modified files:
	liblvm         : lvm.h 

Log message:
	Update lvm.h to address feeback.
	
	This addresses a a large amount of Alasdair's review.  Subsequent patches
	will address remaining issues.
	Addressed:
	// FIXME Mention that's also required on error.
	// FIXME Be consistent in terminology.  It's called "system_dir" then last sentence says "system directory setting".  Is it referring to "system_dir" there or something else?
	// FIXME Mention it frees all resources and cannot be used subsequently?
	// FIXME What does "any system configuration" mean?
	// FIXME Expand on that explanation a bit, now that we know what the other fns look like.
	// FIXME Not sure about that - it needs to scan sometimes.  "will not" or "might not" ?
	// FIXME: That's a FIXME in the code!!!
	// FIXME What does "copied" mean in this context???
	// FIXME Say what struct the returned struct dm_list is a list of...
	// FIXME "This API" ?  This function creates an object in memory?
	// FIXME This function commits the Volume Group object referenced by the VG handle to disk?
	// FIXME Where is "Name" defined?  Absolute pathname?
	
	Outstanding:
	// FIXME Version function first?  No structs or handles needed for that.
	// FIXME Sort out this alignment.  "Set an" directly below "system_dir" looks awful.  Indent differently?  More blank lines?
	// FIXME Check how doxygen processes this.  E.g. "return: LVM handle.  You must use lvm_error() to check there were no errors and confirm that the handle is valid for passing to other functions."
	// FIXME Find a better name.  lvm_init.
	// FIXME Consider renaming according to the new name for lvm_create.
	// FIXME Please can we use dm_malloc throughout?

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.33&r2=1.34

--- LVM2/liblvm/lvm.h	2009/07/27 21:13:54	1.33
+++ LVM2/liblvm/lvm.h	2009/07/28 00:36:58	1.34
@@ -31,7 +31,14 @@
 
 /******************************** structures ********************************/
 
-/* Internal object structures - do not use directly */
+/**
+ * Opaque structures - do not use directly.  Internal structures may change
+ * without notice between releases, whereas this API will be changed much less
+ * frequently.  Backwards compatibility will normally be preserved in future
+ * releases.  On any occasion when the developers do decide to break backwards
+ * compatibility in any significant way, the LVM_LIBAPI number (included in
+ * the library's soname) will be incremented.
+ */
 struct lvm;
 struct physical_volume;
 struct volume_group;
@@ -40,23 +47,15 @@
 /**
  * lvm handle.
  *
- * This is the base handle that is needed to open and create objects. Also
- * error handling is bound to this handle.
+ * This is the base handle that is needed to open and create objects such as
+ * volume groups and logical volumes.  In addition, this handle provides a
+ * context for error handling information, saving any error number (see
+ * lvm_errno) and error message (see lvm_errmsg) that any function may
+ * generate.
  */
 typedef struct lvm *lvm_t;
 
 /**
- * Physical volume object.
- *
- * This object can be either a read-only object or a read-write object and
- * depends on the mode of the volume group.  This object can not be
- * written to disk independently, and changes will be written to disk
- * when the volume group gets committed to disk. The open mode is the
- * same as the volume group object it was created from.
- */
-typedef struct physical_volume pv_t;
-
-/**
  * Volume group object.
  *
  * This object can be either a read-only object or a read-write object
@@ -69,51 +68,47 @@
 /**
  * Logical Volume object.
  *
- * This object can be either a read-only object or a read-write object
- * depending on the mode of the volume group. This object can not be
- * written to disk independently, it is bound to a volume group and changes
- * will be written to disk when the volume group gets committed to disk. The
- * open mode is the same as the volume group object is was created from.
+ * This object is bound to a volume group and has the same mode of the volume
+ * group.  Changes will be written to disk when the volume group gets
+ * committed to disk.
  */
 typedef struct logical_volume lv_t;
 
 /**
- * Physical volume object list.
+ * Physical volume object.
  *
- * The properties of physical volume objects also applies to the list of
- * physical volumes.
+ * This object is bound to a volume group and has the same mode of the volume
+ * group.  Changes will be written to disk when the volume group gets
+ * committed to disk.
  */
-typedef struct lvm_pv_list {
-	struct dm_list list;
-	pv_t *pv;
-} pv_list_t;
+typedef struct physical_volume pv_t;
 
 /**
- * Volume group object list.
+ * Logical Volume object list.
  *
- * The properties of volume group objects also applies to the list of
- * volume groups.
+ * Lists of these structures are returned by lvm_vg_list_pvs.
  */
-typedef struct lvm_vg_list {
+typedef struct lvm_lv_list {
 	struct dm_list list;
-	vg_t *vg;
-} vg_list_t;
+	lv_t *lv;
+} lv_list_t;
 
 /**
- * Logical Volume object list.
+ * Physical volume object list.
  *
- * The properties of logical volume objects also applies to the list of
- * logical volumes.
+ * Lists of these structures are returned by lvm_vg_list_pvs.
  */
-typedef struct lvm_lv_list {
+typedef struct lvm_pv_list {
 	struct dm_list list;
-	lv_t *lv;
-} lv_list_t;
+	pv_t *pv;
+} pv_list_t;
 
 /**
  * String list.
  *
  * This string list contains read-only strings.
+ * Lists of these structures are returned by lvm_list_vg_names and
+ * lvm_list_vg_uuids.
  */
 struct lvm_str_list {
 	struct dm_list list;
@@ -121,7 +116,6 @@
 };
 
 /*************************** generic lvm handling ***************************/
-
 /**
  * Create a LVM handle.
  *
@@ -131,16 +125,24 @@
  * \param   system_dir
  *          Set an alternative LVM system directory. Use NULL to use the
  *          default value. If the environment variable LVM_SYSTEM_DIR is set,
- *          it will override any LVM system directory setting.
+ *          it will override any system_dir setting.
  * \return  A valid LVM handle is returned or NULL if there has been a
  *          memory allocation problem. You have to check if an error occured
  *          with the lvm_error function.
  */
+// FIXME: Sort out this alignment.  "Set an" directly below "system_dir"
+// looks awful.  Indent differently?  More blank lines?
 lvm_t lvm_create(const char *system_dir);
+// FIXME Find a better name.  lvm_init.
 
 /**
  * Destroy a LVM handle allocated with lvm_create.
  *
+ * This function should be used after all LVM operations are complete or after
+ * an unrecoverable error.  Destroying the LVM handle frees the memory and
+ * other resources associated with the handle.  Once destroyed, the handle
+ * cannot be used subsequently.
+ *
  * \param   libh
  *          Handle obtained from lvm_create.
  */
@@ -149,8 +151,9 @@
 /**
  * Reload the original configuration from the system directory.
  *
- * This function should be used when any system configuration changes,
- * and the change is needed by the application.
+ * This function should be used when any LVM configuration changes in the LVM
+ * system_dir or by another lvm_config* function, and the change is needed by
+ * the application.
  *
  * \param   libh
  *          Handle obtained from lvm_create.
@@ -161,13 +164,14 @@
 /**
  * Override the LVM configuration with a configuration string.
  *
- * This API is equivalent to the --config option on lvm commands.
+ * This function is equivalent to the --config option on lvm commands.
  * FIXME: submit a patch to document the --config option
  * Once this API has been used to over-ride the configuration,
  * you should use lvm_config_reload to apply the new settings.
+ *
  * \param   libh
  *          Handle obtained from lvm_create.
- * \param   config_settings
+ * \param   config_string
  *          LVM configuration string to apply.  See the lvm.conf file man page
  *          for the format of the config string.
  * \return  0 (success) or -1 (failure).
@@ -177,9 +181,13 @@
 /**
  * Return stored error no describing last LVM API error.
  *
- * Users of liblvm should use lvm_errno to determine success or failure
- * of the last call, unless the API indicates another method of determining
- * success or failure.
+ * Users of liblvm should use lvm_errno to determine the details of a any
+ * failure of the last call.  A basic success or fail is always returned by
+ * every function, either by returning a 0 or -1, or a non-NULL / NULL.
+ * If a function has failed, lvm_errno may be used to get a more specific
+ * error code describing the failure.  In this way, lvm_errno may be used
+ * after every function call, even after a 'get' function call that simply
+ * returns a value.
  *
  * \param   libh
  *          Handle obtained from lvm_create.
@@ -191,6 +199,9 @@
 /**
  * Return stored error message describing last LVM error.
  *
+ * This function may be used in conjunction with lvm_errno to obtain more
+ * specific error information for a function that is known to have failed.
+ *
  * \param   libh
  *          Handle obtained from lvm_create.
  *
@@ -214,8 +225,8 @@
  * The memory allocated for the list is tied to the lvm_t handle and will be
  * released when lvm_destroy is called.
  *
- * NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
- * To scan the system, use lvm_scan.
+ * NOTE: This function normally does not scan devices in the system for LVM
+ * metadata.  To scan the system, use lvm_scan.
  * NOTE: This function currently returns hidden VG names.  These names always
  * begin with a "#" and should be filtered out and not used.
  *
@@ -233,7 +244,8 @@
  *      }
  *
  *
- * \return  A list of struct lvm_str_list
+ * \return  A list with entries of type struct lvm_str_list, containing the
+ *          VG name strings of the Volume Groups known to the system.
  *          NULL is returned if unable to allocate memory.
  *          An empty list (verify with dm_list_empty) is returned if no VGs
  *          exist on the system.
@@ -246,15 +258,16 @@
  * The memory allocated for the list is tied to the lvm_t handle and will be
  * released when lvm_destroy is called.
  *
- * NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
- * To scan the system, use lvm_scan.
+ * NOTE: This function normally does not scan devices in the system for LVM
+ * metadata.  To scan the system, use lvm_scan.
  * NOTE: This function currently returns hidden VG names.  These names always
  * begin with a "#" and should be filtered out and not used.
  *
  * \param   libh
  *          Handle obtained from lvm_create.
  *
- * \return  List of copied uuid strings.
+ * \return  A list with entries of type struct lvm_str_list, containing the
+ *          VG UUID strings of the Volume Groups known to the system.
  *          NULL is returned if unable to allocate memory.
  *          An empty list (verify with dm_list_empty) is returned if no VGs
  *          exist on the system.
@@ -283,7 +296,7 @@
 /**
  * Create a VG with default parameters.
  *
- * This API requires calling lvm_vg_write to commit the change to disk.
+ * This function creates a Volume Group object in memory.
  * Upon success, other APIs may be used to set non-default parameters.
  * For example, to set a non-default extent size, use lvm_vg_set_extent_size.
  * Next, to add physical storage devices to the volume group, use
@@ -303,9 +316,9 @@
  /**
  * Write a VG to disk.
  *
- * This API commits the VG to disk.
- * Upon failure, retry the operation and/or release the VG handle with
- * lvm_vg_close.
+ * This function commits the Volume Group object referenced by the VG handle
+ * to disk. Upon failure, retry the operation and/or release the VG handle
+ * with lvm_vg_close.
  *
  * \param   vg
  *          VG handle obtained from lvm_vg_create or lvm_vg_open.
@@ -316,7 +329,7 @@
 /**
  * Remove a VG from the system.
  *
- * This API commits the change to disk and does not require calling
+ * This function commits the change to disk and does not require calling
  * lvm_vg_write.
  *
  * \param   vg
@@ -328,7 +341,8 @@
 /**
  * Close a VG opened with lvm_vg_create or lvm_vg_open.
  *
- * This API releases a VG handle and any resources associated with the handle.
+ * This function releases a VG handle and any resources associated with the
+ * handle.
  *
  * \param   vg
  *          VG handle obtained from lvm_vg_create or lvm_vg_open.
@@ -339,7 +353,7 @@
 /**
  * Extend a VG by adding a device.
  *
- * This API requires calling lvm_vg_write to commit the change to disk.
+ * This function requires calling lvm_vg_write to commit the change to disk.
  * After successfully adding a device, use lvm_vg_write to commit the new VG
  * to disk.  Upon failure, retry the operation or release the VG handle with
  * lvm_vg_close.
@@ -351,7 +365,7 @@
  * \param   vg
  *          VG handle obtained from lvm_vg_create or lvm_vg_open.
  * \param   device
- *          Name of device to add to VG.
+ *          Absolute pathname of device to add to VG.
  * \return  0 (success) or -1 (failure).
  */
 int lvm_vg_extend(vg_t *vg, const char *device);
@@ -359,7 +373,7 @@
 /**
  * Reduce a VG by removing an unused device.
  *
- * This API requires calling lvm_vg_write to commit the change to disk.
+ * This function requires calling lvm_vg_write to commit the change to disk.
  * After successfully removing a device, use lvm_vg_write to commit the new VG
  * to disk.  Upon failure, retry the operation or release the VG handle with
  * lvm_vg_close.
@@ -377,7 +391,7 @@
 /**
  * Set the extent size of a VG.
  *
- * This API requires calling lvm_vg_write to commit the change to disk.
+ * This function requires calling lvm_vg_write to commit the change to disk.
  * After successfully setting a new extent size, use lvm_vg_write to commit
  * the new VG to disk.  Upon failure, retry the operation or release the VG
  * handle with lvm_vg_close.
@@ -482,9 +496,9 @@
 
 /**
  * Create a linear logical volume.
- * This API commits the change to disk and does _not_ require calling
+ * This function commits the change to disk and does _not_ require calling
  * lvm_vg_write.
- * FIXME: This API should probably not commit to disk but require calling
+ * FIXME: This function should probably not commit to disk but require calling
  * lvm_vg_write.  However, this appears to be non-trivial change until
  * lv_create_single is refactored by segtype.
  *
@@ -502,9 +516,9 @@
 /**
  * Activate a logical volume.
  *
- * This API is the equivalent of the lvm command "lvchange -ay".
+ * This function is the equivalent of the lvm command "lvchange -ay".
  *
- * NOTE: This API cannot currently handle LVs with an in-progress pvmove or
+ * NOTE: This function cannot currently handle LVs with an in-progress pvmove or
  * lvconvert.
  *
  * \param   lv
@@ -516,7 +530,7 @@
 /**
  * Deactivate a logical volume.
  *
- * This API is the equivalent of the lvm command "lvchange -an".
+ * This function is the equivalent of the lvm command "lvchange -an".
  *
  * \param   lv
  *          Logical volume handle.
@@ -531,7 +545,7 @@
  * lvm_vg_write.
  * Currently only removing linear LVs are possible.
  *
- * FIXME: This API should probably not commit to disk but require calling
+ * FIXME: This function should probably not commit to disk but require calling
  * lvm_vg_write.
  *
  * \param   lv


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

* LVM2/liblvm lvm.h
@ 2009-07-27 21:13 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-27 21:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-27 21:13:54

Modified files:
	liblvm         : lvm.h 

Log message:
	Add warning to lvm.h stating API development in progress.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33

--- LVM2/liblvm/lvm.h	2009/07/27 21:02:17	1.32
+++ LVM2/liblvm/lvm.h	2009/07/27 21:13:54	1.33
@@ -19,6 +19,16 @@
 
 #include <stdint.h>
 
+
+/******************************** WARNING ********************************/
+/*
+ * NOTE: This API is under development and subject to change at any time.
+ *
+ * Please send feedback to lvm-devel@redhat.com
+ */
+/******************************** WARNING ********************************/
+
+
 /******************************** structures ********************************/
 
 /* Internal object structures - do not use directly */


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

* LVM2/liblvm lvm.h
@ 2009-07-27  8:28 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-27  8:28 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-27 08:28:13

Modified files:
	liblvm         : lvm.h 

Log message:
	More liblvm header file cleanups.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.26&r2=1.27

--- LVM2/liblvm/lvm.h	2009/07/26 20:58:11	1.26
+++ LVM2/liblvm/lvm.h	2009/07/27 08:28:13	1.27
@@ -38,11 +38,11 @@
 /**
  * Physical volume object.
  *
- * This object can be either a read-only object or a read-write object
- * depending on the mode it was returned by a function. This object can not be
- * written to disk independently, it is bound to a volume group and changes
- * will be written to disk when the volume group gets committed to disk. The
- * open mode is the same as the volume group object is was created of.
+ * This object can be either a read-only object or a read-write object and
+ * depends on the mode of the volume group.  This object can not be
+ * written to disk independently, and changes will be written to disk
+ * when the volume group gets committed to disk. The open mode is the
+ * same as the volume group object it was created from.
  */
 typedef struct physical_volume pv_t;
 
@@ -60,10 +60,10 @@
  * Logical Volume object.
  *
  * This object can be either a read-only object or a read-write object
- * depending on the mode it was returned by a function. This object can not be
+ * depending on the mode of the volume group. This object can not be
  * written to disk independently, it is bound to a volume group and changes
  * will be written to disk when the volume group gets committed to disk. The
- * open mode is the same as the volume group object is was created of.
+ * open mode is the same as the volume group object is was created from.
  */
 typedef struct logical_volume lv_t;
 
@@ -287,7 +287,7 @@
 int lvm_vg_remove(vg_t *vg);
 
 /**
- * Close a VG opened with lvm_vg_create
+ * Close a VG opened with lvm_vg_create or lvm_vg_open.
  *
  * This API releases a VG handle and any resources associated with the handle.
  *


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

* LVM2/liblvm lvm.h
@ 2009-07-26 16:49 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-26 16:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 16:49:52

Modified files:
	liblvm         : lvm.h 

Log message:
	A few more lvm.h updates that got missed.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.22&r2=1.23

--- LVM2/liblvm/lvm.h	2009/07/26 16:44:05	1.22
+++ LVM2/liblvm/lvm.h	2009/07/26 16:49:52	1.23
@@ -38,11 +38,11 @@
 /**
  * Physical volume object.
  *
- * This object can be either a read-only object or a read-write object and
- * depends on the mode of the volume group.  This object can not be
- * written to disk independently, and changes will be written to disk
- * when the volume group gets committed to disk. The open mode is the
- * same as the volume group object it was created from.
+ * This object can be either a read-only object or a read-write object
+ * depending on the mode it was returned by a function. This object can not be
+ * written to disk independently, it is bound to a volume group and changes
+ * will be written to disk when the volume group gets committed to disk. The
+ * open mode is the same as the volume group object is was created of.
  */
 typedef struct physical_volume pv_t;
 
@@ -326,7 +326,7 @@
  * \param   vg
  *          VG handle obtained from lvm_vg_create or lvm_vg_open.
  * \param   new_size
- *          New extent size to set (in sectors).
+ *          New extent size in bytes.
  * \return  Status code of 1 (success) or 0 (failure).
  */
 int lvm_vg_set_extent_size(vg_t *vg, uint32_t new_size);


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

* LVM2/liblvm lvm.h
@ 2009-07-26 16:35 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-26 16:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 16:35:57

Modified files:
	liblvm         : lvm.h 

Log message:
	Update lvm.h - comments describing function behavior, divide into sections.
	
	Hard to divide into smaller patches because of the moving around and
	commenting, so just put in the new file diffs.  We will review and can
	update as necessary.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21

--- LVM2/liblvm/lvm.h	2009/07/26 16:11:58	1.20
+++ LVM2/liblvm/lvm.h	2009/07/26 16:35:57	1.21
@@ -110,13 +110,6 @@
 	const char *str;
 };
 
-/**
- * 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_vg_list_lvs(vg_t *vg);
 /*************************** generic lvm handling ***************************/
 
 /**
@@ -146,65 +139,105 @@
 /**
  * Reload the original configuration from the system directory.
  *
+ * This function should be used when any system configuration changes,
+ * and the change is needed by the application.
+ *
  * \param   libh
  *          Handle obtained from lvm_create.
  */
 int lvm_reload_config(lvm_t libh);
 
 /**
- * Create a linear logical volume.
- * This API commits the change to disk and does _not_ require calling
- * lvm_vg_write.
- * FIXME: This API should probably not commit to disk but require calling
- * lvm_vg_write.  However, this appears to be non-trivial change until
- * lv_create_single is refactored by segtype.
+ * Return stored error no describing last LVM API error.
  *
- * \param   vg
- *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * Users of liblvm should use lvm_errno to determine success or failure
+ * of the last call, unless the API indicates another method of determining
+ * success or failure.
  *
- * \param   name
- *          Name of logical volume to create.
+ * \param   libh
+ *          Handle obtained from lvm_create.
  *
- * \param   size
- *          Size of logical volume in extents.
+ * \return  An errno value describing the last LVM error.
+ */
+int lvm_errno(lvm_t libh);
+
+/**
+ * Return stored error message describing last LVM error.
+ *
+ * \param   libh
+ *          Handle obtained from lvm_create.
  *
+ * \return  An error string describing the last LVM error.
  */
-lv_t *lvm_vg_create_lv_linear(vg_t *vg, const char *name, uint64_t size);
+const char *lvm_errmsg(lvm_t libh);
 
 /**
- * Remove a logical volume from a volume group.
- * This API commits the change to disk and does _not_ require calling
- * lvm_vg_write.
- * Currently only removing linear LVs are possible.
+ * Scan all devices on the system for VGs and LVM metadata.
  *
- * FIXME: This API should probably not commit to disk but require calling
- * lvm_vg_write.
+ * \return  Status code of 1 (success) or 0 (failure).
  */
-int lvm_vg_remove_lv(lv_t *lv);
+int lvm_scan_vgs(lvm_t libh);
+
+/*************************** volume group handling **************************/
 
 /**
- * Return stored error no describing last LVM API error.
+ * Return the list of volume group names.
  *
- * Users of liblvm should use lvm_errno to determine success or failure
- * of the last call, unless the API indicates another method of determining
- * success or failure.
+ * NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
+ * To scan the system, use lvm_scan_vgs.
+ *
+ * To process the list, use the dm_list iterator functions.  For example:
+ *      vg_t *vg;
+ *      struct dm_list *vgnames;
+ *      struct lvm_str_list *strl;
+ *
+ *      vgnames = lvm_list_vg_names(libh);
+ *	dm_list_iterate_items(strl, vgnames) {
+ *		vgname = strl->str;
+ *              vg = lvm_vg_open(libh, vgname, "r");
+ *              // do something with vg
+ *              lvm_vg_close(vg);
+ *      }
+ *
+ *
+ * \return  A list of struct lvm_str_list
+ *          If no VGs exist on the system, NULL is returned.
+ *
+ * FIXME: handle list memory cleanup
+ */
+struct dm_list *lvm_list_vg_names(lvm_t libh);
+
+/**
+ * Return the list of volume group uuids.
+ *
+ * NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
+ * To scan the system, use lvm_scan_vgs.
  *
  * \param   libh
  *          Handle obtained from lvm_create.
  *
- * \return  An errno value describing the last LVM error.
+ * \return  List of copied uuid strings.
  */
-int lvm_errno(lvm_t libh);
+struct dm_list *lvm_list_vg_uuids(lvm_t libh);
 
 /**
- * Return stored error message describing last LVM error.
+ * Open an existing VG.
+ *
+ * Open a VG for reading or writing.
  *
  * \param   libh
  *          Handle obtained from lvm_create.
- *
- * \return  An error string describing the last LVM error.
+ * \param   vgname
+ *          Name of the VG to open.
+ * \param   mode
+ *          Open mode - either "r" (read) or "w" (read/write).
+ *          Any other character results in an error with EINVAL set.
+ * \param   flags
+ *          Open flags - currently ignored.
+ * \return  non-NULL VG handle (success) or NULL (failure).
  */
-const char *lvm_errmsg(lvm_t libh);
+vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
+		  uint32_t flags);
 
 /**
  * Create a VG with default parameters.
@@ -220,11 +253,48 @@
  *
  * \param   libh
  *          Handle obtained from lvm_create.
- *
+ * \param   vg_name
+ *          Name of the VG to open.
  * \return  non-NULL vg handle (success) or NULL (failure)
  */
 vg_t *lvm_vg_create(lvm_t libh, const char *vg_name);
 
+ /**
+ * Write a VG to disk.
+ *
+ * This API commits the VG to disk.
+ * Upon failure, retry the operation and/or release the VG handle with
+ * lvm_vg_close.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Status code of 1 (success) or 0 (failure).
+ */
+int lvm_vg_write(vg_t *vg);
+
+/**
+ * Remove a VG from the system.
+ *
+ * This API commits the change to disk and does not require calling
+ * lvm_vg_write.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Status code of 1 (success) or 0 (failure).
+ */
+int lvm_vg_remove(vg_t *vg);
+
+/**
+ * Close a VG opened with lvm_vg_create
+ *
+ * This API releases a VG handle and any resources associated with the handle.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Status code of 1 (success) or 0 (failure).
+ */
+int lvm_vg_close(vg_t *vg);
+
 /**
  * Extend a VG by adding a device.
  *
@@ -238,11 +308,9 @@
  * before calling lvm_vg_extend.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create.
- *
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
  * \param   device
  *          Name of device to add to VG.
- *
  * \return  Status code of 1 (success) or 0 (failure).
  */
 int lvm_vg_extend(vg_t *vg, const char *device);
@@ -256,148 +324,220 @@
  * handle with lvm_vg_close.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create.
- *
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
  * \param   new_size
  *          New extent size to set (in sectors).
- *
  * \return  Status code of 1 (success) or 0 (failure).
  */
 int lvm_vg_set_extent_size(vg_t *vg, uint32_t new_size);
 
 /**
- * Write a VG to disk.
+ * Get the current name of a volume group.
  *
- * This API commits the VG to disk.
- * Upon failure, retry the operation and/or release the VG handle with
- * lvm_vg_close.
+ * Memory is allocated using malloc() and caller must free the memory
+ * using free().
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create.
- *
- * \return  Status code of 1 (success) or 0 (failure).
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Copy of the uuid string.
  */
-int lvm_vg_write(vg_t *vg);
+char *lvm_vg_get_uuid(const vg_t *vg);
 
 /**
- * Remove a VG from the system.
+ * Get the current uuid of a volume group.
  *
- * This API commits the change to disk and does not require calling
- * lvm_vg_write.
+ * Memory is allocated using malloc() and caller must free the memory
+ * using free().
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create.
- *
- * \return  Status code of 1 (success) or 0 (failure).
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Copy of the name.
  */
-int lvm_vg_remove(vg_t *vg);
+char *lvm_vg_get_name(const vg_t *vg);
 
 /**
- * Get the current name or uuid of a PV, VG, or LV.
+ * Get the current size in bytes of a volume group.
  *
- * Returns a copy of the current name or uuid for the given PV,
- * VG, or LV.
- *
- * Memory is allocated using malloc() and caller must free the memory
- * using free().
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Size in bytes.
  */
-char *lvm_pv_get_uuid(const pv_t *pv);
-char *lvm_vg_get_uuid(const vg_t *vg);
-char *lvm_lv_get_uuid(const lv_t *lv);
-char *lvm_pv_get_name(const pv_t *pv);
-char *lvm_vg_get_name(const vg_t *vg);
-char *lvm_lv_get_name(const lv_t *lv);
+uint64_t lvm_vg_get_size(const vg_t *vg);
 
 /**
- * Get various pv, vg, or lv properties.
- * For full description of each property, consult the man pages for pvs,
- * vgs, and lvs.
- * FIXME: What value to return for invalid handle or other errors?
+ * Get the current unallocated space in bytes of a volume group.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Free size in bytes.
  */
-uint64_t lvm_pv_get_mda_count(const pv_t *pv);
-uint64_t lvm_vg_get_size(const vg_t *vg);
 uint64_t lvm_vg_get_free_size(const vg_t *vg);
+
+/**
+ * Get the current extent size in bytes of a volume group.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Extent size in bytes.
+ */
 uint64_t lvm_vg_get_extent_size(const vg_t *vg);
+
+/**
+ * Get the current number of total extents of a volume group.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Extent count.
+ */
 uint64_t lvm_vg_get_extent_count(const vg_t *vg);
+
+/**
+ * Get the current number of free extents of a volume group.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Free extent count.
+ */
 uint64_t lvm_vg_get_free_extent_count(const vg_t *vg);
+
+/**
+ * Get the current number of physical volumes of a volume group.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \return  Physical volume count.
+ */
 uint64_t lvm_vg_get_pv_count(const vg_t *vg);
-uint64_t lvm_lv_get_size(const lv_t *lv);
+
+/************************** logical volume handling *************************/
 
 /**
- * Close a VG opened with lvm_vg_create
+ * Return a list of LV handles for a given VG handle.
  *
- * This API releases a VG handle and any resources associated with the handle.
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \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_vg_list_lvs(vg_t *vg);
+
+/**
+ * Create a linear logical volume.
+ * This API commits the change to disk and does _not_ require calling
+ * lvm_vg_write.
+ * FIXME: This API should probably not commit to disk but require calling
+ * lvm_vg_write.  However, this appears to be non-trivial change until
+ * lv_create_single is refactored by segtype.
  *
  * \param   vg
- *          VG handle obtained from lvm_vg_create.
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ * \param   name
+ *          Name of logical volume to create.
+ * \param   size
+ *          Size of logical volume in extents.
+ * \return  LV object
  *
- * \return  Status code of 1 (success) or 0 (failure).
  */
-int lvm_vg_close(vg_t *vg);
+lv_t *lvm_vg_create_lv_linear(vg_t *vg, const char *name, uint64_t size);
 
 /**
- * Open an existing VG.
+ * Remove a logical volume from a volume group.
  *
- * Open a VG for reading or writing.
+ * This function commits the change to disk and does _not_ require calling
+ * lvm_vg_write.
+ * Currently only removing linear LVs are possible.
  *
- * \param   libh
- *          Handle obtained from lvm_create.
+ * FIXME: This API should probably not commit to disk but require calling
+ * lvm_vg_write.
  *
- * \param   vgname
- *          Name of the VG to open.
+ * \param   lv
+ *          Logical volume handle.
+ * \return  Status code of 1 (success) or 0 (failure).
+ */
+int lvm_vg_remove_lv(lv_t *lv);
+
+/**
+ * Get the current name of a logical volume.
  *
- * \param   mode
- *          Open mode - either "r" (read) or "w" (read/write).
- *          Any other character results in an error with EINVAL set.
+ * Memory is allocated using malloc() and caller must free the memory
+ * using free().
  *
- * \param   flags
- *          Open flags - currently ignored.
+ * \param   lv
+ *          Logical volume handle.
+ * \return  Copy of the uuid string.
+ */
+char *lvm_lv_get_uuid(const lv_t *lv);
+
+/**
+ * Get the current uuid of a logical volume.
  *
- * \return  non-NULL VG handle (success) or NULL (failure).
+ * Memory is allocated using malloc() and caller must free the memory
+ * using free().
+ *
+ * \param   lv
+ *          Logical volume handle.
+ * \return  Copy of the name.
+ */
+char *lvm_lv_get_name(const lv_t *lv);
+
+/**
+ * Get the current size in bytes of a logical volume.
+ *
+ * \param   lv
+ *          Logical volume handle.
+ * \return  Size in bytes.
+ */
+uint64_t lvm_lv_get_size(const lv_t *lv);
+
+/************************** physical volume handling ************************/
+
+/**
+ * Physical volume handling should not be needed anymore. Only physical volumes
+ * bound to a vg contain useful information. Therefore the creation,
+ * modification and the removal of orphan physical volumes is not suported.
  */
-vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
-		  uint32_t flags);
 
 /**
  * Return a list of PV handles for a given VG handle.
  *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
  * \return  A list of pv_list_t structures containing pv handles for this vg.
  *          If no PVs exist on the given VG, NULL is returned.
  */
 struct dm_list *lvm_vg_list_pvs(vg_t *vg);
 
 /**
- * Return a list of VG names or VG uuids in the system.
+ * Get the current uuid of a logical volume.
  *
- * NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
- * To scan the system, use lvm_scan_vgs.
- *
- * To process the list, use the dm_list iterator functions.  For example:
- *      vg_t *vg;
- *      struct dm_list *vgnames;
- *      struct lvm_str_list *strl;
+ * Memory is allocated using malloc() and caller must free the memory
+ * using free().
  *
- *      vgnames = lvm_list_vg_names(libh);
- *	dm_list_iterate_items(strl, vgnames) {
- *		vgname = strl->str;
- *              vg = lvm_vg_open(libh, vgname, "r");
- *              // do something with vg
- *              lvm_vg_close(vg);
- *      }
+ * \param   pv
+ *          Physical volume handle.
+ * \return  Copy of the uuid string.
+ */
+char *lvm_pv_get_uuid(const pv_t *pv);
+
+/**
+ * Get the current name of a logical volume.
  *
+ * Memory is allocated using malloc() and caller must free the memory
+ * using free().
  *
- * \return  A list of struct lvm_str_list
- *          If no VGs exist on the system, NULL is returned.
- * FIXME: handle list memory cleanup
+ * \param   pv
+ *          Physical volume handle.
+ * \return  Copy of the name.
  */
-struct dm_list *lvm_list_vg_names(lvm_t libh);
-struct dm_list *lvm_list_vg_uuids(lvm_t libh);
+char *lvm_pv_get_name(const pv_t *pv);
 
 /**
- * Scan all devices on the system for VGs and LVM metadata.
+ * Get the current number of metadata areas in the physical volume.
  *
- * \return  Status code of 1 (success) or 0 (failure).
+ * \param   pv
+ *          Physical volume handle.
+ * \return  metadata area count.
  */
-int lvm_scan_vgs(lvm_t libh);
+uint64_t lvm_pv_get_mda_count(const pv_t *pv);
 
 #endif /* _LIB_LVM_H */


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

* LVM2/liblvm lvm.h
@ 2009-07-26 16:12 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-26 16:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 16:11:58

Modified files:
	liblvm         : lvm.h 

Log message:
	Update lvm.h handle and handle list comments.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.19&r2=1.20

--- LVM2/liblvm/lvm.h	2009/07/26 16:06:46	1.19
+++ LVM2/liblvm/lvm.h	2009/07/26 16:11:58	1.20
@@ -19,31 +19,92 @@
 
 #include <stdint.h>
 
-/* Internal object structures */
-struct volume_group;
+/******************************** structures ********************************/
+
+/* Internal object structures - do not use directly */
+struct lvm;
 struct physical_volume;
+struct volume_group;
 struct logical_volume;
 
-/* liblvm handles to objects pv, vg, lv, pvseg, lvseg */
-typedef struct volume_group vg_t;
+/**
+ * lvm handle.
+ *
+ * This is the base handle that is needed to open and create objects. Also
+ * error handling is bound to this handle.
+ */
+typedef struct lvm *lvm_t;
+
+/**
+ * Physical volume object.
+ *
+ * This object can be either a read-only object or a read-write object and
+ * depends on the mode of the volume group.  This object can not be
+ * written to disk independently, and changes will be written to disk
+ * when the volume group gets committed to disk. The open mode is the
+ * same as the volume group object it was created from.
+ */
 typedef struct physical_volume pv_t;
-typedef struct logical_volume lv_t;
 
-typedef struct lvm_vg_list {
-	struct dm_list list;
-	vg_t *vg;
-} vg_list_t;
+/**
+ * Volume group object.
+ *
+ * This object can be either a read-only object or a read-write object
+ * depending on the mode it was returned by a function. Create functions
+ * return a read-write object, but open functions have the argument mode to
+ * define if the object can be modified or not.
+ */
+typedef struct volume_group vg_t;
+
+/**
+ * Logical Volume object.
+ *
+ * This object can be either a read-only object or a read-write object
+ * depending on the mode it was returned by a function. This object can not be
+ * written to disk independently, it is bound to a volume group and changes
+ * will be written to disk when the volume group gets committed to disk. The
+ * open mode is the same as the volume group object is was created of.
+ */
+typedef struct logical_volume lv_t;
 
+/**
+ * Physical volume object list.
+ *
+ * The properties of physical volume objects also applies to the list of
+ * physical volumes.
+ */
 typedef struct lvm_pv_list {
 	struct dm_list list;
 	pv_t *pv;
 } pv_list_t;
 
+/**
+ * Volume group object list.
+ *
+ * The properties of volume group objects also applies to the list of
+ * volume groups.
+ */
+typedef struct lvm_vg_list {
+	struct dm_list list;
+	vg_t *vg;
+} vg_list_t;
+
+/**
+ * Logical Volume object list.
+ *
+ * The properties of logical volume objects also applies to the list of
+ * logical volumes.
+ */
 typedef struct lvm_lv_list {
 	struct dm_list list;
 	lv_t *lv;
 } lv_list_t;
 
+/**
+ * String list.
+ *
+ * This string list contains read-only strings.
+ */
 struct lvm_str_list {
 	struct dm_list list;
 	const char *str;
@@ -56,13 +117,7 @@
  *          If no LVs exist on the given VG, NULL is returned.
  */
 struct dm_list *lvm_vg_list_lvs(vg_t *vg);
-
-struct lvm; /* internal data */
-
-/**
- * The lvm handle.
- */
-typedef struct lvm *lvm_t;
+/*************************** generic lvm handling ***************************/
 
 /**
  * Create a LVM handle.


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

* LVM2/liblvm lvm.h
@ 2009-07-23 23:37 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-23 23:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-23 23:37:24

Modified files:
	liblvm         : lvm.h 

Log message:
	Add list structure definitions for liblvm objects.
	
	- pv_t, vg_t, lv_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_vg_list_lvs()
	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>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8

--- LVM2/liblvm/lvm.h	2009/07/23 23:36:20	1.7
+++ LVM2/liblvm/lvm.h	2009/07/23 23:37:24	1.8
@@ -15,6 +15,7 @@
 #define _LIB_LVM_H
 
 #include "lvm-version.h"
+#include "libdevmapper.h"
 
 #include <stdint.h>
 
@@ -28,6 +29,22 @@
 typedef struct physical_volume pv_t;
 typedef struct logical_volume lv_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 */
 
 /**


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

* LVM2/liblvm lvm.h
@ 2009-07-23 23:36 wysochanski
  0 siblings, 0 replies; 10+ messages in thread
From: wysochanski @ 2009-07-23 23:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-23 23:36:20

Modified files:
	liblvm         : lvm.h 

Log message:
	Remove lvseg_t and pvseg_t typedefs from liblvm/lvm.h.
	
	We do not need lvseg and pvseg for now.  If we need we will add back
	later.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/liblvm/lvm.h	2009/07/23 01:20:22	1.6
+++ LVM2/liblvm/lvm.h	2009/07/23 23:36:20	1.7
@@ -22,15 +22,11 @@
 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 */
 


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

end of thread, other threads:[~2009-07-28 15:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-28 15:34 LVM2/liblvm lvm.h wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2009-07-28 12:19 wysochanski
2009-07-28  0:36 wysochanski
2009-07-27 21:13 wysochanski
2009-07-27  8:28 wysochanski
2009-07-26 16:49 wysochanski
2009-07-26 16:35 wysochanski
2009-07-26 16:12 wysochanski
2009-07-23 23:37 wysochanski
2009-07-23 23:36 wysochanski

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).