summaryrefslogtreecommitdiff
path: root/lib/uuid
diff options
context:
space:
mode:
authorDave Wysochanski <dwysocha@redhat.com>2008-12-07 04:23:37 +0000
committerDave Wysochanski <dwysocha@redhat.com>2008-12-07 04:23:37 +0000
commitb721056e04ddd38564898b323caf8c559bf88cb7 (patch)
tree5717a6d048f0046b9ed6483934f862c601388f08 /lib/uuid
parent8d2f8d7b6b47b10b39729124c98840ba026e68de (diff)
downloadlvm2-b721056e04ddd38564898b323caf8c559bf88cb7.tar.gz
Add generic function to read /dev/urandom, used in uuid calculation.
Diffstat (limited to 'lib/uuid')
-rw-r--r--lib/uuid/uuid.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/uuid/uuid.c b/lib/uuid/uuid.c
index 39252c0e5..1ded223fa 100644
--- a/lib/uuid/uuid.c
+++ b/lib/uuid/uuid.c
@@ -15,6 +15,7 @@
#include "lib.h"
#include "uuid.h"
+#include "lvm-wrappers.h"
#include <assert.h>
#include <sys/stat.h>
@@ -94,25 +95,14 @@ int lvid_in_restricted_range(union lvid *lvid)
int id_create(struct id *id)
{
- int randomfile;
unsigned i;
size_t len = sizeof(id->uuid);
memset(id->uuid, 0, len);
- if ((randomfile = open("/dev/urandom", O_RDONLY)) < 0) {
- log_sys_error("open", "id_create: /dev/urandom");
+ if (!read_urandom(&id->uuid, len)) {
return 0;
}
- if (read(randomfile, id->uuid, len) != (ssize_t) len) {
- log_sys_error("read", "id_create: /dev/urandom");
- if (close(randomfile))
- stack;
- return 0;
- }
- if (close(randomfile))
- stack;
-
/*
* Skip out the last 2 chars in randomized creation for LVM1
* backwards compatibility.