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>
This commit is contained in:
Sami Kerola 2017-07-30 12:33:12 +01:00
parent 8cfbd35048
commit 30124e172a
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
1 changed files with 2 additions and 3 deletions

View File

@ -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);
}