fsnotify: pass connp and object type to fsnotify_add_mark()
Instead of passing inode and vfsmount arguments to fsnotify_add_mark() and its _locked variant, pass an abstract object pointer and the object type. The helpers fsnotify_obj_{inode,mount} are added to get the concrete object pointer from abstract object pointer. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
@@ -615,8 +615,8 @@ static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark,
|
||||
}
|
||||
|
||||
static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
|
||||
struct inode *inode,
|
||||
struct vfsmount *mnt)
|
||||
fsnotify_connp_t *connp,
|
||||
unsigned int type)
|
||||
{
|
||||
struct fsnotify_mark *mark;
|
||||
int ret;
|
||||
@@ -629,7 +629,7 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
fsnotify_init_mark(mark, group);
|
||||
ret = fsnotify_add_mark_locked(mark, inode, mnt, 0);
|
||||
ret = fsnotify_add_mark_locked(mark, connp, type, 0);
|
||||
if (ret) {
|
||||
fsnotify_put_mark(mark);
|
||||
return ERR_PTR(ret);
|
||||
@@ -643,14 +643,15 @@ static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
|
||||
struct vfsmount *mnt, __u32 mask,
|
||||
unsigned int flags)
|
||||
{
|
||||
fsnotify_connp_t *connp = &real_mount(mnt)->mnt_fsnotify_marks;
|
||||
struct fsnotify_mark *fsn_mark;
|
||||
__u32 added;
|
||||
|
||||
mutex_lock(&group->mark_mutex);
|
||||
fsn_mark = fsnotify_find_mark(&real_mount(mnt)->mnt_fsnotify_marks,
|
||||
group);
|
||||
fsn_mark = fsnotify_find_mark(connp, group);
|
||||
if (!fsn_mark) {
|
||||
fsn_mark = fanotify_add_new_mark(group, NULL, mnt);
|
||||
fsn_mark = fanotify_add_new_mark(group, connp,
|
||||
FSNOTIFY_OBJ_TYPE_VFSMOUNT);
|
||||
if (IS_ERR(fsn_mark)) {
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
return PTR_ERR(fsn_mark);
|
||||
@@ -669,6 +670,7 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
|
||||
struct inode *inode, __u32 mask,
|
||||
unsigned int flags)
|
||||
{
|
||||
fsnotify_connp_t *connp = &inode->i_fsnotify_marks;
|
||||
struct fsnotify_mark *fsn_mark;
|
||||
__u32 added;
|
||||
|
||||
@@ -685,9 +687,10 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
|
||||
return 0;
|
||||
|
||||
mutex_lock(&group->mark_mutex);
|
||||
fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group);
|
||||
fsn_mark = fsnotify_find_mark(connp, group);
|
||||
if (!fsn_mark) {
|
||||
fsn_mark = fanotify_add_new_mark(group, inode, NULL);
|
||||
fsn_mark = fanotify_add_new_mark(group, connp,
|
||||
FSNOTIFY_OBJ_TYPE_INODE);
|
||||
if (IS_ERR(fsn_mark)) {
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
return PTR_ERR(fsn_mark);
|
||||
|
Reference in New Issue
Block a user