diff options
Diffstat (limited to 'include/linux/fsnotify_backend.h')
-rw-r--r-- | include/linux/fsnotify_backend.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index cad5c4d75c1d..13d2dd570049 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -46,6 +46,17 @@ | |||
46 | #define FS_DN_RENAME 0x10000000 /* file renamed */ | 46 | #define FS_DN_RENAME 0x10000000 /* file renamed */ |
47 | #define FS_DN_MULTISHOT 0x20000000 /* dnotify multishot */ | 47 | #define FS_DN_MULTISHOT 0x20000000 /* dnotify multishot */ |
48 | 48 | ||
49 | /* This inode cares about things that happen to its children. Always set for | ||
50 | * dnotify and inotify. */ | ||
51 | #define FS_EVENT_ON_CHILD 0x08000000 | ||
52 | |||
53 | /* This is a list of all events that may get sent to a parernt based on fs event | ||
54 | * happening to inodes inside that directory */ | ||
55 | #define FS_EVENTS_POSS_ON_CHILD (FS_ACCESS | FS_MODIFY | FS_ATTRIB |\ | ||
56 | FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN |\ | ||
57 | FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\ | ||
58 | FS_DELETE) | ||
59 | |||
49 | struct fsnotify_group; | 60 | struct fsnotify_group; |
50 | struct fsnotify_event; | 61 | struct fsnotify_event; |
51 | struct fsnotify_mark_entry; | 62 | struct fsnotify_mark_entry; |
@@ -183,8 +194,52 @@ struct fsnotify_mark_entry { | |||
183 | 194 | ||
184 | /* main fsnotify call to send events */ | 195 | /* main fsnotify call to send events */ |
185 | extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is); | 196 | extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is); |
197 | extern void __fsnotify_parent(struct dentry *dentry, __u32 mask); | ||
186 | extern void __fsnotify_inode_delete(struct inode *inode); | 198 | extern void __fsnotify_inode_delete(struct inode *inode); |
187 | 199 | ||
200 | static inline int fsnotify_inode_watches_children(struct inode *inode) | ||
201 | { | ||
202 | /* FS_EVENT_ON_CHILD is set if the inode may care */ | ||
203 | if (!(inode->i_fsnotify_mask & FS_EVENT_ON_CHILD)) | ||
204 | return 0; | ||
205 | /* this inode might care about child events, does it care about the | ||
206 | * specific set of events that can happen on a child? */ | ||
207 | return inode->i_fsnotify_mask & FS_EVENTS_POSS_ON_CHILD; | ||
208 | } | ||
209 | |||
210 | /* | ||
211 | * Update the dentry with a flag indicating the interest of its parent to receive | ||
212 | * filesystem events when those events happens to this dentry->d_inode. | ||
213 | */ | ||
214 | static inline void __fsnotify_update_dcache_flags(struct dentry *dentry) | ||
215 | { | ||
216 | struct dentry *parent; | ||
217 | |||
218 | assert_spin_locked(&dcache_lock); | ||
219 | assert_spin_locked(&dentry->d_lock); | ||
220 | |||
221 | parent = dentry->d_parent; | ||
222 | if (fsnotify_inode_watches_children(parent->d_inode)) | ||
223 | dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED; | ||
224 | else | ||
225 | dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED; | ||
226 | } | ||
227 | |||
228 | /* | ||
229 | * fsnotify_d_instantiate - instantiate a dentry for inode | ||
230 | * Called with dcache_lock held. | ||
231 | */ | ||
232 | static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode *inode) | ||
233 | { | ||
234 | if (!inode) | ||
235 | return; | ||
236 | |||
237 | assert_spin_locked(&dcache_lock); | ||
238 | |||
239 | spin_lock(&dentry->d_lock); | ||
240 | __fsnotify_update_dcache_flags(dentry); | ||
241 | spin_unlock(&dentry->d_lock); | ||
242 | } | ||
188 | 243 | ||
189 | /* called from fsnotify listeners, such as fanotify or dnotify */ | 244 | /* called from fsnotify listeners, such as fanotify or dnotify */ |
190 | 245 | ||
@@ -230,9 +285,18 @@ extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 | |||
230 | static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is) | 285 | static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is) |
231 | {} | 286 | {} |
232 | 287 | ||
288 | static inline void __fsnotify_parent(struct dentry *dentry, __u32 mask) | ||
289 | {} | ||
290 | |||
233 | static inline void __fsnotify_inode_delete(struct inode *inode) | 291 | static inline void __fsnotify_inode_delete(struct inode *inode) |
234 | {} | 292 | {} |
235 | 293 | ||
294 | static inline void __fsnotify_update_dcache_flags(struct dentry *dentry) | ||
295 | {} | ||
296 | |||
297 | static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode *inode) | ||
298 | {} | ||
299 | |||
236 | #endif /* CONFIG_FSNOTIFY */ | 300 | #endif /* CONFIG_FSNOTIFY */ |
237 | 301 | ||
238 | #endif /* __KERNEL __ */ | 302 | #endif /* __KERNEL __ */ |