diff options
Diffstat (limited to 'include/linux/inotify.h')
-rw-r--r-- | include/linux/inotify.h | 185 |
1 files changed, 13 insertions, 172 deletions
diff --git a/include/linux/inotify.h b/include/linux/inotify.h index 37ea2894b3c0..d33041e2a42a 100644 --- a/include/linux/inotify.h +++ b/include/linux/inotify.h | |||
@@ -51,6 +51,7 @@ struct inotify_event { | |||
51 | /* special flags */ | 51 | /* special flags */ |
52 | #define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */ | 52 | #define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */ |
53 | #define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */ | 53 | #define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */ |
54 | #define IN_EXCL_UNLINK 0x04000000 /* exclude events on unlinked objects */ | ||
54 | #define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */ | 55 | #define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */ |
55 | #define IN_ISDIR 0x40000000 /* event occurred against dir */ | 56 | #define IN_ISDIR 0x40000000 /* event occurred against dir */ |
56 | #define IN_ONESHOT 0x80000000 /* only send event once */ | 57 | #define IN_ONESHOT 0x80000000 /* only send event once */ |
@@ -70,177 +71,17 @@ struct inotify_event { | |||
70 | #define IN_NONBLOCK O_NONBLOCK | 71 | #define IN_NONBLOCK O_NONBLOCK |
71 | 72 | ||
72 | #ifdef __KERNEL__ | 73 | #ifdef __KERNEL__ |
73 | 74 | #include <linux/sysctl.h> | |
74 | #include <linux/dcache.h> | 75 | extern struct ctl_table inotify_table[]; /* for sysctl */ |
75 | #include <linux/fs.h> | 76 | |
76 | 77 | #define ALL_INOTIFY_BITS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ | |
77 | /* | 78 | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ |
78 | * struct inotify_watch - represents a watch request on a specific inode | 79 | IN_MOVED_TO | IN_CREATE | IN_DELETE | \ |
79 | * | 80 | IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT | \ |
80 | * h_list is protected by ih->mutex of the associated inotify_handle. | 81 | IN_Q_OVERFLOW | IN_IGNORED | IN_ONLYDIR | \ |
81 | * i_list, mask are protected by inode->inotify_mutex of the associated inode. | 82 | IN_DONT_FOLLOW | IN_EXCL_UNLINK | IN_MASK_ADD | \ |
82 | * ih, inode, and wd are never written to once the watch is created. | 83 | IN_ISDIR | IN_ONESHOT) |
83 | * | 84 | |
84 | * Callers must use the established inotify interfaces to access inotify_watch | 85 | #endif |
85 | * contents. The content of this structure is private to the inotify | ||
86 | * implementation. | ||
87 | */ | ||
88 | struct inotify_watch { | ||
89 | struct list_head h_list; /* entry in inotify_handle's list */ | ||
90 | struct list_head i_list; /* entry in inode's list */ | ||
91 | atomic_t count; /* reference count */ | ||
92 | struct inotify_handle *ih; /* associated inotify handle */ | ||
93 | struct inode *inode; /* associated inode */ | ||
94 | __s32 wd; /* watch descriptor */ | ||
95 | __u32 mask; /* event mask for this watch */ | ||
96 | }; | ||
97 | |||
98 | struct inotify_operations { | ||
99 | void (*handle_event)(struct inotify_watch *, u32, u32, u32, | ||
100 | const char *, struct inode *); | ||
101 | void (*destroy_watch)(struct inotify_watch *); | ||
102 | }; | ||
103 | |||
104 | #ifdef CONFIG_INOTIFY | ||
105 | |||
106 | /* Kernel API for producing events */ | ||
107 | |||
108 | extern void inotify_d_instantiate(struct dentry *, struct inode *); | ||
109 | extern void inotify_d_move(struct dentry *); | ||
110 | extern void inotify_inode_queue_event(struct inode *, __u32, __u32, | ||
111 | const char *, struct inode *); | ||
112 | extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32, | ||
113 | const char *); | ||
114 | extern void inotify_unmount_inodes(struct list_head *); | ||
115 | extern void inotify_inode_is_dead(struct inode *); | ||
116 | extern u32 inotify_get_cookie(void); | ||
117 | |||
118 | /* Kernel Consumer API */ | ||
119 | |||
120 | extern struct inotify_handle *inotify_init(const struct inotify_operations *); | ||
121 | extern void inotify_init_watch(struct inotify_watch *); | ||
122 | extern void inotify_destroy(struct inotify_handle *); | ||
123 | extern __s32 inotify_find_watch(struct inotify_handle *, struct inode *, | ||
124 | struct inotify_watch **); | ||
125 | extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *, | ||
126 | u32); | ||
127 | extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *, | ||
128 | struct inode *, __u32); | ||
129 | extern __s32 inotify_clone_watch(struct inotify_watch *, struct inotify_watch *); | ||
130 | extern void inotify_evict_watch(struct inotify_watch *); | ||
131 | extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *); | ||
132 | extern int inotify_rm_wd(struct inotify_handle *, __u32); | ||
133 | extern void inotify_remove_watch_locked(struct inotify_handle *, | ||
134 | struct inotify_watch *); | ||
135 | extern void get_inotify_watch(struct inotify_watch *); | ||
136 | extern void put_inotify_watch(struct inotify_watch *); | ||
137 | extern int pin_inotify_watch(struct inotify_watch *); | ||
138 | extern void unpin_inotify_watch(struct inotify_watch *); | ||
139 | |||
140 | #else | ||
141 | |||
142 | static inline void inotify_d_instantiate(struct dentry *dentry, | ||
143 | struct inode *inode) | ||
144 | { | ||
145 | } | ||
146 | |||
147 | static inline void inotify_d_move(struct dentry *dentry) | ||
148 | { | ||
149 | } | ||
150 | |||
151 | static inline void inotify_inode_queue_event(struct inode *inode, | ||
152 | __u32 mask, __u32 cookie, | ||
153 | const char *filename, | ||
154 | struct inode *n_inode) | ||
155 | { | ||
156 | } | ||
157 | |||
158 | static inline void inotify_dentry_parent_queue_event(struct dentry *dentry, | ||
159 | __u32 mask, __u32 cookie, | ||
160 | const char *filename) | ||
161 | { | ||
162 | } | ||
163 | |||
164 | static inline void inotify_unmount_inodes(struct list_head *list) | ||
165 | { | ||
166 | } | ||
167 | |||
168 | static inline void inotify_inode_is_dead(struct inode *inode) | ||
169 | { | ||
170 | } | ||
171 | |||
172 | static inline u32 inotify_get_cookie(void) | ||
173 | { | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | static inline struct inotify_handle *inotify_init(const struct inotify_operations *ops) | ||
178 | { | ||
179 | return ERR_PTR(-EOPNOTSUPP); | ||
180 | } | ||
181 | |||
182 | static inline void inotify_init_watch(struct inotify_watch *watch) | ||
183 | { | ||
184 | } | ||
185 | |||
186 | static inline void inotify_destroy(struct inotify_handle *ih) | ||
187 | { | ||
188 | } | ||
189 | |||
190 | static inline __s32 inotify_find_watch(struct inotify_handle *ih, struct inode *inode, | ||
191 | struct inotify_watch **watchp) | ||
192 | { | ||
193 | return -EOPNOTSUPP; | ||
194 | } | ||
195 | |||
196 | static inline __s32 inotify_find_update_watch(struct inotify_handle *ih, | ||
197 | struct inode *inode, u32 mask) | ||
198 | { | ||
199 | return -EOPNOTSUPP; | ||
200 | } | ||
201 | |||
202 | static inline __s32 inotify_add_watch(struct inotify_handle *ih, | ||
203 | struct inotify_watch *watch, | ||
204 | struct inode *inode, __u32 mask) | ||
205 | { | ||
206 | return -EOPNOTSUPP; | ||
207 | } | ||
208 | |||
209 | static inline int inotify_rm_watch(struct inotify_handle *ih, | ||
210 | struct inotify_watch *watch) | ||
211 | { | ||
212 | return -EOPNOTSUPP; | ||
213 | } | ||
214 | |||
215 | static inline int inotify_rm_wd(struct inotify_handle *ih, __u32 wd) | ||
216 | { | ||
217 | return -EOPNOTSUPP; | ||
218 | } | ||
219 | |||
220 | static inline void inotify_remove_watch_locked(struct inotify_handle *ih, | ||
221 | struct inotify_watch *watch) | ||
222 | { | ||
223 | } | ||
224 | |||
225 | static inline void get_inotify_watch(struct inotify_watch *watch) | ||
226 | { | ||
227 | } | ||
228 | |||
229 | static inline void put_inotify_watch(struct inotify_watch *watch) | ||
230 | { | ||
231 | } | ||
232 | |||
233 | extern inline int pin_inotify_watch(struct inotify_watch *watch) | ||
234 | { | ||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | extern inline void unpin_inotify_watch(struct inotify_watch *watch) | ||
239 | { | ||
240 | } | ||
241 | |||
242 | #endif /* CONFIG_INOTIFY */ | ||
243 | |||
244 | #endif /* __KERNEL __ */ | ||
245 | 86 | ||
246 | #endif /* _LINUX_INOTIFY_H */ | 87 | #endif /* _LINUX_INOTIFY_H */ |