diff options
Diffstat (limited to 'include/linux/fsnotify.h')
-rw-r--r-- | include/linux/fsnotify.h | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 01755909ce81..59d0df43ff9d 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
@@ -11,8 +11,6 @@ | |||
11 | * (C) Copyright 2005 Robert Love | 11 | * (C) Copyright 2005 Robert Love |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/dnotify.h> | ||
15 | #include <linux/inotify.h> | ||
16 | #include <linux/fsnotify_backend.h> | 14 | #include <linux/fsnotify_backend.h> |
17 | #include <linux/audit.h> | 15 | #include <linux/audit.h> |
18 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
@@ -21,35 +19,53 @@ | |||
21 | * fsnotify_d_instantiate - instantiate a dentry for inode | 19 | * fsnotify_d_instantiate - instantiate a dentry for inode |
22 | * Called with dcache_lock held. | 20 | * Called with dcache_lock held. |
23 | */ | 21 | */ |
24 | static inline void fsnotify_d_instantiate(struct dentry *entry, | 22 | static inline void fsnotify_d_instantiate(struct dentry *dentry, |
25 | struct inode *inode) | 23 | struct inode *inode) |
26 | { | 24 | { |
27 | __fsnotify_d_instantiate(entry, inode); | 25 | __fsnotify_d_instantiate(dentry, inode); |
28 | |||
29 | inotify_d_instantiate(entry, inode); | ||
30 | } | 26 | } |
31 | 27 | ||
32 | /* Notify this dentry's parent about a child's events. */ | 28 | /* Notify this dentry's parent about a child's events. */ |
33 | static inline void fsnotify_parent(struct dentry *dentry, __u32 mask) | 29 | static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) |
34 | { | 30 | { |
35 | __fsnotify_parent(dentry, mask); | 31 | if (!dentry) |
32 | dentry = path->dentry; | ||
33 | |||
34 | __fsnotify_parent(path, dentry, mask); | ||
35 | } | ||
36 | 36 | ||
37 | inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); | 37 | /* simple call site for access decisions */ |
38 | static inline int fsnotify_perm(struct file *file, int mask) | ||
39 | { | ||
40 | struct path *path = &file->f_path; | ||
41 | struct inode *inode = path->dentry->d_inode; | ||
42 | __u32 fsnotify_mask = 0; | ||
43 | |||
44 | if (file->f_mode & FMODE_NONOTIFY) | ||
45 | return 0; | ||
46 | if (!(mask & (MAY_READ | MAY_OPEN))) | ||
47 | return 0; | ||
48 | if (mask & MAY_OPEN) | ||
49 | fsnotify_mask = FS_OPEN_PERM; | ||
50 | else if (mask & MAY_READ) | ||
51 | fsnotify_mask = FS_ACCESS_PERM; | ||
52 | else | ||
53 | BUG(); | ||
54 | |||
55 | return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); | ||
38 | } | 56 | } |
39 | 57 | ||
40 | /* | 58 | /* |
41 | * fsnotify_d_move - entry has been moved | 59 | * fsnotify_d_move - dentry has been moved |
42 | * Called with dcache_lock and entry->d_lock held. | 60 | * Called with dcache_lock and dentry->d_lock held. |
43 | */ | 61 | */ |
44 | static inline void fsnotify_d_move(struct dentry *entry) | 62 | static inline void fsnotify_d_move(struct dentry *dentry) |
45 | { | 63 | { |
46 | /* | 64 | /* |
47 | * On move we need to update entry->d_flags to indicate if the new parent | 65 | * On move we need to update dentry->d_flags to indicate if the new parent |
48 | * cares about events from this entry. | 66 | * cares about events from this dentry. |
49 | */ | 67 | */ |
50 | __fsnotify_update_dcache_flags(entry); | 68 | __fsnotify_update_dcache_flags(dentry); |
51 | |||
52 | inotify_d_move(entry); | ||
53 | } | 69 | } |
54 | 70 | ||
55 | /* | 71 | /* |
@@ -57,8 +73,6 @@ static inline void fsnotify_d_move(struct dentry *entry) | |||
57 | */ | 73 | */ |
58 | static inline void fsnotify_link_count(struct inode *inode) | 74 | static inline void fsnotify_link_count(struct inode *inode) |
59 | { | 75 | { |
60 | inotify_inode_queue_event(inode, IN_ATTRIB, 0, NULL, NULL); | ||
61 | |||
62 | fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 76 | fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
63 | } | 77 | } |
64 | 78 | ||
@@ -66,45 +80,31 @@ static inline void fsnotify_link_count(struct inode *inode) | |||
66 | * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir | 80 | * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir |
67 | */ | 81 | */ |
68 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | 82 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, |
69 | const char *old_name, | 83 | const unsigned char *old_name, |
70 | int isdir, struct inode *target, struct dentry *moved) | 84 | int isdir, struct inode *target, struct dentry *moved) |
71 | { | 85 | { |
72 | struct inode *source = moved->d_inode; | 86 | struct inode *source = moved->d_inode; |
73 | u32 in_cookie = inotify_get_cookie(); | ||
74 | u32 fs_cookie = fsnotify_get_cookie(); | 87 | u32 fs_cookie = fsnotify_get_cookie(); |
75 | __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); | 88 | __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); |
76 | __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); | 89 | __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); |
77 | const char *new_name = moved->d_name.name; | 90 | const unsigned char *new_name = moved->d_name.name; |
78 | 91 | ||
79 | if (old_dir == new_dir) | 92 | if (old_dir == new_dir) |
80 | old_dir_mask |= FS_DN_RENAME; | 93 | old_dir_mask |= FS_DN_RENAME; |
81 | 94 | ||
82 | if (isdir) { | 95 | if (isdir) { |
83 | isdir = IN_ISDIR; | ||
84 | old_dir_mask |= FS_IN_ISDIR; | 96 | old_dir_mask |= FS_IN_ISDIR; |
85 | new_dir_mask |= FS_IN_ISDIR; | 97 | new_dir_mask |= FS_IN_ISDIR; |
86 | } | 98 | } |
87 | 99 | ||
88 | inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir, in_cookie, old_name, | ||
89 | source); | ||
90 | inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, in_cookie, new_name, | ||
91 | source); | ||
92 | |||
93 | fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); | 100 | fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); |
94 | fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE, new_name, fs_cookie); | 101 | fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE, new_name, fs_cookie); |
95 | 102 | ||
96 | if (target) { | 103 | if (target) |
97 | inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL); | ||
98 | inotify_inode_is_dead(target); | ||
99 | |||
100 | /* this is really a link_count change not a removal */ | ||
101 | fsnotify_link_count(target); | 104 | fsnotify_link_count(target); |
102 | } | ||
103 | 105 | ||
104 | if (source) { | 106 | if (source) |
105 | inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL); | ||
106 | fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 107 | fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
107 | } | ||
108 | audit_inode_child(moved, new_dir); | 108 | audit_inode_child(moved, new_dir); |
109 | } | 109 | } |
110 | 110 | ||
@@ -117,6 +117,14 @@ static inline void fsnotify_inode_delete(struct inode *inode) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * fsnotify_vfsmount_delete - a vfsmount is being destroyed, clean up is needed | ||
121 | */ | ||
122 | static inline void fsnotify_vfsmount_delete(struct vfsmount *mnt) | ||
123 | { | ||
124 | __fsnotify_vfsmount_delete(mnt); | ||
125 | } | ||
126 | |||
127 | /* | ||
120 | * fsnotify_nameremove - a filename was removed from a directory | 128 | * fsnotify_nameremove - a filename was removed from a directory |
121 | */ | 129 | */ |
122 | static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) | 130 | static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) |
@@ -126,7 +134,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) | |||
126 | if (isdir) | 134 | if (isdir) |
127 | mask |= FS_IN_ISDIR; | 135 | mask |= FS_IN_ISDIR; |
128 | 136 | ||
129 | fsnotify_parent(dentry, mask); | 137 | fsnotify_parent(NULL, dentry, mask); |
130 | } | 138 | } |
131 | 139 | ||
132 | /* | 140 | /* |
@@ -134,9 +142,6 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) | |||
134 | */ | 142 | */ |
135 | static inline void fsnotify_inoderemove(struct inode *inode) | 143 | static inline void fsnotify_inoderemove(struct inode *inode) |
136 | { | 144 | { |
137 | inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL); | ||
138 | inotify_inode_is_dead(inode); | ||
139 | |||
140 | fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 145 | fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
141 | __fsnotify_inode_delete(inode); | 146 | __fsnotify_inode_delete(inode); |
142 | } | 147 | } |
@@ -146,8 +151,6 @@ static inline void fsnotify_inoderemove(struct inode *inode) | |||
146 | */ | 151 | */ |
147 | static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) | 152 | static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) |
148 | { | 153 | { |
149 | inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name, | ||
150 | dentry->d_inode); | ||
151 | audit_inode_child(dentry, inode); | 154 | audit_inode_child(dentry, inode); |
152 | 155 | ||
153 | fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); | 156 | fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); |
@@ -160,8 +163,6 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) | |||
160 | */ | 163 | */ |
161 | static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry) | 164 | static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry) |
162 | { | 165 | { |
163 | inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name, | ||
164 | inode); | ||
165 | fsnotify_link_count(inode); | 166 | fsnotify_link_count(inode); |
166 | audit_inode_child(new_dentry, dir); | 167 | audit_inode_child(new_dentry, dir); |
167 | 168 | ||
@@ -176,7 +177,6 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) | |||
176 | __u32 mask = (FS_CREATE | FS_IN_ISDIR); | 177 | __u32 mask = (FS_CREATE | FS_IN_ISDIR); |
177 | struct inode *d_inode = dentry->d_inode; | 178 | struct inode *d_inode = dentry->d_inode; |
178 | 179 | ||
179 | inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode); | ||
180 | audit_inode_child(dentry, inode); | 180 | audit_inode_child(dentry, inode); |
181 | 181 | ||
182 | fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); | 182 | fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); |
@@ -185,52 +185,55 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) | |||
185 | /* | 185 | /* |
186 | * fsnotify_access - file was read | 186 | * fsnotify_access - file was read |
187 | */ | 187 | */ |
188 | static inline void fsnotify_access(struct dentry *dentry) | 188 | static inline void fsnotify_access(struct file *file) |
189 | { | 189 | { |
190 | struct inode *inode = dentry->d_inode; | 190 | struct path *path = &file->f_path; |
191 | struct inode *inode = path->dentry->d_inode; | ||
191 | __u32 mask = FS_ACCESS; | 192 | __u32 mask = FS_ACCESS; |
192 | 193 | ||
193 | if (S_ISDIR(inode->i_mode)) | 194 | if (S_ISDIR(inode->i_mode)) |
194 | mask |= FS_IN_ISDIR; | 195 | mask |= FS_IN_ISDIR; |
195 | 196 | ||
196 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); | 197 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
197 | 198 | fsnotify_parent(path, NULL, mask); | |
198 | fsnotify_parent(dentry, mask); | 199 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
199 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | /* | 203 | /* |
203 | * fsnotify_modify - file was modified | 204 | * fsnotify_modify - file was modified |
204 | */ | 205 | */ |
205 | static inline void fsnotify_modify(struct dentry *dentry) | 206 | static inline void fsnotify_modify(struct file *file) |
206 | { | 207 | { |
207 | struct inode *inode = dentry->d_inode; | 208 | struct path *path = &file->f_path; |
209 | struct inode *inode = path->dentry->d_inode; | ||
208 | __u32 mask = FS_MODIFY; | 210 | __u32 mask = FS_MODIFY; |
209 | 211 | ||
210 | if (S_ISDIR(inode->i_mode)) | 212 | if (S_ISDIR(inode->i_mode)) |
211 | mask |= FS_IN_ISDIR; | 213 | mask |= FS_IN_ISDIR; |
212 | 214 | ||
213 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); | 215 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
214 | 216 | fsnotify_parent(path, NULL, mask); | |
215 | fsnotify_parent(dentry, mask); | 217 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
216 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 218 | } |
217 | } | 219 | } |
218 | 220 | ||
219 | /* | 221 | /* |
220 | * fsnotify_open - file was opened | 222 | * fsnotify_open - file was opened |
221 | */ | 223 | */ |
222 | static inline void fsnotify_open(struct dentry *dentry) | 224 | static inline void fsnotify_open(struct file *file) |
223 | { | 225 | { |
224 | struct inode *inode = dentry->d_inode; | 226 | struct path *path = &file->f_path; |
227 | struct inode *inode = path->dentry->d_inode; | ||
225 | __u32 mask = FS_OPEN; | 228 | __u32 mask = FS_OPEN; |
226 | 229 | ||
227 | if (S_ISDIR(inode->i_mode)) | 230 | if (S_ISDIR(inode->i_mode)) |
228 | mask |= FS_IN_ISDIR; | 231 | mask |= FS_IN_ISDIR; |
229 | 232 | ||
230 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); | 233 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
231 | 234 | fsnotify_parent(path, NULL, mask); | |
232 | fsnotify_parent(dentry, mask); | 235 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
233 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 236 | } |
234 | } | 237 | } |
235 | 238 | ||
236 | /* | 239 | /* |
@@ -238,18 +241,18 @@ static inline void fsnotify_open(struct dentry *dentry) | |||
238 | */ | 241 | */ |
239 | static inline void fsnotify_close(struct file *file) | 242 | static inline void fsnotify_close(struct file *file) |
240 | { | 243 | { |
241 | struct dentry *dentry = file->f_path.dentry; | 244 | struct path *path = &file->f_path; |
242 | struct inode *inode = dentry->d_inode; | 245 | struct inode *inode = file->f_path.dentry->d_inode; |
243 | fmode_t mode = file->f_mode; | 246 | fmode_t mode = file->f_mode; |
244 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; | 247 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; |
245 | 248 | ||
246 | if (S_ISDIR(inode->i_mode)) | 249 | if (S_ISDIR(inode->i_mode)) |
247 | mask |= FS_IN_ISDIR; | 250 | mask |= FS_IN_ISDIR; |
248 | 251 | ||
249 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); | 252 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
250 | 253 | fsnotify_parent(path, NULL, mask); | |
251 | fsnotify_parent(dentry, mask); | 254 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
252 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 255 | } |
253 | } | 256 | } |
254 | 257 | ||
255 | /* | 258 | /* |
@@ -263,9 +266,7 @@ static inline void fsnotify_xattr(struct dentry *dentry) | |||
263 | if (S_ISDIR(inode->i_mode)) | 266 | if (S_ISDIR(inode->i_mode)) |
264 | mask |= FS_IN_ISDIR; | 267 | mask |= FS_IN_ISDIR; |
265 | 268 | ||
266 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); | 269 | fsnotify_parent(NULL, dentry, mask); |
267 | |||
268 | fsnotify_parent(dentry, mask); | ||
269 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 270 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
270 | } | 271 | } |
271 | 272 | ||
@@ -299,19 +300,18 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid) | |||
299 | if (mask) { | 300 | if (mask) { |
300 | if (S_ISDIR(inode->i_mode)) | 301 | if (S_ISDIR(inode->i_mode)) |
301 | mask |= FS_IN_ISDIR; | 302 | mask |= FS_IN_ISDIR; |
302 | inotify_inode_queue_event(inode, mask, 0, NULL, NULL); | ||
303 | 303 | ||
304 | fsnotify_parent(dentry, mask); | 304 | fsnotify_parent(NULL, dentry, mask); |
305 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 305 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | #if defined(CONFIG_INOTIFY) || defined(CONFIG_FSNOTIFY) /* notify helpers */ | 309 | #if defined(CONFIG_FSNOTIFY) /* notify helpers */ |
310 | 310 | ||
311 | /* | 311 | /* |
312 | * fsnotify_oldname_init - save off the old filename before we change it | 312 | * fsnotify_oldname_init - save off the old filename before we change it |
313 | */ | 313 | */ |
314 | static inline const char *fsnotify_oldname_init(const char *name) | 314 | static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name) |
315 | { | 315 | { |
316 | return kstrdup(name, GFP_KERNEL); | 316 | return kstrdup(name, GFP_KERNEL); |
317 | } | 317 | } |
@@ -319,22 +319,22 @@ static inline const char *fsnotify_oldname_init(const char *name) | |||
319 | /* | 319 | /* |
320 | * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init | 320 | * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init |
321 | */ | 321 | */ |
322 | static inline void fsnotify_oldname_free(const char *old_name) | 322 | static inline void fsnotify_oldname_free(const unsigned char *old_name) |
323 | { | 323 | { |
324 | kfree(old_name); | 324 | kfree(old_name); |
325 | } | 325 | } |
326 | 326 | ||
327 | #else /* CONFIG_INOTIFY || CONFIG_FSNOTIFY */ | 327 | #else /* CONFIG_FSNOTIFY */ |
328 | 328 | ||
329 | static inline const char *fsnotify_oldname_init(const char *name) | 329 | static inline const char *fsnotify_oldname_init(const unsigned char *name) |
330 | { | 330 | { |
331 | return NULL; | 331 | return NULL; |
332 | } | 332 | } |
333 | 333 | ||
334 | static inline void fsnotify_oldname_free(const char *old_name) | 334 | static inline void fsnotify_oldname_free(const unsigned char *old_name) |
335 | { | 335 | { |
336 | } | 336 | } |
337 | 337 | ||
338 | #endif /* ! CONFIG_INOTIFY */ | 338 | #endif /* CONFIG_FSNOTIFY */ |
339 | 339 | ||
340 | #endif /* _LINUX_FS_NOTIFY_H */ | 340 | #endif /* _LINUX_FS_NOTIFY_H */ |