Fei Jie | 7a158a1 | 2016-04-06 14:18:48 +0800 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include <sys/syscall.h> |
| 3 | |
| 4 | #ifdef __NR_linkat |
| 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_1[] = "linkat_sample_old"; |
| 14 | static const char sample_2[] = "linkat_sample_new"; |
| 15 | const long fd_old = (long) 0xdeadbeefffffffff; |
| 16 | const long fd_new = (long) 0xdeadbeeffffffffe; |
| 17 | |
| 18 | int rc = syscall(__NR_linkat, fd_old, sample_1, fd_new, sample_2, 0); |
| 19 | printf("linkat(%d, \"%s\", %d, \"%s\", 0) = %d %s (%m)\n", |
| 20 | (int) fd_old, sample_1, (int) fd_new, sample_2, rc, |
| 21 | errno == ENOSYS ? "ENOSYS" : "EBADF"); |
| 22 | |
Dmitry V. Levin | 867c1cd | 2016-04-07 00:31:44 +0000 | [diff] [blame] | 23 | rc = syscall(__NR_linkat, -100, sample_1, -100, sample_2, -1L); |
| 24 | printf("linkat(%s, \"%s\", %s, \"%s\", %s) = %d %s (%m)\n", |
| 25 | "AT_FDCWD", sample_1, "AT_FDCWD", sample_2, |
| 26 | "AT_SYMLINK_NOFOLLOW|AT_REMOVEDIR|AT_SYMLINK_FOLLOW" |
| 27 | "|AT_NO_AUTOMOUNT|AT_EMPTY_PATH|0xffffe0ff", |
| 28 | rc, errno == ENOSYS ? "ENOSYS" : "EINVAL"); |
| 29 | |
Fei Jie | 7a158a1 | 2016-04-06 14:18:48 +0800 | [diff] [blame] | 30 | puts("+++ exited with 0 +++"); |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | #else |
| 35 | |
| 36 | SKIP_MAIN_UNDEFINED("__NR_linkat") |
| 37 | |
| 38 | #endif |