mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o removed display_uuid
o use id_write_format from lib/uuid/uuid.h instead
This commit is contained in:
parent
12137231d3
commit
d29265b97d
@ -18,13 +18,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include "metadata.h"
|
||||
#include "dbg_malloc.h"
|
||||
#include "log.h"
|
||||
#include "display.h"
|
||||
#include "activate.h"
|
||||
#include "uuid.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SIZE_BUF 128
|
||||
|
||||
@ -60,48 +62,17 @@ char *display_size(unsigned long long size, size_len_t sl)
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: this function is badly named, it doesn't display the data it
|
||||
* creates a new uuid string with -'s in it. It would be better if
|
||||
* the destination was passed in as well. EJT
|
||||
*/
|
||||
char *display_uuid(char *uuidstr)
|
||||
{
|
||||
int i, j;
|
||||
char *uuid;
|
||||
|
||||
if ((!uuidstr) || !(uuid = dbg_malloc(NAME_LEN))) {
|
||||
log_error("no memory for uuid display buffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(uuid, 0, NAME_LEN);
|
||||
|
||||
i = 6;
|
||||
memcpy(uuid, uuidstr, i);
|
||||
uuidstr += i;
|
||||
|
||||
for (j = 0; j < 6; j++) {
|
||||
uuid[i++] = '-';
|
||||
memcpy(&uuid[i], uuidstr, 4);
|
||||
uuidstr += 4;
|
||||
i += 4;
|
||||
}
|
||||
|
||||
memcpy(&uuid[i], uuidstr, 2);
|
||||
|
||||
/* Caller must free */
|
||||
return uuid;
|
||||
}
|
||||
|
||||
void pvdisplay_colons(struct physical_volume *pv)
|
||||
{
|
||||
char *uuid;
|
||||
char uuid[64];
|
||||
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
uuid = display_uuid(pv->id.uuid);
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return;
|
||||
}
|
||||
|
||||
log_print("%s:%s:%" PRIu64 ":-1:%u:%u:-1:%" PRIu64 ":%u:%u:%u:%s",
|
||||
dev_name(pv->dev), pv->vg_name, pv->size,
|
||||
@ -114,14 +85,12 @@ void pvdisplay_colons(struct physical_volume *pv)
|
||||
pv->pe_count - pv->pe_allocated,
|
||||
pv->pe_allocated, *uuid ? uuid : "none");
|
||||
|
||||
dbg_free(uuid);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void pvdisplay_full(struct physical_volume *pv)
|
||||
{
|
||||
char *uuid;
|
||||
char uuid[64];
|
||||
char *size, *size1; /*, *size2; */
|
||||
|
||||
uint64_t pe_free;
|
||||
@ -129,7 +98,10 @@ void pvdisplay_full(struct physical_volume *pv)
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
uuid = display_uuid(pv->id.uuid);
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return;
|
||||
}
|
||||
|
||||
log_print("--- %sPhysical volume ---", pv->pe_size ? "" : "NEW ");
|
||||
log_print("PV Name %s", dev_name(pv->dev));
|
||||
@ -179,8 +151,6 @@ void pvdisplay_full(struct physical_volume *pv)
|
||||
log_print("PV UUID %s", *uuid ? uuid : "none");
|
||||
log_print(" ");
|
||||
|
||||
dbg_free(uuid);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -456,6 +426,7 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
{
|
||||
uint32_t access;
|
||||
char *s1;
|
||||
char uuid[64];
|
||||
|
||||
log_print("--- Volume group ---");
|
||||
log_print("VG Name %s", vg->name);
|
||||
@ -513,16 +484,12 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
log_print("Free PE / Size %u / %s", vg->free_count, s1);
|
||||
dbg_free(s1);
|
||||
|
||||
if (strlen(vg->id.uuid))
|
||||
s1 = display_uuid(vg->id.uuid);
|
||||
else
|
||||
s1 = "none";
|
||||
|
||||
log_print("VG UUID %s", s1);
|
||||
|
||||
if (strlen(vg->id.uuid))
|
||||
dbg_free(s1);
|
||||
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return;
|
||||
}
|
||||
|
||||
log_print("VG UUID %s", uuid);
|
||||
log_print(" ");
|
||||
|
||||
return;
|
||||
|
@ -131,7 +131,7 @@ int pvscan(int argc, char **argv)
|
||||
|
||||
void pvscan_display_single(struct physical_volume *pv)
|
||||
{
|
||||
|
||||
char uuid[64];
|
||||
int vg_name_len = 0;
|
||||
|
||||
char *s1, *s2;
|
||||
@ -161,10 +161,13 @@ void pvscan_display_single(struct physical_volume *pv)
|
||||
vg_name_len = strlen(pv->vg_name) - sizeof (EXPORTED_TAG) + 1;
|
||||
|
||||
if (arg_count(uuid_ARG)) {
|
||||
sprintf(pv_tmp_name,
|
||||
"%-*s with UUID %s",
|
||||
pv_max_name_len - 2,
|
||||
dev_name(pv->dev), display_uuid(pv->id.uuid));
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(pv_tmp_name, "%-*s with UUID %s",
|
||||
pv_max_name_len - 2, dev_name(pv->dev), uuid);
|
||||
} else {
|
||||
sprintf(pv_tmp_name, "%s", dev_name(pv->dev));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user