aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2018-04-20 19:10:54 -0400
committerJan Kara <jack@suse.cz>2018-05-18 08:58:22 -0400
commit837a393438475177889dc3161b7250ed48dce27a (patch)
tree4751320ac899799666dd4742973e3cf33bd32d08
parent3dca1a7494e32a3186bd907963e387bf875ee54e (diff)
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 <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/notify/fanotify/fanotify.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index f83650486052..f90842efea13 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -91,14 +91,13 @@ static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info,
91 u32 event_mask, const void *data, 91 u32 event_mask, const void *data,
92 int data_type) 92 int data_type)
93{ 93{
94 struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
95 struct fsnotify_mark *vfsmnt_mark = fsnotify_iter_vfsmount_mark(iter_info);
96 __u32 marks_mask = 0, marks_ignored_mask = 0; 94 __u32 marks_mask = 0, marks_ignored_mask = 0;
97 const struct path *path = data; 95 const struct path *path = data;
96 struct fsnotify_mark *mark;
97 int type;
98 98
99 pr_debug("%s: inode_mark=%p vfsmnt_mark=%p mask=%x data=%p" 99 pr_debug("%s: report_mask=%x mask=%x data=%p data_type=%d\n",
100 " data_type=%d\n", __func__, inode_mark, vfsmnt_mark, 100 __func__, iter_info->report_mask, event_mask, data, data_type);
101 event_mask, data, data_type);
102 101
103 /* if we don't have enough info to send an event to userspace say no */ 102 /* if we don't have enough info to send an event to userspace say no */
104 if (data_type != FSNOTIFY_EVENT_PATH) 103 if (data_type != FSNOTIFY_EVENT_PATH)
@@ -109,20 +108,21 @@ static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info,
109 !d_can_lookup(path->dentry)) 108 !d_can_lookup(path->dentry))
110 return false; 109 return false;
111 110
112 /* 111 fsnotify_foreach_obj_type(type) {
113 * if the event is for a child and this inode doesn't care about 112 if (!fsnotify_iter_should_report_type(iter_info, type))
114 * events on the child, don't send it! 113 continue;
115 */ 114 mark = iter_info->marks[type];
116 if (inode_mark && 115 /*
117 (!(event_mask & FS_EVENT_ON_CHILD) || 116 * if the event is for a child and this inode doesn't care about
118 (inode_mark->mask & FS_EVENT_ON_CHILD))) { 117 * events on the child, don't send it!
119 marks_mask |= inode_mark->mask; 118 */
120 marks_ignored_mask |= inode_mark->ignored_mask; 119 if (type == FSNOTIFY_OBJ_TYPE_INODE &&
121 } 120 (event_mask & FS_EVENT_ON_CHILD) &&
121 !(mark->mask & FS_EVENT_ON_CHILD))
122 continue;
122 123
123 if (vfsmnt_mark) { 124 marks_mask |= mark->mask;
124 marks_mask |= vfsmnt_mark->mask; 125 marks_ignored_mask |= mark->ignored_mask;
125 marks_ignored_mask |= vfsmnt_mark->ignored_mask;
126 } 126 }
127 127
128 if (d_is_dir(path->dentry) && 128 if (d_is_dir(path->dentry) &&