Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fsnotify: refactor fsnotify_parent()/fsnotify() paired calls when event is on path

A wrapper function fsnotify_path() has been defined to simplify the
paired calls to fsnotify_parent()/fsnotify(). All hooks that made use
these paired calls and passed FSNOTIFY_EVENT_PATH have been updated
accordingly.

Signed-off-by: Matthew Bobrowski <mbobrowski@mbobrowski.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Matthew Bobrowski and committed by
Jan Kara
a704bba5 9b076f1c

+22 -20
+22 -20
include/linux/fsnotify.h
··· 26 26 return __fsnotify_parent(path, dentry, mask); 27 27 } 28 28 29 + /* 30 + * Simple wrapper to consolidate calls fsnotify_parent()/fsnotify() when 31 + * an event is on a path. 32 + */ 33 + static inline int fsnotify_path(struct inode *inode, const struct path *path, 34 + __u32 mask) 35 + { 36 + int ret = fsnotify_parent(path, NULL, mask); 37 + 38 + if (ret) 39 + return ret; 40 + return fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 41 + } 42 + 29 43 /* simple call site for access decisions */ 30 44 static inline int fsnotify_perm(struct file *file, int mask) 31 45 { 32 46 const struct path *path = &file->f_path; 33 47 struct inode *inode = file_inode(file); 34 48 __u32 fsnotify_mask = 0; 35 - int ret; 36 49 37 50 if (file->f_mode & FMODE_NONOTIFY) 38 51 return 0; ··· 58 45 else 59 46 BUG(); 60 47 61 - ret = fsnotify_parent(path, NULL, fsnotify_mask); 62 - if (ret) 63 - return ret; 64 - 65 - return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 48 + return fsnotify_path(inode, path, fsnotify_mask); 66 49 } 67 50 68 51 /* ··· 189 180 if (S_ISDIR(inode->i_mode)) 190 181 mask |= FS_ISDIR; 191 182 192 - if (!(file->f_mode & FMODE_NONOTIFY)) { 193 - fsnotify_parent(path, NULL, mask); 194 - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 195 - } 183 + if (!(file->f_mode & FMODE_NONOTIFY)) 184 + fsnotify_path(inode, path, mask); 196 185 } 197 186 198 187 /* ··· 205 198 if (S_ISDIR(inode->i_mode)) 206 199 mask |= FS_ISDIR; 207 200 208 - if (!(file->f_mode & FMODE_NONOTIFY)) { 209 - fsnotify_parent(path, NULL, mask); 210 - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 211 - } 201 + if (!(file->f_mode & FMODE_NONOTIFY)) 202 + fsnotify_path(inode, path, mask); 212 203 } 213 204 214 205 /* ··· 223 218 if (file->f_flags & __FMODE_EXEC) 224 219 mask |= FS_OPEN_EXEC; 225 220 226 - fsnotify_parent(path, NULL, mask); 227 - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 221 + fsnotify_path(inode, path, mask); 228 222 } 229 223 230 224 /* ··· 239 235 if (S_ISDIR(inode->i_mode)) 240 236 mask |= FS_ISDIR; 241 237 242 - if (!(file->f_mode & FMODE_NONOTIFY)) { 243 - fsnotify_parent(path, NULL, mask); 244 - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 245 - } 238 + if (!(file->f_mode & FMODE_NONOTIFY)) 239 + fsnotify_path(inode, path, mask); 246 240 } 247 241 248 242 /*