1 /*
2 * Copyright (c) 2014-2023 The strace developers.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8 #include "defs.h"
9 #include <linux/fcntl.h>
10 #include "xlat/fchmodat_flags.h"
11
12 static void
13 decode_chmod(struct tcb *tcp, const int offset)
14 {
15 /* pathname */
16 printpath(tcp, tcp->u_arg[offset]);
17 tprint_arg_next();
18
19 /* mode */
20 print_numeric_umode_t(tcp->u_arg[offset + 1]);
21 }
22
23 SYS_FUNC(chmod)
24 {
25 decode_chmod(tcp, 0);
26
27 return RVAL_DECODED;
28 }
29
30 static void
31 decode_fchmodat(struct tcb *tcp)
32 {
33 /* dirfd */
34 print_dirfd(tcp, tcp->u_arg[0]);
35 tprint_arg_next();
36
37 decode_chmod(tcp, 1);
38 }
39
40 SYS_FUNC(fchmodat)
41 {
42 decode_fchmodat(tcp);
43
44 return RVAL_DECODED;
45 }
46
47 SYS_FUNC(fchmodat2)
48 {
49 decode_fchmodat(tcp);
50 tprint_arg_next();
51
52 printflags(fchmodat_flags, tcp->u_arg[3], "AT_???");
53
54 return RVAL_DECODED;
55 }
56
57 SYS_FUNC(fchmod)
58 {
59 /* fd */
60 printfd(tcp, tcp->u_arg[0]);
61 tprint_arg_next();
62
63 /* mode */
64 print_numeric_umode_t(tcp->u_arg[1]);
65
66 return RVAL_DECODED;
67 }