1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

o removed display_uuid

o use id_write_format from lib/uuid/uuid.h instead
This commit is contained in:
Joe Thornber 2002-01-21 11:29:06 +00:00
parent 12137231d3
commit d29265b97d
2 changed files with 28 additions and 58 deletions

View File

@ -18,13 +18,15 @@
* *
*/ */
#include <sys/types.h>
#include <string.h>
#include "metadata.h" #include "metadata.h"
#include "dbg_malloc.h" #include "dbg_malloc.h"
#include "log.h" #include "log.h"
#include "display.h" #include "display.h"
#include "activate.h" #include "activate.h"
#include "uuid.h"
#include <sys/types.h>
#include <string.h>
#define SIZE_BUF 128 #define SIZE_BUF 128
@ -60,48 +62,17 @@ char *display_size(unsigned long long size, size_len_t sl)
return size_buf; 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) void pvdisplay_colons(struct physical_volume *pv)
{ {
char *uuid; char uuid[64];
if (!pv) if (!pv)
return; 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", log_print("%s:%s:%" PRIu64 ":-1:%u:%u:-1:%" PRIu64 ":%u:%u:%u:%s",
dev_name(pv->dev), pv->vg_name, pv->size, 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_count - pv->pe_allocated,
pv->pe_allocated, *uuid ? uuid : "none"); pv->pe_allocated, *uuid ? uuid : "none");
dbg_free(uuid);
return; return;
} }
void pvdisplay_full(struct physical_volume *pv) void pvdisplay_full(struct physical_volume *pv)
{ {
char *uuid; char uuid[64];
char *size, *size1; /*, *size2; */ char *size, *size1; /*, *size2; */
uint64_t pe_free; uint64_t pe_free;
@ -129,7 +98,10 @@ void pvdisplay_full(struct physical_volume *pv)
if (!pv) if (!pv)
return; 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("--- %sPhysical volume ---", pv->pe_size ? "" : "NEW ");
log_print("PV Name %s", dev_name(pv->dev)); 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("PV UUID %s", *uuid ? uuid : "none");
log_print(" "); log_print(" ");
dbg_free(uuid);
return; return;
} }
@ -456,6 +426,7 @@ void vgdisplay_full(struct volume_group *vg)
{ {
uint32_t access; uint32_t access;
char *s1; char *s1;
char uuid[64];
log_print("--- Volume group ---"); log_print("--- Volume group ---");
log_print("VG Name %s", vg->name); 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); log_print("Free PE / Size %u / %s", vg->free_count, s1);
dbg_free(s1); dbg_free(s1);
if (strlen(vg->id.uuid)) if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
s1 = display_uuid(vg->id.uuid); stack;
else return;
s1 = "none"; }
log_print("VG UUID %s", s1);
if (strlen(vg->id.uuid))
dbg_free(s1);
log_print("VG UUID %s", uuid);
log_print(" "); log_print(" ");
return; return;

View File

@ -131,7 +131,7 @@ int pvscan(int argc, char **argv)
void pvscan_display_single(struct physical_volume *pv) void pvscan_display_single(struct physical_volume *pv)
{ {
char uuid[64];
int vg_name_len = 0; int vg_name_len = 0;
char *s1, *s2; 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; vg_name_len = strlen(pv->vg_name) - sizeof (EXPORTED_TAG) + 1;
if (arg_count(uuid_ARG)) { if (arg_count(uuid_ARG)) {
sprintf(pv_tmp_name, if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
"%-*s with UUID %s", stack;
pv_max_name_len - 2, return;
dev_name(pv->dev), display_uuid(pv->id.uuid)); }
sprintf(pv_tmp_name, "%-*s with UUID %s",
pv_max_name_len - 2, dev_name(pv->dev), uuid);
} else { } else {
sprintf(pv_tmp_name, "%s", dev_name(pv->dev)); sprintf(pv_tmp_name, "%s", dev_name(pv->dev));
} }