1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_FANOTIFY_H
3 #define _LINUX_FANOTIFY_H
5 #include <linux/sysctl.h>
6 #include <uapi/linux/fanotify.h>
8 extern struct ctl_table fanotify_table[]; /* for sysctl */
10 #define FAN_GROUP_FLAG(group, flag) \
11 ((group)->fanotify_data.flags & (flag))
14 * Flags allowed to be passed from/to userspace.
16 * We intentionally do not add new bits to the old FAN_ALL_* constants, because
17 * they are uapi exposed constants. If there are programs out there using
18 * these constant, the programs may break if re-compiled with new uapi headers
19 * and then run on an old kernel.
21 #define FANOTIFY_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
22 FAN_CLASS_PRE_CONTENT)
24 #define FANOTIFY_FID_BITS (FAN_REPORT_FID | FAN_REPORT_DFID_NAME)
26 #define FANOTIFY_INIT_FLAGS (FANOTIFY_CLASS_BITS | FANOTIFY_FID_BITS | \
28 FAN_CLOEXEC | FAN_NONBLOCK | \
29 FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS)
31 #define FANOTIFY_MARK_TYPE_BITS (FAN_MARK_INODE | FAN_MARK_MOUNT | \
34 #define FANOTIFY_MARK_FLAGS (FANOTIFY_MARK_TYPE_BITS | \
37 FAN_MARK_DONT_FOLLOW | \
39 FAN_MARK_IGNORED_MASK | \
40 FAN_MARK_IGNORED_SURV_MODIFY | \
44 * Events that can be reported with data type FSNOTIFY_EVENT_PATH.
45 * Note that FAN_MODIFY can also be reported with data type
46 * FSNOTIFY_EVENT_INODE.
48 #define FANOTIFY_PATH_EVENTS (FAN_ACCESS | FAN_MODIFY | \
49 FAN_CLOSE | FAN_OPEN | FAN_OPEN_EXEC)
52 * Directory entry modification events - reported only to directory
53 * where entry is modified and not to a watching parent.
55 #define FANOTIFY_DIRENT_EVENTS (FAN_MOVE | FAN_CREATE | FAN_DELETE)
57 /* Events that can only be reported with data type FSNOTIFY_EVENT_INODE */
58 #define FANOTIFY_INODE_EVENTS (FANOTIFY_DIRENT_EVENTS | \
59 FAN_ATTRIB | FAN_MOVE_SELF | FAN_DELETE_SELF)
61 /* Events that user can request to be notified on */
62 #define FANOTIFY_EVENTS (FANOTIFY_PATH_EVENTS | \
63 FANOTIFY_INODE_EVENTS)
65 /* Events that require a permission response from user */
66 #define FANOTIFY_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM | \
69 /* Extra flags that may be reported with event or control handling of events */
70 #define FANOTIFY_EVENT_FLAGS (FAN_EVENT_ON_CHILD | FAN_ONDIR)
72 /* Events that may be reported to user */
73 #define FANOTIFY_OUTGOING_EVENTS (FANOTIFY_EVENTS | \
74 FANOTIFY_PERM_EVENTS | \
75 FAN_Q_OVERFLOW | FAN_ONDIR)
77 #define ALL_FANOTIFY_EVENT_BITS (FANOTIFY_OUTGOING_EVENTS | \
80 /* Do not use these old uapi constants internally */
81 #undef FAN_ALL_CLASS_BITS
82 #undef FAN_ALL_INIT_FLAGS
83 #undef FAN_ALL_MARK_FLAGS
85 #undef FAN_ALL_PERM_EVENTS
86 #undef FAN_ALL_OUTGOING_EVENTS
88 #endif /* _LINUX_FANOTIFY_H */