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.
#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;
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
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);
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);
#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;
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
#include "lib.h"
#include "lvm2app.h"
-#include "metadata-exported.h"
+#include "metadata.h"
#include "lvm-string.h"
#include "defaults.h"
#include "segtype.h"
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)
#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)
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)