Loading...
Note: File does not exist in v4.6.
1#include <stdio.h>
2#include <unistd.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <fcntl.h>
6#include <stdlib.h>
7
8#define BUF_SIZE 256
9
10static __attribute__((noinline))
11void urandom_read(int fd, int count)
12{
13 char buf[BUF_SIZE];
14 int i;
15
16 for (i = 0; i < count; ++i)
17 read(fd, buf, BUF_SIZE);
18}
19
20int main(int argc, char *argv[])
21{
22 int fd = open("/dev/urandom", O_RDONLY);
23 int count = 4;
24
25 if (fd < 0)
26 return 1;
27
28 if (argc == 2)
29 count = atoi(argv[1]);
30
31 urandom_read(fd, count);
32
33 close(fd);
34 return 0;
35}