From: Sami Kerola Date: Sun, 30 Jul 2017 11:33:12 +0000 (+0100) Subject: libuuid: use access(2) when checking /dev/random availability X-Git-Tag: v2.31-rc1~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30124e172a8beef96bde3b6c0844d9aaea801ee8;p=thirdparty%2Futil-linux.git 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 --- diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c index 21e361293e..7dafcaeedd 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); }