diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-08-15 17:19:06 -0600 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-08-23 16:29:28 -0600 |
commit | 8aaf7d913a382291f2770e6ce72a8919d5441bef (patch) | |
tree | 17eab2a1ccfbb90a78b377482adc48bade2b9734 /include/linux/random.h | |
parent | 4b9e40b23ad171cb1120a2befc3c2eb4a144ed63 (diff) |
urandom fallback
Diffstat (limited to 'include/linux/random.h')
-rw-r--r-- | include/linux/random.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/random.h b/include/linux/random.h index bd3dc61b..95a15d05 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -10,10 +10,19 @@ #include <sys/syscall.h> #include <linux/bug.h> +#ifdef __NR_getrandom static inline int getrandom(void *buf, size_t buflen, unsigned int flags) { return syscall(SYS_getrandom, buf, buflen, flags); } +#else +extern int urandom_fd; + +static inline int getrandom(void *buf, size_t buflen, unsigned int flags) +{ + return read(urandom_fd, buf, buflen); +} +#endif static inline void get_random_bytes(void *buf, int nbytes) { |