Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 1 | #include <linux/fsnotify_backend.h> |
| 2 | #include <linux/path.h> |
| 3 | #include <linux/slab.h> |
| 4 | |
Jan Kara | 054c636 | 2016-12-21 18:06:12 +0100 | [diff] [blame] | 5 | extern struct kmem_cache *fanotify_mark_cache; |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 6 | extern struct kmem_cache *fanotify_event_cachep; |
Jan Kara | f083441 | 2014-04-03 14:46:33 -0700 | [diff] [blame] | 7 | extern struct kmem_cache *fanotify_perm_event_cachep; |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 8 | |
Jan Kara | 8581679 | 2014-01-28 21:38:06 +0100 | [diff] [blame] | 9 | /* |
Jan Kara | f083441 | 2014-04-03 14:46:33 -0700 | [diff] [blame] | 10 | * Structure for normal fanotify events. It gets allocated in |
| 11 | * fanotify_handle_event() and freed when the information is retrieved by |
| 12 | * userspace |
Jan Kara | 8581679 | 2014-01-28 21:38:06 +0100 | [diff] [blame] | 13 | */ |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 14 | struct fanotify_event_info { |
| 15 | struct fsnotify_event fse; |
| 16 | /* |
| 17 | * We hold ref to this path so it may be dereferenced at any point |
| 18 | * during this object's lifetime |
| 19 | */ |
| 20 | struct path path; |
| 21 | struct pid *tgid; |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 22 | }; |
| 23 | |
Jan Kara | f083441 | 2014-04-03 14:46:33 -0700 | [diff] [blame] | 24 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS |
| 25 | /* |
| 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. |
| 31 | */ |
| 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 */ |
| 36 | }; |
| 37 | |
| 38 | static inline struct fanotify_perm_event_info * |
| 39 | FANOTIFY_PE(struct fsnotify_event *fse) |
| 40 | { |
| 41 | return container_of(fse, struct fanotify_perm_event_info, fae.fse); |
| 42 | } |
| 43 | #endif |
| 44 | |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 45 | static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse) |
| 46 | { |
| 47 | return container_of(fse, struct fanotify_event_info, fse); |
| 48 | } |
Jan Kara | f083441 | 2014-04-03 14:46:33 -0700 | [diff] [blame] | 49 | |
| 50 | struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask, |
Al Viro | 3cd5eca | 2016-11-20 20:19:09 -0500 | [diff] [blame] | 51 | const struct path *path); |