7 #ifndef __LINUX_FSNOTIFY_BACKEND_H
8 #define __LINUX_FSNOTIFY_BACKEND_H
14 #include <linux/list.h>
17 #include <linux/types.h>
27 #define FS_ACCESS 0x00000001
28 #define FS_MODIFY 0x00000002
29 #define FS_ATTRIB 0x00000004
30 #define FS_CLOSE_WRITE 0x00000008
31 #define FS_CLOSE_NOWRITE 0x00000010
32 #define FS_OPEN 0x00000020
33 #define FS_MOVED_FROM 0x00000040
34 #define FS_MOVED_TO 0x00000080
35 #define FS_CREATE 0x00000100
36 #define FS_DELETE 0x00000200
37 #define FS_DELETE_SELF 0x00000400
38 #define FS_MOVE_SELF 0x00000800
40 #define FS_UNMOUNT 0x00002000
41 #define FS_Q_OVERFLOW 0x00004000
42 #define FS_IN_IGNORED 0x00008000
44 #define FS_OPEN_PERM 0x00010000
45 #define FS_ACCESS_PERM 0x00020000
47 #define FS_EXCL_UNLINK 0x04000000
48 #define FS_ISDIR 0x40000000
49 #define FS_IN_ONESHOT 0x80000000
51 #define FS_DN_RENAME 0x10000000
52 #define FS_DN_MULTISHOT 0x20000000
56 #define FS_EVENT_ON_CHILD 0x08000000
60 #define FS_EVENTS_POSS_ON_CHILD (FS_ACCESS | FS_MODIFY | FS_ATTRIB |\
61 FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN |\
62 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\
63 FS_DELETE | FS_OPEN_PERM | FS_ACCESS_PERM)
65 #define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO)
67 #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM)
69 #define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \
70 FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \
71 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \
72 FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \
73 FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \
74 FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \
75 FS_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \
76 FS_DN_MULTISHOT | FS_EVENT_ON_CHILD)
78 struct fsnotify_group;
79 struct fsnotify_event;
81 struct fsnotify_event_private_data;
97 struct fsnotify_mark *inode_mark,
98 struct fsnotify_mark *vfsmount_mark,
100 int (*handle_event)(
struct fsnotify_group *
group,
101 struct fsnotify_mark *inode_mark,
102 struct fsnotify_mark *vfsmount_mark,
103 struct fsnotify_event *
event);
104 void (*free_group_priv)(
struct fsnotify_group *
group);
105 void (*freeing_mark)(
struct fsnotify_mark *
mark,
struct fsnotify_group *
group);
106 void (*free_event_priv)(
struct fsnotify_event_private_data *
priv);
115 struct fsnotify_group {
126 const struct fsnotify_ops *
ops;
129 struct mutex notification_mutex;
133 unsigned int max_events;
153 #ifdef CONFIG_INOTIFY_USER
154 struct inotify_group_private_data {
162 #ifdef CONFIG_FANOTIFY
163 struct fanotify_group_private_data {
164 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
166 struct mutex access_mutex;
172 unsigned int max_marks;
189 struct fsnotify_event_holder {
190 struct fsnotify_event *
event;
198 struct fsnotify_event_private_data {
199 struct fsnotify_group *
group;
208 struct fsnotify_event {
214 struct fsnotify_event_holder holder;
217 struct inode *to_tell;
231 #define FSNOTIFY_EVENT_NONE 0
232 #define FSNOTIFY_EVENT_PATH 1
233 #define FSNOTIFY_EVENT_INODE 2
243 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
253 struct fsnotify_inode_mark {
262 struct fsnotify_vfsmount_mark {
278 struct fsnotify_mark {
283 struct fsnotify_group *
group;
287 struct fsnotify_inode_mark
i;
288 struct fsnotify_vfsmount_mark
m;
292 #define FSNOTIFY_MARK_FLAG_INODE 0x01
293 #define FSNOTIFY_MARK_FLAG_VFSMOUNT 0x02
294 #define FSNOTIFY_MARK_FLAG_OBJECT_PINNED 0x04
295 #define FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY 0x08
296 #define FSNOTIFY_MARK_FLAG_ALIVE 0x10
299 void (*free_mark)(
struct fsnotify_mark *
mark);
302 #ifdef CONFIG_FSNOTIFY
314 static inline int fsnotify_inode_watches_children(
struct inode *
inode)
317 if (!(inode->i_fsnotify_mask & FS_EVENT_ON_CHILD))
321 return inode->i_fsnotify_mask & FS_EVENTS_POSS_ON_CHILD;
328 static inline void __fsnotify_update_dcache_flags(
struct dentry *
dentry)
342 if (parent->
d_inode && fsnotify_inode_watches_children(parent->
d_inode))
351 static inline void __fsnotify_d_instantiate(
struct dentry *dentry,
struct inode *inode)
356 spin_lock(&dentry->
d_lock);
357 __fsnotify_update_dcache_flags(dentry);
358 spin_unlock(&dentry->
d_lock);
373 struct fsnotify_event *
event);
377 struct fsnotify_event *
event,
378 struct fsnotify_event_private_data *
priv,
379 struct fsnotify_event *(*merge)(
struct list_head *,
380 struct fsnotify_event *));
394 extern void fsnotify_init_mark(
struct fsnotify_mark *
mark,
void (*free_mark)(
struct fsnotify_mark *mark));
406 extern int fsnotify_add_mark(
struct fsnotify_mark *mark,
struct fsnotify_group *group,
407 struct inode *inode,
struct vfsmount *mnt,
int allow_dups);
424 void *
data,
int data_is,
425 const unsigned char *
name,
431 struct fsnotify_event *new_event);
452 static inline void __fsnotify_update_dcache_flags(
struct dentry *dentry)
455 static inline void __fsnotify_d_instantiate(
struct dentry *dentry,
struct inode *inode)