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 | |
Fei Jie | 7a158a1 | 2016-04-06 14:18:48 +0800 | [diff] [blame] | 6 | # include <stdio.h> |
| 7 | # include <unistd.h> |
| 8 | |
| 9 | int |
| 10 | main(void) |
| 11 | { |
| 12 | static const char sample_1[] = "linkat_sample_old"; |
| 13 | static const char sample_2[] = "linkat_sample_new"; |
| 14 | const long fd_old = (long) 0xdeadbeefffffffff; |
| 15 | const long fd_new = (long) 0xdeadbeeffffffffe; |
| 16 | |
Dmitry V. Levin | 5c62af0 | 2016-04-21 21:00:18 +0000 | [diff] [blame] | 17 | long rc = syscall(__NR_linkat, fd_old, sample_1, fd_new, sample_2, 0); |
| 18 | printf("linkat(%d, \"%s\", %d, \"%s\", 0) = %ld %s (%m)\n", |
| 19 | (int) fd_old, sample_1, (int) fd_new, sample_2, |
| 20 | rc, errno2name()); |
Fei Jie | 7a158a1 | 2016-04-06 14:18:48 +0800 | [diff] [blame] | 21 | |
Dmitry V. Levin | 867c1cd | 2016-04-07 00:31:44 +0000 | [diff] [blame] | 22 | rc = syscall(__NR_linkat, -100, sample_1, -100, sample_2, -1L); |
Dmitry V. Levin | 5c62af0 | 2016-04-21 21:00:18 +0000 | [diff] [blame] | 23 | printf("linkat(%s, \"%s\", %s, \"%s\", %s) = %ld %s (%m)\n", |
Dmitry V. Levin | 867c1cd | 2016-04-07 00:31:44 +0000 | [diff] [blame] | 24 | "AT_FDCWD", sample_1, "AT_FDCWD", sample_2, |
| 25 | "AT_SYMLINK_NOFOLLOW|AT_REMOVEDIR|AT_SYMLINK_FOLLOW" |
| 26 | "|AT_NO_AUTOMOUNT|AT_EMPTY_PATH|0xffffe0ff", |
Dmitry V. Levin | 9f6611b | 2016-04-21 17:49:32 +0000 | [diff] [blame] | 27 | rc, errno2name()); |
Dmitry V. Levin | 867c1cd | 2016-04-07 00:31:44 +0000 | [diff] [blame] | 28 | |
Fei Jie | 7a158a1 | 2016-04-06 14:18:48 +0800 | [diff] [blame] | 29 | puts("+++ exited with 0 +++"); |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | #else |
| 34 | |
| 35 | SKIP_MAIN_UNDEFINED("__NR_linkat") |
| 36 | |
| 37 | #endif |