diff options
Diffstat (limited to 'include/linux/fsnotify.h')
-rw-r--r-- | include/linux/fsnotify.h | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 59d0df43ff9..5c185fa2708 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
@@ -26,12 +26,12 @@ static inline void fsnotify_d_instantiate(struct dentry *dentry, | |||
26 | } | 26 | } |
27 | 27 | ||
28 | /* Notify this dentry's parent about a child's events. */ | 28 | /* Notify this dentry's parent about a child's events. */ |
29 | static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) | 29 | static inline int fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) |
30 | { | 30 | { |
31 | if (!dentry) | 31 | if (!dentry) |
32 | dentry = path->dentry; | 32 | dentry = path->dentry; |
33 | 33 | ||
34 | __fsnotify_parent(path, dentry, mask); | 34 | return __fsnotify_parent(path, dentry, mask); |
35 | } | 35 | } |
36 | 36 | ||
37 | /* simple call site for access decisions */ | 37 | /* simple call site for access decisions */ |
@@ -40,6 +40,7 @@ static inline int fsnotify_perm(struct file *file, int mask) | |||
40 | struct path *path = &file->f_path; | 40 | struct path *path = &file->f_path; |
41 | struct inode *inode = path->dentry->d_inode; | 41 | struct inode *inode = path->dentry->d_inode; |
42 | __u32 fsnotify_mask = 0; | 42 | __u32 fsnotify_mask = 0; |
43 | int ret; | ||
43 | 44 | ||
44 | if (file->f_mode & FMODE_NONOTIFY) | 45 | if (file->f_mode & FMODE_NONOTIFY) |
45 | return 0; | 46 | return 0; |
@@ -52,6 +53,10 @@ static inline int fsnotify_perm(struct file *file, int mask) | |||
52 | else | 53 | else |
53 | BUG(); | 54 | BUG(); |
54 | 55 | ||
56 | ret = fsnotify_parent(path, NULL, fsnotify_mask); | ||
57 | if (ret) | ||
58 | return ret; | ||
59 | |||
55 | return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); | 60 | return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
56 | } | 61 | } |
57 | 62 | ||
@@ -93,8 +98,8 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | |||
93 | old_dir_mask |= FS_DN_RENAME; | 98 | old_dir_mask |= FS_DN_RENAME; |
94 | 99 | ||
95 | if (isdir) { | 100 | if (isdir) { |
96 | old_dir_mask |= FS_IN_ISDIR; | 101 | old_dir_mask |= FS_ISDIR; |
97 | new_dir_mask |= FS_IN_ISDIR; | 102 | new_dir_mask |= FS_ISDIR; |
98 | } | 103 | } |
99 | 104 | ||
100 | fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); | 105 | fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); |
@@ -132,7 +137,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) | |||
132 | __u32 mask = FS_DELETE; | 137 | __u32 mask = FS_DELETE; |
133 | 138 | ||
134 | if (isdir) | 139 | if (isdir) |
135 | mask |= FS_IN_ISDIR; | 140 | mask |= FS_ISDIR; |
136 | 141 | ||
137 | fsnotify_parent(NULL, dentry, mask); | 142 | fsnotify_parent(NULL, dentry, mask); |
138 | } | 143 | } |
@@ -174,7 +179,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct | |||
174 | */ | 179 | */ |
175 | static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) | 180 | static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) |
176 | { | 181 | { |
177 | __u32 mask = (FS_CREATE | FS_IN_ISDIR); | 182 | __u32 mask = (FS_CREATE | FS_ISDIR); |
178 | struct inode *d_inode = dentry->d_inode; | 183 | struct inode *d_inode = dentry->d_inode; |
179 | 184 | ||
180 | audit_inode_child(dentry, inode); | 185 | audit_inode_child(dentry, inode); |
@@ -192,7 +197,7 @@ static inline void fsnotify_access(struct file *file) | |||
192 | __u32 mask = FS_ACCESS; | 197 | __u32 mask = FS_ACCESS; |
193 | 198 | ||
194 | if (S_ISDIR(inode->i_mode)) | 199 | if (S_ISDIR(inode->i_mode)) |
195 | mask |= FS_IN_ISDIR; | 200 | mask |= FS_ISDIR; |
196 | 201 | ||
197 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 202 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
198 | fsnotify_parent(path, NULL, mask); | 203 | fsnotify_parent(path, NULL, mask); |
@@ -210,7 +215,7 @@ static inline void fsnotify_modify(struct file *file) | |||
210 | __u32 mask = FS_MODIFY; | 215 | __u32 mask = FS_MODIFY; |
211 | 216 | ||
212 | if (S_ISDIR(inode->i_mode)) | 217 | if (S_ISDIR(inode->i_mode)) |
213 | mask |= FS_IN_ISDIR; | 218 | mask |= FS_ISDIR; |
214 | 219 | ||
215 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 220 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
216 | fsnotify_parent(path, NULL, mask); | 221 | fsnotify_parent(path, NULL, mask); |
@@ -228,12 +233,13 @@ static inline void fsnotify_open(struct file *file) | |||
228 | __u32 mask = FS_OPEN; | 233 | __u32 mask = FS_OPEN; |
229 | 234 | ||
230 | if (S_ISDIR(inode->i_mode)) | 235 | if (S_ISDIR(inode->i_mode)) |
231 | mask |= FS_IN_ISDIR; | 236 | mask |= FS_ISDIR; |
232 | 237 | ||
233 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 238 | /* FMODE_NONOTIFY must never be set from user */ |
234 | fsnotify_parent(path, NULL, mask); | 239 | file->f_mode &= ~FMODE_NONOTIFY; |
235 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); | 240 | |
236 | } | 241 | fsnotify_parent(path, NULL, mask); |
242 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); | ||
237 | } | 243 | } |
238 | 244 | ||
239 | /* | 245 | /* |
@@ -247,7 +253,7 @@ static inline void fsnotify_close(struct file *file) | |||
247 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; | 253 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; |
248 | 254 | ||
249 | if (S_ISDIR(inode->i_mode)) | 255 | if (S_ISDIR(inode->i_mode)) |
250 | mask |= FS_IN_ISDIR; | 256 | mask |= FS_ISDIR; |
251 | 257 | ||
252 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 258 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
253 | fsnotify_parent(path, NULL, mask); | 259 | fsnotify_parent(path, NULL, mask); |
@@ -264,7 +270,7 @@ static inline void fsnotify_xattr(struct dentry *dentry) | |||
264 | __u32 mask = FS_ATTRIB; | 270 | __u32 mask = FS_ATTRIB; |
265 | 271 | ||
266 | if (S_ISDIR(inode->i_mode)) | 272 | if (S_ISDIR(inode->i_mode)) |
267 | mask |= FS_IN_ISDIR; | 273 | mask |= FS_ISDIR; |
268 | 274 | ||
269 | fsnotify_parent(NULL, dentry, mask); | 275 | fsnotify_parent(NULL, dentry, mask); |
270 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 276 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
@@ -299,7 +305,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid) | |||
299 | 305 | ||
300 | if (mask) { | 306 | if (mask) { |
301 | if (S_ISDIR(inode->i_mode)) | 307 | if (S_ISDIR(inode->i_mode)) |
302 | mask |= FS_IN_ISDIR; | 308 | mask |= FS_ISDIR; |
303 | 309 | ||
304 | fsnotify_parent(NULL, dentry, mask); | 310 | fsnotify_parent(NULL, dentry, mask); |
305 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 311 | fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); |