diff options
author | Sami Kerola | 2017-07-30 13:33:12 +0200 |
---|---|---|
committer | Sami Kerola | 2017-08-05 10:58:25 +0200 |
commit | 30124e172a8beef96bde3b6c0844d9aaea801ee8 (patch) | |
tree | dcebf6de507f2f089179ff9c0d2f615f9abc1d6a /libuuid | |
parent | uuidparse: nil uuid have all bits set to zero (diff) | |
download | kernel-qcow2-util-linux-30124e172a8beef96bde3b6c0844d9aaea801ee8.tar.gz kernel-qcow2-util-linux-30124e172a8beef96bde3b6c0844d9aaea801ee8.tar.xz kernel-qcow2-util-linux-30124e172a8beef96bde3b6c0844d9aaea801ee8.zip |
libuuid: use access(2) when checking /dev/random availability
The access(2) is more lightwight than stat(2), and tells whether random
device(s) can be read or not, unlike the earlier stat() call.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'libuuid')
-rw-r--r-- | libuuid/src/gen_uuid.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c index 21e361293..7dafcaeed 100644 --- a/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c @@ -534,9 +534,8 @@ void uuid_generate_random(uuid_t out) */ static int have_random_source(void) { - struct stat s; - - return (!stat("/dev/random", &s) || !stat("/dev/urandom", &s)); + return (access("/dev/random", R_OK) == 0 || + access("/dev/urandom", R_OK) == 0); } |