@@ -135,13 +135,12 @@ void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
135135}
136136EXPORT_SYMBOL_GPL (__fsnotify_parent );
137137
138- static void send_to_group (__u32 mask ,
139- struct fsnotify_group * group ,
140- void * data , int data_is , const char * file_name ,
141- u32 cookie , struct fsnotify_event * * event ,
142- struct inode * to_tell )
138+ static void send_to_group (struct fsnotify_group * group , struct inode * to_tell ,
139+ struct vfsmount * mnt , __u32 mask , void * data ,
140+ int data_is , u32 cookie , const char * file_name ,
141+ struct fsnotify_event * * event )
143142{
144- if (!group -> ops -> should_send_event (group , to_tell , mask ,
143+ if (!group -> ops -> should_send_event (group , to_tell , mnt , mask ,
145144 data , data_is ))
146145 return ;
147146 if (!* event ) {
@@ -159,15 +158,9 @@ static void send_to_group(__u32 mask,
159158 group -> ops -> handle_event (group , * event );
160159}
161160
162- static bool needed_by_vfsmount (__u32 test_mask , void * data , int data_is )
161+ static bool needed_by_vfsmount (__u32 test_mask , struct vfsmount * mnt )
163162{
164- struct path * path ;
165-
166- if (data_is == FSNOTIFY_EVENT_PATH )
167- path = (struct path * )data ;
168- else if (data_is == FSNOTIFY_EVENT_FILE )
169- path = & ((struct file * )data )-> f_path ;
170- else
163+ if (!mnt )
171164 return false;
172165
173166 /* hook in this when mnt->mnt_fsnotify_mask is defined */
@@ -184,6 +177,7 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
184177{
185178 struct fsnotify_group * group ;
186179 struct fsnotify_event * event = NULL ;
180+ struct vfsmount * mnt = NULL ;
187181 int idx ;
188182 /* global tests shouldn't care about events on child only the specific event */
189183 __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD );
@@ -198,10 +192,15 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
198192 !(test_mask & fsnotify_vfsmount_mask ))
199193 return ;
200194
195+ if (data_is == FSNOTIFY_EVENT_PATH )
196+ mnt = ((struct path * )data )-> mnt ;
197+ else if (data_is == FSNOTIFY_EVENT_FILE )
198+ mnt = ((struct file * )data )-> f_path .mnt ;
199+
201200 /* if this inode's directed listeners don't care and nothing on the vfsmount
202201 * listeners list cares, nothing to do */
203202 if (!(test_mask & to_tell -> i_fsnotify_mask ) &&
204- !needed_by_vfsmount (test_mask , data , data_is ))
203+ !needed_by_vfsmount (test_mask , mnt ))
205204 return ;
206205
207206 /*
@@ -214,16 +213,16 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
214213 if (test_mask & to_tell -> i_fsnotify_mask ) {
215214 list_for_each_entry_rcu (group , & fsnotify_inode_groups , inode_group_list ) {
216215 if (test_mask & group -> mask ) {
217- send_to_group (mask , group , data , data_is ,
218- file_name , cookie , & event , to_tell );
216+ send_to_group (group , to_tell , NULL , mask , data , data_is ,
217+ cookie , file_name , & event );
219218 }
220219 }
221220 }
222- if (needed_by_vfsmount (test_mask , data , data_is )) {
221+ if (needed_by_vfsmount (test_mask , mnt )) {
223222 list_for_each_entry_rcu (group , & fsnotify_vfsmount_groups , vfsmount_group_list ) {
224223 if (test_mask & group -> mask ) {
225- send_to_group (mask , group , data , data_is ,
226- file_name , cookie , & event , to_tell );
224+ send_to_group (group , to_tell , mnt , mask , data , data_is ,
225+ cookie , file_name , & event );
227226 }
228227 }
229228 }
0 commit comments