34#include <sys/limits.h>
36#include <sys/random.h>
37#include <sys/sysproto.h>
41#define GRND_VALIDFLAGS (GRND_NONBLOCK | GRND_RANDOM | GRND_INSECURE)
60 if (buflen > IOSIZE_MAX)
94 if ((
flags & GRND_INSECURE) != 0)
95 flags |= GRND_NONBLOCK;
102 aiov.iov_base = user_buf;
103 aiov.iov_len = buflen;
104 auio.uio_iov = &aiov;
107 auio.uio_resid = buflen;
108 auio.uio_segflg = UIO_USERSPACE;
109 auio.uio_rw = UIO_READ;
112 error = read_random_uio(&auio, (
flags & GRND_NONBLOCK) != 0);
114 td->td_retval[0] = buflen - auio.uio_resid;
118#ifndef _SYS_SYSPROTO_H_
int sys_getrandom(struct thread *td, struct getrandom_args *uap)
static int kern_getrandom(struct thread *td, void *user_buf, size_t buflen, unsigned int flags)
CTASSERT(EWOULDBLOCK==EAGAIN)