mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 21:47:04 +07:00
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>
This commit is contained in:
parent
9b076f1c0f
commit
a704bba5e3
@ -26,13 +26,26 @@ static inline int fsnotify_parent(const struct path *path, struct dentry *dentry
|
||||
return __fsnotify_parent(path, dentry, mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple wrapper to consolidate calls fsnotify_parent()/fsnotify() when
|
||||
* an event is on a path.
|
||||
*/
|
||||
static inline int fsnotify_path(struct inode *inode, const struct path *path,
|
||||
__u32 mask)
|
||||
{
|
||||
int ret = fsnotify_parent(path, NULL, mask);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
return fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||
}
|
||||
|
||||
/* simple call site for access decisions */
|
||||
static inline int fsnotify_perm(struct file *file, int mask)
|
||||
{
|
||||
const struct path *path = &file->f_path;
|
||||
struct inode *inode = file_inode(file);
|
||||
__u32 fsnotify_mask = 0;
|
||||
int ret;
|
||||
|
||||
if (file->f_mode & FMODE_NONOTIFY)
|
||||
return 0;
|
||||
@ -45,11 +58,7 @@ static inline int fsnotify_perm(struct file *file, int mask)
|
||||
else
|
||||
BUG();
|
||||
|
||||
ret = fsnotify_parent(path, NULL, fsnotify_mask);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||
return fsnotify_path(inode, path, fsnotify_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -180,10 +189,8 @@ static inline void fsnotify_access(struct file *file)
|
||||
if (S_ISDIR(inode->i_mode))
|
||||
mask |= FS_ISDIR;
|
||||
|
||||
if (!(file->f_mode & FMODE_NONOTIFY)) {
|
||||
fsnotify_parent(path, NULL, mask);
|
||||
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||
}
|
||||
if (!(file->f_mode & FMODE_NONOTIFY))
|
||||
fsnotify_path(inode, path, mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -198,10 +205,8 @@ static inline void fsnotify_modify(struct file *file)
|
||||
if (S_ISDIR(inode->i_mode))
|
||||
mask |= FS_ISDIR;
|
||||
|
||||
if (!(file->f_mode & FMODE_NONOTIFY)) {
|
||||
fsnotify_parent(path, NULL, mask);
|
||||
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||
}
|
||||
if (!(file->f_mode & FMODE_NONOTIFY))
|
||||
fsnotify_path(inode, path, mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -218,8 +223,7 @@ static inline void fsnotify_open(struct file *file)
|
||||
if (file->f_flags & __FMODE_EXEC)
|
||||
mask |= FS_OPEN_EXEC;
|
||||
|
||||
fsnotify_parent(path, NULL, mask);
|
||||
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||
fsnotify_path(inode, path, mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -235,10 +239,8 @@ static inline void fsnotify_close(struct file *file)
|
||||
if (S_ISDIR(inode->i_mode))
|
||||
mask |= FS_ISDIR;
|
||||
|
||||
if (!(file->f_mode & FMODE_NONOTIFY)) {
|
||||
fsnotify_parent(path, NULL, mask);
|
||||
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||
}
|
||||
if (!(file->f_mode & FMODE_NONOTIFY))
|
||||
fsnotify_path(inode, path, mask);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user