public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/fw/builtin-syscalls-4] hurd: Make getrandom honour GRND_NONBLOCK
@ 2019-12-31 10:46 Florian Weimer
0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2019-12-31 10:46 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a45244ce127763872ff0b5743fb4ac8299ee9b28
commit a45244ce127763872ff0b5743fb4ac8299ee9b28
Author: James Clarke <jrtc27@jrtc27.com>
Date: Tue Dec 17 18:29:29 2019 +0000
hurd: Make getrandom honour GRND_NONBLOCK
* sysdeps/mach/hurd/getrandom.c (__getrandom): Open the random source
with O_NONBLOCK when the GRND_NONBLOCK flag is provided.
Message-Id: <20191217182929.90989-1-jrtc27@jrtc27.com>
Diff:
---
sysdeps/mach/hurd/getrandom.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sysdeps/mach/hurd/getrandom.c b/sysdeps/mach/hurd/getrandom.c
index 8bf42aa..aac9c6f 100644
--- a/sysdeps/mach/hurd/getrandom.c
+++ b/sysdeps/mach/hurd/getrandom.c
@@ -27,13 +27,17 @@ ssize_t
__getrandom (void *buffer, size_t length, unsigned int flags)
{
const char *random_source = "/dev/urandom";
+ int open_flags = O_RDONLY | O_CLOEXEC;
size_t amount_read;
int fd;
if (flags & GRND_RANDOM)
random_source = "/dev/random";
- fd = __open_nocancel(random_source, O_RDONLY | O_CLOEXEC);
+ if (flags & GRND_NONBLOCK)
+ open_flags |= O_NONBLOCK;
+
+ fd = __open_nocancel(random_source, open_flags);
if (fd == -1)
return -1;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-31 10:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-31 10:46 [glibc/fw/builtin-syscalls-4] hurd: Make getrandom honour GRND_NONBLOCK Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).