Skip to content

Commit 0badfa0

Browse files
amir73iljankara
authored andcommitted
fanotify: generalize the handling of extra event flags
In fanotify_group_event_mask() there is logic in place to make sure we are not going to handle an event with no type and just FAN_ONDIR flag. Generalize this logic to any FANOTIFY_EVENT_FLAGS. There is only one more flag in this group at the moment - FAN_EVENT_ON_CHILD. We never report it to user, but we do pass it in to fanotify_alloc_event() when group is reporting fid as indication that event happened on child. We will have use for this indication later on. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 08b95c3 commit 0badfa0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

fs/notify/fanotify/fanotify.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ static u32 fanotify_group_event_mask(struct fsnotify_group *group,
211211
int data_type)
212212
{
213213
__u32 marks_mask = 0, marks_ignored_mask = 0;
214-
__u32 test_mask, user_mask = FANOTIFY_OUTGOING_EVENTS;
214+
__u32 test_mask, user_mask = FANOTIFY_OUTGOING_EVENTS |
215+
FANOTIFY_EVENT_FLAGS;
215216
const struct path *path = fsnotify_data_path(data, data_type);
216217
struct fsnotify_mark *mark;
217218
int type;
@@ -264,14 +265,18 @@ static u32 fanotify_group_event_mask(struct fsnotify_group *group,
264265
*
265266
* For backward compatibility and consistency, do not report FAN_ONDIR
266267
* to user in legacy fanotify mode (reporting fd) and report FAN_ONDIR
267-
* to user in FAN_REPORT_FID mode for all event types.
268+
* to user in fid mode for all event types.
269+
*
270+
* We never report FAN_EVENT_ON_CHILD to user, but we do pass it in to
271+
* fanotify_alloc_event() when group is reporting fid as indication
272+
* that event happened on child.
268273
*/
269274
if (FAN_GROUP_FLAG(group, FAN_REPORT_FID)) {
270-
/* Do not report FAN_ONDIR without any event */
271-
if (!(test_mask & ~FAN_ONDIR))
275+
/* Do not report event flags without any event */
276+
if (!(test_mask & ~FANOTIFY_EVENT_FLAGS))
272277
return 0;
273278
} else {
274-
user_mask &= ~FAN_ONDIR;
279+
user_mask &= ~FANOTIFY_EVENT_FLAGS;
275280
}
276281

277282
return test_mask & user_mask;

0 commit comments

Comments
 (0)