summaryrefslogtreecommitdiffstats
path: root/libuuid
diff options
context:
space:
mode:
authorSami Kerola2017-07-30 13:33:12 +0200
committerSami Kerola2017-08-05 10:58:25 +0200
commit30124e172a8beef96bde3b6c0844d9aaea801ee8 (patch)
treedcebf6de507f2f089179ff9c0d2f615f9abc1d6a /libuuid
parentuuidparse: nil uuid have all bits set to zero (diff)
downloadkernel-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.c5
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);
}