mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Always fail if random id generation fails.
This commit is contained in:
parent
c44c015a2d
commit
52f9afec22
@ -1,5 +1,6 @@
|
||||
Version 2.01.02 -
|
||||
===================================
|
||||
Always fail if random id generation fails.
|
||||
Recognise gnbd devices.
|
||||
|
||||
Version 2.01.01 - 19th January 2005
|
||||
|
@ -88,8 +88,11 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
}
|
||||
*/
|
||||
|
||||
if (!*lv->lvid.s)
|
||||
lvid_create(&lv->lvid, &lv->vg->id);
|
||||
if (!*lv->lvid.s && !lvid_create(&lv->lvid, &lv->vg->id)) {
|
||||
log_error("Random lvid creation failed for %s/%s.",
|
||||
lv->vg->name, lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -267,10 +267,13 @@ struct physical_volume *pv_create(const struct format_type *fmt,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!id)
|
||||
id_create(&pv->id);
|
||||
else
|
||||
if (id)
|
||||
memcpy(&pv->id, id, sizeof(*id));
|
||||
else if (!id_create(&pv->id)) {
|
||||
log_error("Failed to create random uuid for %s.",
|
||||
dev_name(dev));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pv->dev = dev;
|
||||
|
||||
|
@ -134,7 +134,8 @@ int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow,
|
||||
if (id)
|
||||
s->id = *id;
|
||||
else if (!id_create(&s->id)) {
|
||||
log_error("Snapshot UUID creation failed");
|
||||
log_error("Random UUID creation failed for snapshot %s.",
|
||||
cow->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,7 @@ static unsigned char _inverse_c[256];
|
||||
int lvid_create(union lvid *lvid, struct id *vgid)
|
||||
{
|
||||
memcpy(lvid->id, vgid, sizeof(*lvid->id));
|
||||
id_create(&lvid->id[1]);
|
||||
|
||||
return 1;
|
||||
return id_create(&lvid->id[1]);
|
||||
}
|
||||
|
||||
void uuid_from_num(char *uuid, uint32_t num)
|
||||
@ -83,16 +81,18 @@ int id_create(struct id *id)
|
||||
|
||||
memset(id->uuid, 0, len);
|
||||
if ((randomfile = open("/dev/urandom", O_RDONLY)) < 0) {
|
||||
log_sys_error("open", "id_create");
|
||||
log_sys_error("open", "id_create: /dev/urandom");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (read(randomfile, id->uuid, len) != len) {
|
||||
log_sys_error("read", "id_create");
|
||||
close(randomfile);
|
||||
log_sys_error("read", "id_create: /dev/urandom");
|
||||
if (close(randomfile))
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
close(randomfile);
|
||||
if (close(randomfile))
|
||||
stack;
|
||||
|
||||
/*
|
||||
* Skip out the last 2 chars in randomized creation for LVM1
|
||||
|
@ -173,7 +173,11 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
}
|
||||
} else {
|
||||
/* --uuid: Change PV ID randomly */
|
||||
id_create(&pv->id);
|
||||
if (!id_create(&pv->id)) {
|
||||
log_error("Failed to generate new random UUID for %s.",
|
||||
pv_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
log_verbose("Updating physical volume \"%s\"", pv_name);
|
||||
|
@ -264,7 +264,11 @@ static int _vgchange_uuid(struct cmd_context *cmd, struct volume_group *vg)
|
||||
if (!archive(vg))
|
||||
return ECMD_FAILED;
|
||||
|
||||
id_create(&vg->id);
|
||||
if (!id_create(&vg->id)) {
|
||||
log_error("Failed to generate new random UUID for VG %s.",
|
||||
vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
memcpy(&lvl->lv->lvid, &vg->id, sizeof(vg->id));
|
||||
|
Loading…
Reference in New Issue
Block a user