blob: 2a268a28d87e76396068bb196cd99d9962f18e81 [file] [log] [blame]
Fei Jie41cd6572016-04-06 14:18:49 +08001#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
10int
11main(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. Levinf2f91c02016-04-07 00:39:18 +000021 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 Jie41cd6572016-04-06 14:18:49 +080028 puts("+++ exited with 0 +++");
29 return 0;
30}
31
32#else
33
34SKIP_MAIN_UNDEFINED("__NR_unlinkat")
35
36#endif