blob: 2a5fb14115dfe0415f2d39bc57acb8d902aecc60 [file] [log] [blame]
Jan Kara7053aee2014-01-21 15:48:14 -08001#include <linux/fsnotify_backend.h>
2#include <linux/path.h>
3#include <linux/slab.h>
4
5extern struct kmem_cache *fanotify_event_cachep;
Jan Karaf0834412014-04-03 14:46:33 -07006extern struct kmem_cache *fanotify_perm_event_cachep;
Jan Kara7053aee2014-01-21 15:48:14 -08007
Jan Kara85816792014-01-28 21:38:06 +01008/*
Jan Karaf0834412014-04-03 14:46:33 -07009 * Structure for normal fanotify events. It gets allocated in
10 * fanotify_handle_event() and freed when the information is retrieved by
11 * userspace
Jan Kara85816792014-01-28 21:38:06 +010012 */
Jan Kara7053aee2014-01-21 15:48:14 -080013struct fanotify_event_info {
14 struct fsnotify_event fse;
15 /*
16 * We hold ref to this path so it may be dereferenced at any point
17 * during this object's lifetime
18 */
19 struct path path;
20 struct pid *tgid;
Jan Kara7053aee2014-01-21 15:48:14 -080021};
22
Jan Karaf0834412014-04-03 14:46:33 -070023#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
24/*
25 * Structure for permission fanotify events. It gets allocated and freed in
26 * fanotify_handle_event() since we wait there for user response. When the
27 * information is retrieved by userspace the structure is moved from
28 * group->notification_list to group->fanotify_data.access_list to wait for
29 * user response.
30 */
31struct fanotify_perm_event_info {
32 struct fanotify_event_info fae;
33 int response; /* userspace answer to question */
34 int fd; /* fd we passed to userspace for this event */
35};
36
37static inline struct fanotify_perm_event_info *
38FANOTIFY_PE(struct fsnotify_event *fse)
39{
40 return container_of(fse, struct fanotify_perm_event_info, fae.fse);
41}
42#endif
43
Jan Kara7053aee2014-01-21 15:48:14 -080044static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse)
45{
46 return container_of(fse, struct fanotify_event_info, fse);
47}
Jan Karaf0834412014-04-03 14:46:33 -070048
49struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask,
50 struct path *path);