add new renameat2 syscall
[trinity.git] / syscalls / splice.c
blobe971d0b3f974002d1df9ce4eb786c24626a2d33c
1 /*
2 * SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in,
3 int, fd_out, loff_t __user *, off_out,
4 size_t, len, unsigned int, flags)
5 */
6 #include <stdlib.h>
7 #include "sanitise.h"
8 #include "random.h"
9 #include "shm.h"
11 # define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
12 # define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
13 (but we may still block on the fd
14 we splice from/to). */
15 # define SPLICE_F_MORE 4 /* Expect more data. */
16 # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
18 static void sanitise_splice(int childno)
20 if ((rand() % 10) < 3)
21 return;
23 if (rand_bool()) {
24 shm->syscall[childno].a1 = shm->pipe_fds[rand() % MAX_PIPE_FDS];
25 shm->syscall[childno].a2 = 0;
28 if (rand_bool()) {
29 shm->syscall[childno].a3 = shm->pipe_fds[rand() % MAX_PIPE_FDS];
30 shm->syscall[childno].a4 = 0;
34 struct syscallentry syscall_splice = {
35 .name = "splice",
36 .num_args = 6,
37 .arg1name = "fd_in",
38 .arg1type = ARG_FD,
39 .arg2name = "off_in",
40 .arg2type = ARG_ADDRESS,
41 .arg3name = "fd_out",
42 .arg3type = ARG_FD,
43 .arg4name = "off_out",
44 .arg4type = ARG_ADDRESS,
45 .arg5name = "len",
46 .arg5type = ARG_LEN,
47 .arg6name = "flags",
48 .arg6type = ARG_LIST,
49 .arg6list = {
50 .num = 4,
51 .values = { SPLICE_F_MOVE, SPLICE_F_NONBLOCK, SPLICE_F_MORE, SPLICE_F_GIFT },
53 .sanitise = sanitise_splice,
54 .flags = NEED_ALARM,