diff options
author | Jan Kara <jack@suse.cz> | 2019-01-08 07:28:18 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2019-02-18 05:49:36 -0500 |
commit | af6a51130626bfd3e60041d80335b2c31590d56d (patch) | |
tree | e8d148b7e1a867a81b42a6e4c644325f6547c07f /fs/notify | |
parent | 53136b393c918cb14626419d6b626a7416b9cbf6 (diff) |
fanotify: Fold dequeue_event() into process_access_response()
Fold dequeue_event() into process_access_response(). This will make
changes to use of ->response field easier.
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify')
-rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 6c61a06d0ef5..e47d2a7709bf 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -138,28 +138,6 @@ static int create_fd(struct fsnotify_group *group, | |||
138 | return client_fd; | 138 | return client_fd; |
139 | } | 139 | } |
140 | 140 | ||
141 | static struct fanotify_perm_event *dequeue_event( | ||
142 | struct fsnotify_group *group, int fd) | ||
143 | { | ||
144 | struct fanotify_perm_event *event, *return_e = NULL; | ||
145 | |||
146 | spin_lock(&group->notification_lock); | ||
147 | list_for_each_entry(event, &group->fanotify_data.access_list, | ||
148 | fae.fse.list) { | ||
149 | if (event->fd != fd) | ||
150 | continue; | ||
151 | |||
152 | list_del_init(&event->fae.fse.list); | ||
153 | return_e = event; | ||
154 | break; | ||
155 | } | ||
156 | spin_unlock(&group->notification_lock); | ||
157 | |||
158 | pr_debug("%s: found return_re=%p\n", __func__, return_e); | ||
159 | |||
160 | return return_e; | ||
161 | } | ||
162 | |||
163 | static int process_access_response(struct fsnotify_group *group, | 141 | static int process_access_response(struct fsnotify_group *group, |
164 | struct fanotify_response *response_struct) | 142 | struct fanotify_response *response_struct) |
165 | { | 143 | { |
@@ -188,14 +166,21 @@ static int process_access_response(struct fsnotify_group *group, | |||
188 | if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT)) | 166 | if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT)) |
189 | return -EINVAL; | 167 | return -EINVAL; |
190 | 168 | ||
191 | event = dequeue_event(group, fd); | 169 | spin_lock(&group->notification_lock); |
192 | if (!event) | 170 | list_for_each_entry(event, &group->fanotify_data.access_list, |
193 | return -ENOENT; | 171 | fae.fse.list) { |
172 | if (event->fd != fd) | ||
173 | continue; | ||
194 | 174 | ||
195 | event->response = response; | 175 | list_del_init(&event->fae.fse.list); |
196 | wake_up(&group->fanotify_data.access_waitq); | 176 | event->response = response; |
177 | spin_unlock(&group->notification_lock); | ||
178 | wake_up(&group->fanotify_data.access_waitq); | ||
179 | return 0; | ||
180 | } | ||
181 | spin_unlock(&group->notification_lock); | ||
197 | 182 | ||
198 | return 0; | 183 | return -ENOENT; |
199 | } | 184 | } |
200 | 185 | ||
201 | static int copy_fid_to_user(struct fanotify_event *event, char __user *buf) | 186 | static int copy_fid_to_user(struct fanotify_event *event, char __user *buf) |