xref: /OK3568_Linux_fs/kernel/fs/notify/fsnotify.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __FS_NOTIFY_FSNOTIFY_H_
3*4882a593Smuzhiyun #define __FS_NOTIFY_FSNOTIFY_H_
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/list.h>
6*4882a593Smuzhiyun #include <linux/fsnotify.h>
7*4882a593Smuzhiyun #include <linux/srcu.h>
8*4882a593Smuzhiyun #include <linux/types.h>
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include "../mount.h"
11*4882a593Smuzhiyun 
fsnotify_conn_inode(struct fsnotify_mark_connector * conn)12*4882a593Smuzhiyun static inline struct inode *fsnotify_conn_inode(
13*4882a593Smuzhiyun 				struct fsnotify_mark_connector *conn)
14*4882a593Smuzhiyun {
15*4882a593Smuzhiyun 	return container_of(conn->obj, struct inode, i_fsnotify_marks);
16*4882a593Smuzhiyun }
17*4882a593Smuzhiyun 
fsnotify_conn_mount(struct fsnotify_mark_connector * conn)18*4882a593Smuzhiyun static inline struct mount *fsnotify_conn_mount(
19*4882a593Smuzhiyun 				struct fsnotify_mark_connector *conn)
20*4882a593Smuzhiyun {
21*4882a593Smuzhiyun 	return container_of(conn->obj, struct mount, mnt_fsnotify_marks);
22*4882a593Smuzhiyun }
23*4882a593Smuzhiyun 
fsnotify_conn_sb(struct fsnotify_mark_connector * conn)24*4882a593Smuzhiyun static inline struct super_block *fsnotify_conn_sb(
25*4882a593Smuzhiyun 				struct fsnotify_mark_connector *conn)
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun 	return container_of(conn->obj, struct super_block, s_fsnotify_marks);
28*4882a593Smuzhiyun }
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun /* destroy all events sitting in this groups notification queue */
31*4882a593Smuzhiyun extern void fsnotify_flush_notify(struct fsnotify_group *group);
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /* protects reads of inode and vfsmount marks list */
34*4882a593Smuzhiyun extern struct srcu_struct fsnotify_mark_srcu;
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun /* compare two groups for sorting of marks lists */
37*4882a593Smuzhiyun extern int fsnotify_compare_groups(struct fsnotify_group *a,
38*4882a593Smuzhiyun 				   struct fsnotify_group *b);
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun /* Destroy all marks attached to an object via connector */
41*4882a593Smuzhiyun extern void fsnotify_destroy_marks(fsnotify_connp_t *connp);
42*4882a593Smuzhiyun /* run the list of all marks associated with inode and destroy them */
fsnotify_clear_marks_by_inode(struct inode * inode)43*4882a593Smuzhiyun static inline void fsnotify_clear_marks_by_inode(struct inode *inode)
44*4882a593Smuzhiyun {
45*4882a593Smuzhiyun 	fsnotify_destroy_marks(&inode->i_fsnotify_marks);
46*4882a593Smuzhiyun }
47*4882a593Smuzhiyun /* run the list of all marks associated with vfsmount and destroy them */
fsnotify_clear_marks_by_mount(struct vfsmount * mnt)48*4882a593Smuzhiyun static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
49*4882a593Smuzhiyun {
50*4882a593Smuzhiyun 	fsnotify_destroy_marks(&real_mount(mnt)->mnt_fsnotify_marks);
51*4882a593Smuzhiyun }
52*4882a593Smuzhiyun /* run the list of all marks associated with sb and destroy them */
fsnotify_clear_marks_by_sb(struct super_block * sb)53*4882a593Smuzhiyun static inline void fsnotify_clear_marks_by_sb(struct super_block *sb)
54*4882a593Smuzhiyun {
55*4882a593Smuzhiyun 	fsnotify_destroy_marks(&sb->s_fsnotify_marks);
56*4882a593Smuzhiyun }
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun /*
59*4882a593Smuzhiyun  * update the dentry->d_flags of all of inode's children to indicate if inode cares
60*4882a593Smuzhiyun  * about events that happen to its children.
61*4882a593Smuzhiyun  */
62*4882a593Smuzhiyun extern void __fsnotify_update_child_dentry_flags(struct inode *inode);
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun /* allocate and destroy and event holder to attach events to notification/access queues */
65*4882a593Smuzhiyun extern struct fsnotify_event_holder *fsnotify_alloc_event_holder(void);
66*4882a593Smuzhiyun extern void fsnotify_destroy_event_holder(struct fsnotify_event_holder *holder);
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun extern struct kmem_cache *fsnotify_mark_connector_cachep;
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun #endif	/* __FS_NOTIFY_FSNOTIFY_H_ */
71