summaryrefslogtreecommitdiffstats
path: root/sys/dev/random
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2015-07-14 18:45:15 +0000
committered <ed@FreeBSD.org>2015-07-14 18:45:15 +0000
commit4f8313adcd77ccc0953275aa06bb5181e4f85954 (patch)
treee31443362ff95281e596323578398cada5e3d232 /sys/dev/random
parent0f95984131a638e861338eaae0614aa09b18e35d (diff)
downloadFreeBSD-src-4f8313adcd77ccc0953275aa06bb5181e4f85954.zip
FreeBSD-src-4f8313adcd77ccc0953275aa06bb5181e4f85954.tar.gz
Implement the CloudABI random_get() system call.
The random_get() system call works similar to getentropy()/getrandom() on OpenBSD/Linux. It fills a buffer with random data. This change introduces a new function, read_random_uio(), that is used to implement read() on the random devices. We can call into this function from within the CloudABI compatibility layer. Approved by: secteam Reviewed by: jmg, markm, wblock Obtained from: https://github.com/NuxiNL/freebsd Differential Revision: https://reviews.freebsd.org/D3053
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/randomdev.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
index e27b9095..f3339aa 100644
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -152,6 +152,13 @@ static struct selinfo rsel;
static int
randomdev_read(struct cdev *dev __unused, struct uio *uio, int flags)
{
+
+ return (read_random_uio(uio, (flags & O_NONBLOCK) != 0));
+}
+
+int
+read_random_uio(struct uio *uio, bool nonblock)
+{
uint8_t *random_buf;
int error;
ssize_t read_len, total_read, c;
OpenPOWER on IntegriCloud