Skip to main content

sys_getrandom

Function sys_getrandom 

Source
pub fn sys_getrandom(
    buf: u64,
    len: usize,
    flags: u32,
) -> Result<u64, SyscallError>
Expand description

SYS_GETRANDOM (601): Fill a buffer with random bytes.

§Arguments

  • buf - Pointer to the userspace buffer
  • len - Number of bytes requested
  • flags - GRND_NONBLOCK (1) and/or GRND_RANDOM (2)

§Returns

  • Number of bytes written on success
  • -EAGAIN if GRND_NONBLOCK is set and entropy pool is not yet initialised
  • -EFAULT if buf pointer is invalid
  • -EINVAL if len is 0 or flags are invalid

§POSIX compatibility

POSIX signature: ssize_t getrandom(void *buf, size_t buflen, unsigned int flags)