]> granicus.if.org Git - strace/blob - tests/fchmodat.c
Remove XLAT_END
[strace] / tests / fchmodat.c
1 /*
2  * Check decoding of fchmodat syscall.
3  *
4  * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
5  * Copyright (c) 2016-2019 The strace developers.
6  * All rights reserved.
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #include "tests.h"
12 #include "scno.h"
13
14 #ifdef __NR_fchmodat
15
16 # include <fcntl.h>
17 # include <sys/stat.h>
18 # include <stdio.h>
19 # include <unistd.h>
20
21 int
22 main(void)
23 {
24         static const char sample[] = "fchmodat_sample";
25
26         if (open(sample, O_RDONLY | O_CREAT, 0400) < 0)
27                 perror_msg_and_fail("open");
28
29         long rc = syscall(__NR_fchmodat, -100, sample, 0600);
30         printf("fchmodat(AT_FDCWD, \"%s\", 0600) = %s\n",
31                sample, sprintrc(rc));
32
33         if (unlink(sample))
34                 perror_msg_and_fail("unlink");
35
36         rc = syscall(__NR_fchmodat, -100, sample, 051);
37         printf("fchmodat(AT_FDCWD, \"%s\", 051) = %s\n",
38                sample, sprintrc(rc));
39
40         rc = syscall(__NR_fchmodat, -100, sample, 004);
41         printf("fchmodat(AT_FDCWD, \"%s\", 004) = %s\n",
42                sample, sprintrc(rc));
43
44         puts("+++ exited with 0 +++");
45         return 0;
46 }
47
48 #else
49
50 SKIP_MAIN_UNDEFINED("__NR_fchmodat")
51
52 #endif