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