aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fsnotify.h
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2010-07-28 10:18:37 -0400
committerEric Paris <eparis@redhat.com>2010-07-28 10:18:51 -0400
commit3bcf3860a4ff9bbc522820b4b765e65e4deceb3e (patch)
tree1e235af133559062c6fdee840ff9698f1dee26a6 /include/linux/fsnotify.h
parentf70ab54cc6c3907b0727ba332b3976f80f3846d0 (diff)
fsnotify: store struct file not struct path
Al explains that calling dentry_open() with a mnt/dentry pair is only garunteed to be safe if they are already used in an open struct file. To make sure this is the case don't store and use a struct path in fsnotify, always use a struct file. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'include/linux/fsnotify.h')
-rw-r--r--include/linux/fsnotify.h37
1 files changed, 16 insertions, 21 deletions
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 59d0df43ff9d..e4e2204187ee 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -26,19 +26,18 @@ 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. */
29static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) 29static inline void fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
30{ 30{
31 if (!dentry) 31 if (!dentry)
32 dentry = path->dentry; 32 dentry = file->f_path.dentry;
33 33
34 __fsnotify_parent(path, dentry, mask); 34 __fsnotify_parent(file, dentry, mask);
35} 35}
36 36
37/* simple call site for access decisions */ 37/* simple call site for access decisions */
38static inline int fsnotify_perm(struct file *file, int mask) 38static inline int fsnotify_perm(struct file *file, int mask)
39{ 39{
40 struct path *path = &file->f_path; 40 struct inode *inode = file->f_path.dentry->d_inode;
41 struct inode *inode = path->dentry->d_inode;
42 __u32 fsnotify_mask = 0; 41 __u32 fsnotify_mask = 0;
43 42
44 if (file->f_mode & FMODE_NONOTIFY) 43 if (file->f_mode & FMODE_NONOTIFY)
@@ -52,7 +51,7 @@ static inline int fsnotify_perm(struct file *file, int mask)
52 else 51 else
53 BUG(); 52 BUG();
54 53
55 return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 54 return fsnotify(inode, fsnotify_mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
56} 55}
57 56
58/* 57/*
@@ -187,16 +186,15 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
187 */ 186 */
188static inline void fsnotify_access(struct file *file) 187static inline void fsnotify_access(struct file *file)
189{ 188{
190 struct path *path = &file->f_path; 189 struct inode *inode = file->f_path.dentry->d_inode;
191 struct inode *inode = path->dentry->d_inode;
192 __u32 mask = FS_ACCESS; 190 __u32 mask = FS_ACCESS;
193 191
194 if (S_ISDIR(inode->i_mode)) 192 if (S_ISDIR(inode->i_mode))
195 mask |= FS_IN_ISDIR; 193 mask |= FS_IN_ISDIR;
196 194
197 if (!(file->f_mode & FMODE_NONOTIFY)) { 195 if (!(file->f_mode & FMODE_NONOTIFY)) {
198 fsnotify_parent(path, NULL, mask); 196 fsnotify_parent(file, NULL, mask);
199 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 197 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
200 } 198 }
201} 199}
202 200
@@ -205,16 +203,15 @@ static inline void fsnotify_access(struct file *file)
205 */ 203 */
206static inline void fsnotify_modify(struct file *file) 204static inline void fsnotify_modify(struct file *file)
207{ 205{
208 struct path *path = &file->f_path; 206 struct inode *inode = file->f_path.dentry->d_inode;
209 struct inode *inode = path->dentry->d_inode;
210 __u32 mask = FS_MODIFY; 207 __u32 mask = FS_MODIFY;
211 208
212 if (S_ISDIR(inode->i_mode)) 209 if (S_ISDIR(inode->i_mode))
213 mask |= FS_IN_ISDIR; 210 mask |= FS_IN_ISDIR;
214 211
215 if (!(file->f_mode & FMODE_NONOTIFY)) { 212 if (!(file->f_mode & FMODE_NONOTIFY)) {
216 fsnotify_parent(path, NULL, mask); 213 fsnotify_parent(file, NULL, mask);
217 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 214 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
218 } 215 }
219} 216}
220 217
@@ -223,16 +220,15 @@ static inline void fsnotify_modify(struct file *file)
223 */ 220 */
224static inline void fsnotify_open(struct file *file) 221static inline void fsnotify_open(struct file *file)
225{ 222{
226 struct path *path = &file->f_path; 223 struct inode *inode = file->f_path.dentry->d_inode;
227 struct inode *inode = path->dentry->d_inode;
228 __u32 mask = FS_OPEN; 224 __u32 mask = FS_OPEN;
229 225
230 if (S_ISDIR(inode->i_mode)) 226 if (S_ISDIR(inode->i_mode))
231 mask |= FS_IN_ISDIR; 227 mask |= FS_IN_ISDIR;
232 228
233 if (!(file->f_mode & FMODE_NONOTIFY)) { 229 if (!(file->f_mode & FMODE_NONOTIFY)) {
234 fsnotify_parent(path, NULL, mask); 230 fsnotify_parent(file, NULL, mask);
235 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 231 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
236 } 232 }
237} 233}
238 234
@@ -241,7 +237,6 @@ static inline void fsnotify_open(struct file *file)
241 */ 237 */
242static inline void fsnotify_close(struct file *file) 238static inline void fsnotify_close(struct file *file)
243{ 239{
244 struct path *path = &file->f_path;
245 struct inode *inode = file->f_path.dentry->d_inode; 240 struct inode *inode = file->f_path.dentry->d_inode;
246 fmode_t mode = file->f_mode; 241 fmode_t mode = file->f_mode;
247 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; 242 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
@@ -250,8 +245,8 @@ static inline void fsnotify_close(struct file *file)
250 mask |= FS_IN_ISDIR; 245 mask |= FS_IN_ISDIR;
251 246
252 if (!(file->f_mode & FMODE_NONOTIFY)) { 247 if (!(file->f_mode & FMODE_NONOTIFY)) {
253 fsnotify_parent(path, NULL, mask); 248 fsnotify_parent(file, NULL, mask);
254 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 249 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
255 } 250 }
256} 251}
257 252