Dmitry V. Levin
fef09070d6
* getrandom.c: New file. * Makefile.am (strace_SOURCES): Add it. * linux/dummy.h (sys_getrandom): Remove. * linux/syscall.h (sys_getrandom): New prototype. * xlat/getrandom_flags.in: New file. * tests/getrandom.c: New file. * tests/getrandom.awk: New file. * tests/getrandom.test: New test. * tests/Makefile.am (check_PROGRAMS): Add getrandom. (TESTS): Add getrandom.test. (EXTRA_DIST): Add getrandom.awk. * tests/.gitignore: Add getrandom.
22 lines
380 B
C
22 lines
380 B
C
#include <unistd.h>
|
|
#include <sys/syscall.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
#ifdef __NR_getrandom
|
|
char buf[4];
|
|
|
|
if (syscall(__NR_getrandom, buf, sizeof(buf) - 1, 0) != sizeof(buf) - 1)
|
|
return 77;
|
|
if (syscall(__NR_getrandom, buf, sizeof(buf), 1) != sizeof(buf))
|
|
return 77;
|
|
if (syscall(__NR_getrandom, buf, sizeof(buf), 0x3003) != -1)
|
|
return 77;
|
|
|
|
return 0;
|
|
#else
|
|
return 77;
|
|
#endif
|
|
}
|