Judger/tests/test_src/seccomp/write_file_openat.c
2017-08-30 08:46:48 +08:00

21 lines
378 B
C

#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
int flags;
if (!strcmp(argv[2], "w")) {
flags = O_WRONLY | O_CREAT;
}
else {
flags = O_RDWR | O_CREAT;
}
int fd = openat(0, argv[1], flags, 0755);
if (fd < 0) {
return errno;
}
close(fd);
return 0;
}