Fei Jie | 41cd657 | 2016-04-06 14:18:49 +0800 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include <sys/syscall.h> |
| 3 | |
| 4 | #ifdef __NR_unlinkat |
| 5 | |
| 6 | # include <errno.h> |
| 7 | # include <stdio.h> |
| 8 | # include <unistd.h> |
| 9 | |
| 10 | int |
| 11 | main(void) |
| 12 | { |
| 13 | static const char sample[] = "unlinkat_sample"; |
| 14 | const long fd = (long) 0xdeadbeefffffffff; |
| 15 | |
| 16 | int rc = syscall(__NR_unlinkat, fd, sample, 0); |
| 17 | printf("unlinkat(%d, \"%s\", 0) = %d %s (%m)\n", |
| 18 | (int) fd, sample, rc, |
| 19 | errno == ENOSYS ? "ENOSYS" : "EBADF"); |
| 20 | |
Dmitry V. Levin | f2f91c0 | 2016-04-07 00:39:18 +0000 | [diff] [blame] | 21 | rc = syscall(__NR_unlinkat, -100, sample, -1L); |
| 22 | printf("unlinkat(%s, \"%s\", %s) = %d %s (%m)\n", |
| 23 | "AT_FDCWD", sample, |
| 24 | "AT_SYMLINK_NOFOLLOW|AT_REMOVEDIR|AT_SYMLINK_FOLLOW" |
| 25 | "|AT_NO_AUTOMOUNT|AT_EMPTY_PATH|0xffffe0ff", |
| 26 | rc, errno == ENOSYS ? "ENOSYS" : "EINVAL"); |
| 27 | |
Fei Jie | 41cd657 | 2016-04-06 14:18:49 +0800 | [diff] [blame] | 28 | puts("+++ exited with 0 +++"); |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | #else |
| 33 | |
| 34 | SKIP_MAIN_UNDEFINED("__NR_unlinkat") |
| 35 | |
| 36 | #endif |