[PATCH 5/9] libuuid: use access(2) when checking /dev/random availability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 libuuid/src/gen_uuid.c | 5 ++---
 1 file 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);
 }
 
 
-- 
2.13.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux