blob: 2007e371191600690306c0dbfa572cde6fcf2854 [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;
Amir Goldsteina0a92d22019-01-10 19:04:31 +02008 u32 mask;
Eric Paris63c882a2009-05-21 17:02:01 -04009 int wd;
Jan Kara7053aee2014-01-21 15:48:14 -080010 u32 sync_cookie;
11 int name_len;
12 char name[];
Eric Paris63c882a2009-05-21 17:02:01 -040013};
14
Eric Paris000285d2009-12-17 21:24:24 -050015struct inotify_inode_mark {
16 struct fsnotify_mark fsn_mark;
Eric Paris63c882a2009-05-21 17:02:01 -040017 int wd;
18};
19
Jan Kara7053aee2014-01-21 15:48:14 -080020static 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 Paris000285d2009-12-17 21:24:24 -050025extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
Eric Paris528da3e2009-06-12 16:04:26 -040026 struct fsnotify_group *group);
Amir Goldstein1a2620a2020-12-02 14:07:08 +020027extern 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 Paris63c882a2009-05-21 17:02:01 -040031
32extern const struct fsnotify_ops inotify_fsnotify_ops;
Jan Kara054c6362016-12-21 18:06:12 +010033extern struct kmem_cache *inotify_inode_mark_cachep;
Nikolay Borisov1cce1ee2016-12-14 15:56:33 +020034
35#ifdef CONFIG_INOTIFY_USER
36static inline void dec_inotify_instances(struct ucounts *ucounts)
37{
38 dec_ucount(ucounts, UCOUNT_INOTIFY_INSTANCES);
39}
40
41static inline struct ucounts *inc_inotify_watches(struct ucounts *ucounts)
42{
43 return inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_INOTIFY_WATCHES);
44}
45
46static inline void dec_inotify_watches(struct ucounts *ucounts)
47{
48 dec_ucount(ucounts, UCOUNT_INOTIFY_WATCHES);
49}
50#endif