1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Add lvm2app function to query pvseg properties.

Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
This commit is contained in:
Petr Rockai 2010-11-17 20:12:39 +00:00
parent 4543dac58e
commit 55429cde3c
6 changed files with 56 additions and 6 deletions

View File

@ -1436,6 +1436,45 @@ uint64_t lvm_pv_get_free(const pv_t pv);
*/
struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name);
/**
* Get the value of a PV segment property
*
* \memberof pv_t
*
* \param pvseg
* Physical volume segment handle.
*
* \param name
* Name of property to query. See pvs man page for full list of properties
* that may be queried.
*
* The memory allocated for a string property value is tied to the vg_t
* handle and will be released when lvm_vg_close() is called.
*
* Example:
* lvm_property_value v;
* char *prop_name = "pvseg_start";
*
* v = lvm_pvseg_get_property(pvseg, prop_name);
* if (lvm_errno(libh) || !v.is_valid) {
* // handle error
* printf("Invalid property name or unable to query"
* "'%s'.\n", prop_name);
* return;
* }
* if (v.is_string)
* printf(", value = %s\n", v.value.string);
* else
* printf(", value = %"PRIu64"\n", v.value.integer);
*
* \return
* lvm_property_value structure that will contain the current
* value of the property. Caller should check lvm_errno() as well
* as 'is_valid' flag before using the value.
*/
struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
const char *name);
/**
* Return a list of pvseg handles for a given PV handle.
*

View File

@ -50,13 +50,13 @@ const char *lvm_lv_get_name(const lv_t lv)
struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name)
{
return get_property(NULL, NULL, lv, NULL, name);
return get_property(NULL, NULL, lv, NULL, NULL, name);
}
struct lvm_property_value lvm_lvseg_get_property(const lvseg_t lvseg,
const char *name)
{
return get_property(NULL, NULL, NULL, lvseg, name);
return get_property(NULL, NULL, NULL, lvseg, NULL, name);
}
uint64_t lvm_lv_is_active(const lv_t lv)

View File

@ -47,7 +47,7 @@ struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
const lv_t lv, const lvseg_t lvseg,
const char *name)
const pvseg_t pvseg, const char *name)
{
struct lvm_property_type prop;
struct lvm_property_value v;
@ -73,6 +73,11 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
v.is_valid = 0;
return v;
}
} else if (pvseg) {
if (!pvseg_get_property(pvseg, &prop)) {
v.is_valid = 0;
return v;
}
}
v.is_settable = prop.is_settable;
v.is_string = prop.is_string;

View File

@ -19,7 +19,7 @@
struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list);
struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
const lv_t lv, const lvseg_t lvseg,
const char *name);
const pvseg_t pvseg, const char *name);
int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
const char *name, struct lvm_property_value *value);

View File

@ -51,7 +51,13 @@ uint64_t lvm_pv_get_free(const pv_t pv)
struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
{
return get_property(pv, NULL, NULL, NULL, name);
return get_property(pv, NULL, NULL, NULL, NULL, name);
}
struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
const char *name)
{
return get_property(NULL, NULL, NULL, NULL, pvseg, name);
}
struct dm_list *lvm_pv_list_pvsegs(pv_t pv)

View File

@ -338,7 +338,7 @@ const char *lvm_vg_get_name(const vg_t vg)
struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name)
{
return get_property(NULL, vg, NULL, NULL, name);
return get_property(NULL, vg, NULL, NULL, NULL, name);
}
int lvm_vg_set_property(const vg_t vg, const char *name,