summaryrefslogtreecommitdiff
path: root/lib/uuid
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2004-01-09 19:18:20 +0000
committerAlasdair Kergon <agk@redhat.com>2004-01-09 19:18:20 +0000
commitcc8f6e3dbc86dd0e5a532669092941e84c31b841 (patch)
tree199dbc2d316b4df0e0623c8ca3de8ee959f71826 /lib/uuid
parent397b239bdf677a40815dc1b352606335f22b1161 (diff)
downloadlvm2-cc8f6e3dbc86dd0e5a532669092941e84c31b841.tar.gz
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.]
Diffstat (limited to 'lib/uuid')
-rw-r--r--lib/uuid/uuid.c12
-rw-r--r--lib/uuid/uuid.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/uuid/uuid.c b/lib/uuid/uuid.c
index 8083b7abe..8e4a1533e 100644
--- a/lib/uuid/uuid.c
+++ b/lib/uuid/uuid.c
@@ -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;
diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h
index aa25773d7..ee7e36542 100644
--- a/lib/uuid/uuid.h
+++ b/lib/uuid/uuid.h
@@ -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);