Skip to content

Commit 837a393

Browse files
amir73iljankara
authored andcommitted
fanotify: generalize fanotify_should_send_event()
Use fsnotify_foreach_obj_type macros to generalize the code that filters events by marks mask and ignored_mask. This is going to be used for adding mark of super block object type. Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 3dca1a7 commit 837a393

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

fs/notify/fanotify/fanotify.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info,
9191
u32 event_mask, const void *data,
9292
int data_type)
9393
{
94-
struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
95-
struct fsnotify_mark *vfsmnt_mark = fsnotify_iter_vfsmount_mark(iter_info);
9694
__u32 marks_mask = 0, marks_ignored_mask = 0;
9795
const struct path *path = data;
96+
struct fsnotify_mark *mark;
97+
int type;
9898

99-
pr_debug("%s: inode_mark=%p vfsmnt_mark=%p mask=%x data=%p"
100-
" data_type=%d\n", __func__, inode_mark, vfsmnt_mark,
101-
event_mask, data, data_type);
99+
pr_debug("%s: report_mask=%x mask=%x data=%p data_type=%d\n",
100+
__func__, iter_info->report_mask, event_mask, data, data_type);
102101

103102
/* if we don't have enough info to send an event to userspace say no */
104103
if (data_type != FSNOTIFY_EVENT_PATH)
@@ -109,20 +108,21 @@ static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info,
109108
!d_can_lookup(path->dentry))
110109
return false;
111110

112-
/*
113-
* if the event is for a child and this inode doesn't care about
114-
* events on the child, don't send it!
115-
*/
116-
if (inode_mark &&
117-
(!(event_mask & FS_EVENT_ON_CHILD) ||
118-
(inode_mark->mask & FS_EVENT_ON_CHILD))) {
119-
marks_mask |= inode_mark->mask;
120-
marks_ignored_mask |= inode_mark->ignored_mask;
121-
}
111+
fsnotify_foreach_obj_type(type) {
112+
if (!fsnotify_iter_should_report_type(iter_info, type))
113+
continue;
114+
mark = iter_info->marks[type];
115+
/*
116+
* if the event is for a child and this inode doesn't care about
117+
* events on the child, don't send it!
118+
*/
119+
if (type == FSNOTIFY_OBJ_TYPE_INODE &&
120+
(event_mask & FS_EVENT_ON_CHILD) &&
121+
!(mark->mask & FS_EVENT_ON_CHILD))
122+
continue;
122123

123-
if (vfsmnt_mark) {
124-
marks_mask |= vfsmnt_mark->mask;
125-
marks_ignored_mask |= vfsmnt_mark->ignored_mask;
124+
marks_mask |= mark->mask;
125+
marks_ignored_mask |= mark->ignored_mask;
126126
}
127127

128128
if (d_is_dir(path->dentry) &&

0 commit comments

Comments
 (0)