License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / fs / notify / fanotify / fanotify.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
7053aee2
JK
2#include <linux/fsnotify_backend.h>
3#include <linux/path.h>
4#include <linux/slab.h>
5
054c636e 6extern struct kmem_cache *fanotify_mark_cache;
7053aee2 7extern struct kmem_cache *fanotify_event_cachep;
f083441b 8extern struct kmem_cache *fanotify_perm_event_cachep;
7053aee2 9
85816794 10/*
f083441b
JK
11 * Structure for normal fanotify events. It gets allocated in
12 * fanotify_handle_event() and freed when the information is retrieved by
13 * userspace
85816794 14 */
7053aee2
JK
15struct fanotify_event_info {
16 struct fsnotify_event fse;
17 /*
18 * We hold ref to this path so it may be dereferenced at any point
19 * during this object's lifetime
20 */
21 struct path path;
22 struct pid *tgid;
f083441b
JK
23};
24
7053aee2 25#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
f083441b
JK
26/*
27 * Structure for permission fanotify events. It gets allocated and freed in
28 * fanotify_handle_event() since we wait there for user response. When the
29 * information is retrieved by userspace the structure is moved from
30 * group->notification_list to group->fanotify_data.access_list to wait for
31 * user response.
32 */
33struct fanotify_perm_event_info {
34 struct fanotify_event_info fae;
35 int response; /* userspace answer to question */
36 int fd; /* fd we passed to userspace for this event */
7053aee2
JK
37};
38
f083441b
JK
39static inline struct fanotify_perm_event_info *
40FANOTIFY_PE(struct fsnotify_event *fse)
41{
42 return container_of(fse, struct fanotify_perm_event_info, fae.fse);
43}
44#endif
45
7053aee2
JK
46static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse)
47{
48 return container_of(fse, struct fanotify_event_info, fse);
49}
f083441b
JK
50
51struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask,
3cd5eca8 52 const struct path *path);