1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-01 08:58:47 +03:00

If PV/VG uuids are missing, generate them from the pv/vg numbers.

[This situation could occur if the uuids were oritinally created by
LVM1 on a system without /dev/urandom.]
This commit is contained in:
Alasdair Kergon 2004-01-09 19:18:20 +00:00
parent 9121eada08
commit ad8a001688
3 changed files with 22 additions and 0 deletions

View File

@ -150,6 +150,10 @@ static int _read_pvd(struct device *dev, struct pv_disk *pvd)
return 0;
}
/* If UUID is missing, create one */
if (pvd->pv_uuid[0] == '\0')
uuid_from_num(pvd->pv_uuid, pvd->pv_number);
return 1;
}
@ -172,6 +176,10 @@ static int _read_vgd(struct disk_list *data)
_xlate_vgd(vgd);
/* If UUID is missing, create one */
if (vgd->vg_uuid[0] == '\0')
uuid_from_num(vgd->vg_uuid, vgd->vg_number);
return 1;
}

View File

@ -25,6 +25,18 @@ int lvid_create(union lvid *lvid, struct id *vgid)
return 1;
}
void uuid_from_num(char *uuid, uint32_t num)
{
unsigned i;
for (i = ID_LEN; i; i--) {
uuid[i - 1] = _c[num % (sizeof(_c) - 1)];
num /= sizeof(_c) - 1;
}
uuid[ID_LEN] = '\0';
}
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num)
{
int i;

View File

@ -26,6 +26,8 @@ union lvid {
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num);
int lvnum_from_lvid(union lvid *lvid);
void uuid_from_num(char *uuid, uint32_t num);
int lvid_create(union lvid *lvid, struct id *vgid);
int id_create(struct id *id);
int id_valid(struct id *id);