blob: c00d2caca8948662a06bfd715187d8640c774b3b [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Eric Paris63c882a2009-05-21 17:02:01 -04002#include <linux/fsnotify_backend.h>
3#include <linux/inotify.h>
4#include <linux/slab.h> /* struct kmem_cache */
5
Jan Kara7053aee2014-01-21 15:48:14 -08006struct inotify_event_info {
7 struct fsnotify_event fse;
Eric Paris63c882a2009-05-21 17:02:01 -04008 int wd;
Jan Kara7053aee2014-01-21 15:48:14 -08009 u32 sync_cookie;
10 int name_len;
11 char name[];
Eric Paris63c882a2009-05-21 17:02:01 -040012};
13
Eric Paris000285d2009-12-17 21:24:24 -050014struct inotify_inode_mark {
15 struct fsnotify_mark fsn_mark;
Eric Paris63c882a2009-05-21 17:02:01 -040016 int wd;
17};
18
Jan Kara7053aee2014-01-21 15:48:14 -080019static inline struct inotify_event_info *INOTIFY_E(struct fsnotify_event *fse)
20{
21 return container_of(fse, struct inotify_event_info, fse);
22}
23
Eric Paris000285d2009-12-17 21:24:24 -050024extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
Eric Paris528da3e2009-06-12 16:04:26 -040025 struct fsnotify_group *group);
Jan Kara7053aee2014-01-21 15:48:14 -080026extern int inotify_handle_event(struct fsnotify_group *group,
27 struct inode *inode,
28 struct fsnotify_mark *inode_mark,
29 struct fsnotify_mark *vfsmount_mark,
Al Viro3cd5eca2016-11-20 20:19:09 -050030 u32 mask, const void *data, int data_type,
Jan Kara9385a842016-11-10 17:51:50 +010031 const unsigned char *file_name, u32 cookie,
32 struct fsnotify_iter_info *iter_info);
Eric Paris63c882a2009-05-21 17:02:01 -040033
34extern const struct fsnotify_ops inotify_fsnotify_ops;
Jan Kara054c6362016-12-21 18:06:12 +010035extern struct kmem_cache *inotify_inode_mark_cachep;
Nikolay Borisov1cce1ee2016-12-14 15:56:33 +020036
37#ifdef CONFIG_INOTIFY_USER
38static inline void dec_inotify_instances(struct ucounts *ucounts)
39{
40 dec_ucount(ucounts, UCOUNT_INOTIFY_INSTANCES);
41}
42
43static inline struct ucounts *inc_inotify_watches(struct ucounts *ucounts)
44{
45 return inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_INOTIFY_WATCHES);
46}
47
48static inline void dec_inotify_watches(struct ucounts *ucounts)
49{
50 dec_ucount(ucounts, UCOUNT_INOTIFY_WATCHES);
51}
52#endif