Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Eric Paris | 63c882a | 2009-05-21 17:02:01 -0400 | [diff] [blame] | 2 | #include <linux/fsnotify_backend.h> |
| 3 | #include <linux/inotify.h> |
| 4 | #include <linux/slab.h> /* struct kmem_cache */ |
| 5 | |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 6 | struct inotify_event_info { |
| 7 | struct fsnotify_event fse; |
Amir Goldstein | a0a92d2 | 2019-01-10 19:04:31 +0200 | [diff] [blame] | 8 | u32 mask; |
Eric Paris | 63c882a | 2009-05-21 17:02:01 -0400 | [diff] [blame] | 9 | int wd; |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 10 | u32 sync_cookie; |
| 11 | int name_len; |
| 12 | char name[]; |
Eric Paris | 63c882a | 2009-05-21 17:02:01 -0400 | [diff] [blame] | 13 | }; |
| 14 | |
Eric Paris | 000285d | 2009-12-17 21:24:24 -0500 | [diff] [blame] | 15 | struct inotify_inode_mark { |
| 16 | struct fsnotify_mark fsn_mark; |
Eric Paris | 63c882a | 2009-05-21 17:02:01 -0400 | [diff] [blame] | 17 | int wd; |
| 18 | }; |
| 19 | |
Jan Kara | 7053aee | 2014-01-21 15:48:14 -0800 | [diff] [blame] | 20 | static inline struct inotify_event_info *INOTIFY_E(struct fsnotify_event *fse) |
| 21 | { |
| 22 | return container_of(fse, struct inotify_event_info, fse); |
| 23 | } |
| 24 | |
Eric Paris | 000285d | 2009-12-17 21:24:24 -0500 | [diff] [blame] | 25 | extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark, |
Eric Paris | 528da3e | 2009-06-12 16:04:26 -0400 | [diff] [blame] | 26 | struct fsnotify_group *group); |
Amir Goldstein | 1a2620a | 2020-12-02 14:07:08 +0200 | [diff] [blame] | 27 | extern int inotify_handle_inode_event(struct fsnotify_mark *inode_mark, |
| 28 | u32 mask, struct inode *inode, |
| 29 | struct inode *dir, |
| 30 | const struct qstr *name, u32 cookie); |
Eric Paris | 63c882a | 2009-05-21 17:02:01 -0400 | [diff] [blame] | 31 | |
| 32 | extern const struct fsnotify_ops inotify_fsnotify_ops; |
Jan Kara | 054c636 | 2016-12-21 18:06:12 +0100 | [diff] [blame] | 33 | extern struct kmem_cache *inotify_inode_mark_cachep; |
Nikolay Borisov | 1cce1ee | 2016-12-14 15:56:33 +0200 | [diff] [blame] | 34 | |
| 35 | #ifdef CONFIG_INOTIFY_USER |
| 36 | static inline void dec_inotify_instances(struct ucounts *ucounts) |
| 37 | { |
| 38 | dec_ucount(ucounts, UCOUNT_INOTIFY_INSTANCES); |
| 39 | } |
| 40 | |
| 41 | static inline struct ucounts *inc_inotify_watches(struct ucounts *ucounts) |
| 42 | { |
| 43 | return inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_INOTIFY_WATCHES); |
| 44 | } |
| 45 | |
| 46 | static inline void dec_inotify_watches(struct ucounts *ucounts) |
| 47 | { |
| 48 | dec_ucount(ucounts, UCOUNT_INOTIFY_WATCHES); |
| 49 | } |
| 50 | #endif |