Linux 4.18.10
[linux/fpc-iii.git] / fs / notify / fanotify / fanotify.h
blob8609ba06f4745769e70a69e61a4f0813b0902477
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/fsnotify_backend.h>
3 #include <linux/path.h>
4 #include <linux/slab.h>
6 extern struct kmem_cache *fanotify_mark_cache;
7 extern struct kmem_cache *fanotify_event_cachep;
8 extern struct kmem_cache *fanotify_perm_event_cachep;
11 * Structure for normal fanotify events. It gets allocated in
12 * fanotify_handle_event() and freed when the information is retrieved by
13 * userspace
15 struct fanotify_event_info {
16 struct fsnotify_event fse;
18 * We hold ref to this path so it may be dereferenced at any point
19 * during this object's lifetime
21 struct path path;
22 struct pid *tgid;
26 * Structure for permission fanotify events. It gets allocated and freed in
27 * fanotify_handle_event() since we wait there for user response. When the
28 * information is retrieved by userspace the structure is moved from
29 * group->notification_list to group->fanotify_data.access_list to wait for
30 * user response.
32 struct fanotify_perm_event_info {
33 struct fanotify_event_info fae;
34 int response; /* userspace answer to question */
35 int fd; /* fd we passed to userspace for this event */
38 static inline struct fanotify_perm_event_info *
39 FANOTIFY_PE(struct fsnotify_event *fse)
41 return container_of(fse, struct fanotify_perm_event_info, fae.fse);
44 static inline bool fanotify_is_perm_event(u32 mask)
46 return IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS) &&
47 mask & FAN_ALL_PERM_EVENTS;
50 static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse)
52 return container_of(fse, struct fanotify_event_info, fse);
55 struct fanotify_event_info *fanotify_alloc_event(struct fsnotify_group *group,
56 struct inode *inode, u32 mask,
57 const struct path *path);