blob: c8a7e37057ca47d000c527355bbc31ee8c5f7f6b [file] [log] [blame]
Dmitry V. Levin99db95d2014-02-05 04:13:18 +00001#include "defs.h"
2#include <linux/fanotify.h>
3
4static const struct xlat fan_classes[] = {
5 XLAT(FAN_CLASS_NOTIF),
6 XLAT(FAN_CLASS_CONTENT),
7 XLAT(FAN_CLASS_PRE_CONTENT),
8 XLAT_END
9};
10
11static const struct xlat fan_init_flags[] = {
12 XLAT(FAN_CLOEXEC),
13 XLAT(FAN_NONBLOCK),
14 XLAT(FAN_UNLIMITED_QUEUE),
15 XLAT(FAN_UNLIMITED_MARKS),
16 XLAT_END
17};
18
19int
20sys_fanotify_init(struct tcb *tcp)
21{
22 unsigned flags;
23
24 if (exiting(tcp))
25 return 0;
26
27 flags = tcp->u_arg[0];
28 printxval(fan_classes, flags & FAN_ALL_CLASS_BITS, "FAN_CLASS_???");
29 flags &= ~FAN_ALL_CLASS_BITS;
30 if (flags) {
31 tprints("|");
32 printflags(fan_init_flags, flags, "FAN_???");
33 }
34 tprints(", ");
35 tprint_open_modes((unsigned) tcp->u_arg[1]);
36
37 return 0;
38}
39
40static const struct xlat fan_mark_flags[] = {
41 XLAT(FAN_MARK_ADD),
42 XLAT(FAN_MARK_REMOVE),
43 XLAT(FAN_MARK_DONT_FOLLOW),
44 XLAT(FAN_MARK_ONLYDIR),
45 XLAT(FAN_MARK_MOUNT),
46 XLAT(FAN_MARK_IGNORED_MASK),
47 XLAT(FAN_MARK_IGNORED_SURV_MODIFY),
48 XLAT(FAN_MARK_FLUSH),
49 XLAT_END
50};
51
52static const struct xlat fan_event_flags[] = {
53 XLAT(FAN_ACCESS),
54 XLAT(FAN_MODIFY),
55 XLAT(FAN_CLOSE),
56 XLAT(FAN_CLOSE_WRITE),
57 XLAT(FAN_CLOSE_NOWRITE),
58 XLAT(FAN_OPEN),
59 XLAT(FAN_Q_OVERFLOW),
60 XLAT(FAN_OPEN_PERM),
61 XLAT(FAN_ACCESS_PERM),
62 XLAT(FAN_ONDIR),
63 XLAT(FAN_EVENT_ON_CHILD),
64 XLAT_END
65};
66
67int
68sys_fanotify_mark(struct tcb *tcp)
69{
70 if (exiting(tcp))
71 return 0;
72
73 printfd(tcp, tcp->u_arg[0]);
74 tprints(", ");
75 printflags(fan_mark_flags, (unsigned) tcp->u_arg[1], "FAN_MARK_???");
76 tprints(", ");
77 printflags(fan_event_flags, tcp->u_arg[2], "FAN_???");
78 tprints(", ");
79 if ((int) tcp->u_arg[3] == FAN_NOFD)
80 tprints("FAN_NOFD, ");
81 else
82 print_dirfd(tcp, tcp->u_arg[3]);
83 printpath(tcp, tcp->u_arg[4]);
84
85 return 0;
86}