]> granicus.if.org Git - strace/blob - tests/fchownat.c
Remove XLAT_END
[strace] / tests / fchownat.c
1 /*
2  * Check decoding of fchownat 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 #include <fcntl.h>
14
15 #if defined __NR_fchownat && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW
16
17 # include <stdio.h>
18 # include <unistd.h>
19
20 int
21 main(void)
22 {
23         static const char sample[] = "fchownat_sample";
24         uid_t uid = geteuid();
25         uid_t gid = getegid();
26
27         if (open(sample, O_RDONLY | O_CREAT, 0400) == -1)
28                 perror_msg_and_fail("open");
29
30         long rc = syscall(__NR_fchownat, AT_FDCWD, sample, uid, gid, 0);
31         printf("fchownat(AT_FDCWD, \"%s\", %d, %d, 0) = %s\n",
32                sample, uid, gid, sprintrc(rc));
33
34         if (unlink(sample))
35                 perror_msg_and_fail("unlink");
36
37         rc = syscall(__NR_fchownat, AT_FDCWD,
38                      sample, -1, -1L, AT_SYMLINK_NOFOLLOW);
39         printf("fchownat(AT_FDCWD, \"%s\", -1, -1, AT_SYMLINK_NOFOLLOW) = %s\n",
40                sample, sprintrc(rc));
41
42         puts("+++ exited with 0 +++");
43         return 0;
44 }
45
46 #else
47
48 SKIP_MAIN_UNDEFINED("__NR_fchownat && AT_FDCWD && AT_SYMLINK_NOFOLLOW")
49
50 #endif