Index: sys/compat/cloudabi/cloudabi_random.c =================================================================== --- sys/compat/cloudabi/cloudabi_random.c +++ sys/compat/cloudabi/cloudabi_random.c @@ -26,6 +26,10 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include + #include int @@ -32,7 +36,18 @@ cloudabi_sys_random_get(struct thread *td, struct cloudabi_sys_random_get_args *uap) { + struct iovec iov = { + .iov_base = uap->buf, + .iov_len = uap->nbyte + }; + struct uio uio = { + .uio_iov = &iov, + .uio_iovcnt = 1, + .uio_resid = iov.iov_len, + .uio_segflg = UIO_USERSPACE, + .uio_rw = UIO_READ, + .uio_td = td + }; - /* Not implemented. */ - return (ENOSYS); + return (read_random_uio(&uio, 0)); } Index: sys/dev/random/randomdev.c =================================================================== --- sys/dev/random/randomdev.c +++ sys/dev/random/randomdev.c @@ -134,6 +134,13 @@ static int randomdev_read(struct cdev *dev __unused, struct uio *uio, int flags) { + + return (read_random_uio(uio, flags)); +} + +int +read_random_uio(struct uio *uio, int flags) +{ uint8_t *random_buf; int c, error; ssize_t nbytes; Index: sys/sys/random.h =================================================================== --- sys/sys/random.h +++ sys/sys/random.h @@ -31,7 +31,10 @@ #ifdef _KERNEL +struct uio; + u_int read_random(void *, u_int); +int read_random_uio(struct uio *, int); /* * Note: if you add or remove members of random_entropy_source, remember to also update the