1 #include <sys/syscall.h>
11 static int sys_execveat (int dirfd
, const char *pathname
,
12 char *const argv
[], char *const envp
[],
15 #if defined(__NR_execveat)
16 return syscall(__NR_execveat
, dirfd
, pathname
, argv
, envp
, flags
);
26 char *argv
[] = { "foobar", "execveat exists", NULL
};
27 char *envp
[] = { NULL
};
31 dirp
= opendir("/bin");
38 /* Check valgrind will produce expected warnings for the
39 various wrong arguments. */
41 char *mem
= malloc(16);
42 void *t
= (void *) &mem
[0];
43 void *z
= (void *) -1;
44 int flag
= *((int *) &mem
[8]);
46 sys_execveat(-1, "bin/xecho", argv
, envp
, 0);
47 sys_execveat(-1, "xecho", argv
, envp
, 0);
48 sys_execveat(fd
, "xecho", argv
, envp
, flag
);
49 sys_execveat(fd
, "", argv
, envp
, 0);
50 sys_execveat(fd
, NULL
, argv
, envp
, 0);
51 sys_execveat(fd
, "xecho", t
, envp
, 0);
52 sys_execveat(fd
, "xecho", z
, envp
, 0);
55 /* Check execveat called with the correct arguments works. */
56 if (sys_execveat(fd
, "echo", argv
, envp
, 0) == -1) {