1 #include "tests.h"
2 #include <asm/unistd.h>
3 
4 #ifdef __NR_linkat
5 
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) 0xdeadbeefffffffffULL;
15 	const long fd_new = (long) 0xdeadbeeffffffffeULL;
16 
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());
21 
22 	rc = syscall(__NR_linkat, -100, sample_1, -100, sample_2, -1L);
23 	printf("linkat(%s, \"%s\", %s, \"%s\", %s) = %ld %s (%m)\n",
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",
27 	       rc, errno2name());
28 
29 	puts("+++ exited with 0 +++");
30 	return 0;
31 }
32 
33 #else
34 
35 SKIP_MAIN_UNDEFINED("__NR_linkat")
36 
37 #endif
38