1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 10:25:13 +03:00

Add pv_uuid_dup, vg_uuid_dup, and lv_uuid_dup, and call id_format_and_copy.

Add supporting functions for pv_uuid, vg_uuid, and lv_uuid.
Call new function id_format_and_copy.  Use 'const' where appropriate.
Add "_dup" suffix to indicate memory is being allocated.
Call {pv|vg|lv}_uuid_dup from lvm2app uuid functions.
This commit is contained in:
Dave Wysochanski 2010-09-30 14:07:47 +00:00
parent f4fd41552d
commit 254d672dcc
9 changed files with 23 additions and 23 deletions

View File

@ -16,6 +16,11 @@
#include "metadata.h"
#include "activate.h"
char *lv_uuid_dup(const struct logical_volume *lv)
{
return id_format_and_copy(lv->vg->vgmem, &lv->lvid.id[1]);
}
uint64_t lv_size(const struct logical_volume *lv)
{
return lv->size;

View File

@ -49,5 +49,6 @@ struct logical_volume {
uint64_t lv_size(const struct logical_volume *lv);
char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_uuid_dup(const struct logical_volume *lv);
#endif

View File

@ -29,6 +29,11 @@ struct id pv_id(const struct physical_volume *pv)
return pv_field(pv, id);
}
char *pv_uuid_dup(const struct physical_volume *pv)
{
return id_format_and_copy(pv->vg->vgmem, &pv->id);
}
const struct format_type *pv_format_type(const struct physical_volume *pv)
{
return pv_field(pv, fmt);

View File

@ -56,6 +56,7 @@ struct device *pv_dev(const struct physical_volume *pv);
const char *pv_vg_name(const struct physical_volume *pv);
char *pv_attr_dup(struct dm_pool *mem, const struct physical_volume *pv);
const char *pv_dev_name(const struct physical_volume *pv);
char *pv_uuid_dup(const struct physical_volume *pv);
uint64_t pv_size(const struct physical_volume *pv);
uint64_t pv_size_field(const struct physical_volume *pv);
uint64_t pv_dev_size(const struct physical_volume *pv);

View File

@ -16,6 +16,11 @@
#include "metadata.h"
#include "activate.h"
char *vg_uuid_dup(const struct volume_group *vg)
{
return id_format_and_copy(vg->vgmem, &vg->id);
}
uint32_t vg_seqno(const struct volume_group *vg)
{
return vg->seqno;

View File

@ -124,5 +124,6 @@ unsigned snapshot_count(const struct volume_group *vg);
uint64_t vg_mda_size(const struct volume_group *vg);
uint64_t vg_mda_free(const struct volume_group *vg);
char *vg_attr_dup(struct dm_pool *mem, const struct volume_group *vg);
char *vg_uuid_dup(const struct volume_group *vg);
#endif

View File

@ -14,7 +14,7 @@
#include "lib.h"
#include "lvm2app.h"
#include "metadata-exported.h"
#include "metadata.h"
#include "lvm-string.h"
#include "defaults.h"
#include "segtype.h"
@ -39,13 +39,7 @@ uint64_t lvm_lv_get_size(const lv_t lv)
const char *lvm_lv_get_uuid(const lv_t lv)
{
char uuid[64] __attribute__((aligned(8)));
if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid))) {
log_error(INTERNAL_ERROR "unable to convert uuid");
return NULL;
}
return dm_pool_strndup(lv->vg->vgmem, (const char *)uuid, 64);
return lv_uuid_dup(lv);
}
const char *lvm_lv_get_name(const lv_t lv)

View File

@ -14,18 +14,12 @@
#include "lib.h"
#include "lvm2app.h"
#include "metadata-exported.h"
#include "metadata.h"
#include "lvm-string.h"
const char *lvm_pv_get_uuid(const pv_t pv)
{
char uuid[64] __attribute__((aligned(8)));
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
log_error(INTERNAL_ERROR "Unable to convert uuid");
return NULL;
}
return dm_pool_strndup(pv->vg->vgmem, (const char *)uuid, 64);
return pv_uuid_dup(pv);
}
const char *lvm_pv_get_name(const pv_t pv)

View File

@ -327,13 +327,7 @@ uint64_t lvm_vg_get_max_lv(const vg_t vg)
const char *lvm_vg_get_uuid(const vg_t vg)
{
char uuid[64] __attribute__((aligned(8)));
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
log_error(INTERNAL_ERROR "Unable to convert uuid");
return NULL;
}
return dm_pool_strndup(vg->vgmem, (const char *)uuid, 64);
return vg_uuid_dup(vg);
}
const char *lvm_vg_get_name(const vg_t vg)