38
static int rand_pipe_fd(void)
40
return shm->pipe_fds[rand() % MAX_PIPE_FDS];
43
/* perf related fds (see also perf.c & syscalls/perf_event_open.c) */
44
static int rand_perf_fd(void)
46
return shm->perf_fds[rand() % MAX_PERF_FDS];
49
/* epoll related fds */
50
static void open_epoll_fds(void)
55
while (i < MAX_EPOLL_FDS) {
57
switch (rand_bool()) {
58
case 0: fd = epoll_create(1);
60
case 1: fd = epoll_create1(EPOLL_CLOEXEC);
67
shm->epoll_fds[i] = fd;
68
output(2, "fd[%d] = epoll\n", shm->epoll_fds[i]);
74
static int rand_epoll_fd(void)
76
return shm->epoll_fds[rand() % MAX_EPOLL_FDS];
80
static void open_eventfd_fds(void)
84
shm->eventfd_fds[0] = eventfd(rand32(), 0);
85
shm->eventfd_fds[1] = eventfd(rand32(), EFD_CLOEXEC);
86
shm->eventfd_fds[2] = eventfd(rand32(), EFD_NONBLOCK);
87
shm->eventfd_fds[3] = eventfd(rand32(), EFD_SEMAPHORE);
88
shm->eventfd_fds[4] = eventfd(rand32(), EFD_CLOEXEC | EFD_NONBLOCK);
89
shm->eventfd_fds[5] = eventfd(rand32(), EFD_CLOEXEC | EFD_SEMAPHORE);
90
shm->eventfd_fds[6] = eventfd(rand32(), EFD_NONBLOCK | EFD_SEMAPHORE);
91
shm->eventfd_fds[7] = eventfd(rand32(), EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE);
93
for (i = 0; i < MAX_EVENTFD_FDS; i++)
94
output(2, "fd[%d] = eventfd\n", shm->eventfd_fds[i]);
97
static int rand_eventfd_fd(void)
99
return shm->eventfd_fds[rand() % MAX_EVENTFD_FDS];
102
/* regular file FDs */
103
unsigned int nr_file_fds = 0;
35
105
static int rand_file_fd(void)
37
107
unsigned int fd_index;
40
110
return shm->file_fds[fd_index];
43
static int rand_pipe_fd(void)
45
return shm->pipe_fds[rand() % MAX_PIPE_FDS];
48
114
static int get_new_random_fd(void)
55
122
if (do_specific_proto == TRUE)
124
207
void setup_fds(void)
127
if (no_files == TRUE)
209
/* If we have victim files, don't worry about sockets. */
210
if (victim_path == NULL)
133
if (files_in_index == 0)
221
if (no_files == FALSE) {
223
if (files_in_index == 0) /* Something bad happened. Crappy -V maybe? */
224
return; // FIXME: We should log something here probably.
139
230
void regenerate_fds(void)