mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Generate LV uuid from lv_number when reading in LVs.
This commit is contained in:
parent
dc511e9ecb
commit
b5ed53273a
@ -202,6 +202,12 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
uint32_t alloc;
|
||||
struct dm_info info;
|
||||
int inkernel;
|
||||
char uuid[64];
|
||||
|
||||
if (!id_write_format(&lv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inkernel = lv_info(lv, &info) && info.exists;
|
||||
|
||||
@ -211,6 +217,8 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
lv->vg->name, lv->name);
|
||||
log_print("VG Name %s", lv->vg->name);
|
||||
|
||||
log_print("LV UUID %s", uuid);
|
||||
|
||||
log_print("LV Write Access %s",
|
||||
(lv->status & LVM_WRITE) ? "read/write" : "read only");
|
||||
|
||||
|
@ -273,6 +273,9 @@ int export_vg(struct vg_disk *vgd, struct volume_group *vg)
|
||||
int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd)
|
||||
{
|
||||
memset(&lv->id, 0, sizeof(lv->id));
|
||||
|
||||
id_from_lvnum(&lv->id, lvd->lv_number);
|
||||
|
||||
if (!(lv->name = _create_lv_name(mem, lvd->lv_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
|
@ -354,6 +354,13 @@ static int _print_lvs(struct formatter *f, struct volume_group *vg)
|
||||
_out(f, "%s {", lv->name);
|
||||
_inc_indent(f);
|
||||
|
||||
if (!id_write_format(&lv->id, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_out(f, "id = \"%s\"", buffer);
|
||||
|
||||
if (!print_flags(lv->status, LV_FLAGS,
|
||||
buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
|
@ -365,6 +365,12 @@ static int _read_lv(struct pool *mem,
|
||||
lv->vg = vg;
|
||||
|
||||
|
||||
if (!_read_id(&lv->id, lvn, "id")) {
|
||||
log_err("Couldn't read uuid for logical volume %s.",
|
||||
lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(lvn, "status", '/'))) {
|
||||
log_err("Couldn't find status flags for logical volume.");
|
||||
return 0;
|
||||
|
@ -19,6 +19,32 @@ static unsigned char _c[] =
|
||||
static int _built_inverse;
|
||||
static unsigned char _inverse_c[256];
|
||||
|
||||
int id_from_lvnum(struct id *id, int lv_num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = ID_LEN; i; i--) {
|
||||
id->uuid[i - 1] = _c[lv_num % (sizeof(_c) - 1)];
|
||||
lv_num /= sizeof(_c) - 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lvnum_from_id(struct id *id)
|
||||
{
|
||||
int i, lv_num = 0;
|
||||
unsigned char *c;
|
||||
|
||||
for (i = 0; i < ID_LEN; i++) {
|
||||
lv_num *= sizeof(_c) - 1;
|
||||
if ((c = strchr(_c, id->uuid[i])))
|
||||
lv_num += (int) (c - _c);
|
||||
}
|
||||
|
||||
return lv_num;
|
||||
}
|
||||
|
||||
int id_create(struct id *id)
|
||||
{
|
||||
int random, i, len = sizeof(id->uuid);
|
||||
|
@ -15,6 +15,9 @@ struct id {
|
||||
uint8_t uuid[ID_LEN];
|
||||
};
|
||||
|
||||
int id_from_lvnum(struct id *id, int lv_num);
|
||||
int lvnum_from_id(struct id *id);
|
||||
|
||||
int id_create(struct id *id);
|
||||
int id_valid(struct id *id);
|
||||
int id_equal(struct id *lhs, struct id *rhs);
|
||||
|
Loading…
Reference in New Issue
Block a user