]> granicus.if.org Git - strace/blob - fanotify.c
evdev: decode struct input_absinfo regardless of in-kernel definitions
[strace] / fanotify.c
1 /*
2  * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
3  * Copyright (c) 2014-2019 The strace developers.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: LGPL-2.1-or-later
7  */
8
9 #include "defs.h"
10
11 #include "xlat/fan_classes.h"
12 #include "xlat/fan_init_flags.h"
13
14 #ifndef FAN_ALL_CLASS_BITS
15 # define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
16 #endif
17 #ifndef FAN_NOFD
18 # define FAN_NOFD -1
19 #endif
20
21 SYS_FUNC(fanotify_init)
22 {
23         unsigned int flags = tcp->u_arg[0];
24
25         printxval(fan_classes, flags & FAN_ALL_CLASS_BITS, "FAN_CLASS_???");
26         flags &= ~FAN_ALL_CLASS_BITS;
27         if (flags) {
28                 tprints("|");
29                 printflags(fan_init_flags, flags, "FAN_???");
30         }
31         tprints(", ");
32         tprint_open_modes((unsigned) tcp->u_arg[1]);
33
34         return RVAL_DECODED | RVAL_FD;
35 }
36
37 #include "xlat/fan_mark_flags.h"
38 #include "xlat/fan_event_flags.h"
39
40 SYS_FUNC(fanotify_mark)
41 {
42         printfd(tcp, tcp->u_arg[0]);
43         tprints(", ");
44         printflags(fan_mark_flags, tcp->u_arg[1], "FAN_MARK_???");
45         tprints(", ");
46         /*
47          * the mask argument is defined as 64-bit,
48          * but kernel uses the lower 32 bits only.
49          */
50         unsigned long long mask = 0;
51         int argn = getllval(tcp, &mask, 2);
52 #ifdef HPPA
53         /* Parsic is weird.  See arch/parisc/kernel/sys_parisc32.c.  */
54         mask = (mask << 32) | (mask >> 32);
55 #endif
56         printflags64(fan_event_flags, mask, "FAN_???");
57         tprints(", ");
58         if ((int) tcp->u_arg[argn] == FAN_NOFD)
59                 print_xlat_d(FAN_NOFD);
60         else
61                 print_dirfd(tcp, tcp->u_arg[argn]);
62         tprints(", ");
63         printpath(tcp, tcp->u_arg[argn + 1]);
64
65         return RVAL_DECODED;
66 }