diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-08 00:13:18 -0900 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-20 09:07:08 -0900 |
commit | b33fc8298f7e13226b9895abc57c9bfce5e3fa2d (patch) | |
tree | a3d2a5a909b6372f7777c1c5c18cef5f81d123a9 /include/linux/random.h | |
parent | 7f4191a202ea4558ca2d5eb8a47daea33c9999c7 (diff) |
bcache in userspace; userspace fsck
Diffstat (limited to 'include/linux/random.h')
-rw-r--r-- | include/linux/random.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/random.h b/include/linux/random.h new file mode 100644 index 00000000..bd3dc61b --- /dev/null +++ b/include/linux/random.h @@ -0,0 +1,31 @@ +/* + * include/linux/random.h + * + * Include file for the random number generator. + */ +#ifndef _LINUX_RANDOM_H +#define _LINUX_RANDOM_H + +#include <unistd.h> +#include <sys/syscall.h> +#include <linux/bug.h> + +static inline int getrandom(void *buf, size_t buflen, unsigned int flags) +{ + return syscall(SYS_getrandom, buf, buflen, flags); +} + +static inline void get_random_bytes(void *buf, int nbytes) +{ + BUG_ON(getrandom(buf, nbytes, 0) != nbytes); +} + +static inline int get_random_int(void) +{ + int v; + + get_random_bytes(&v, sizeof(v)); + return v; +} + +#endif /* _LINUX_RANDOM_H */ |