2018-03-14 17:23:22 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define BUF_SIZE 256
|
2018-05-07 17:50:49 +00:00
|
|
|
|
2019-03-15 20:04:14 +00:00
|
|
|
static __attribute__((noinline))
|
|
|
|
void urandom_read(int fd, int count)
|
|
|
|
{
|
|
|
|
char buf[BUF_SIZE];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
read(fd, buf, BUF_SIZE);
|
|
|
|
}
|
|
|
|
|
2018-05-07 17:50:49 +00:00
|
|
|
int main(int argc, char *argv[])
|
2018-03-14 17:23:22 +00:00
|
|
|
{
|
|
|
|
int fd = open("/dev/urandom", O_RDONLY);
|
2018-05-07 17:50:49 +00:00
|
|
|
int count = 4;
|
2018-03-14 17:23:22 +00:00
|
|
|
|
|
|
|
if (fd < 0)
|
|
|
|
return 1;
|
2018-05-07 17:50:49 +00:00
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
count = atoi(argv[1]);
|
|
|
|
|
2019-03-15 20:04:14 +00:00
|
|
|
urandom_read(fd, count);
|
2018-03-14 17:23:22 +00:00
|
|
|
|
|
|
|
close(fd);
|
|
|
|
return 0;
|
|
|
|
}
|