Skip to content

Commit 103ff6a

Browse files
amir73iljankara
authored andcommitted
fanotify: generalize merge logic of events on dir
An event on directory should never be merged with an event on non-directory regardless of the event struct type. This change has no visible effect, because currently, with struct fanotify_path_event, the relevant events will not be merged because event path of dir will be different than event path of non-dir. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 0badfa0 commit 103ff6a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

fs/notify/fanotify/fanotify.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,22 @@ static bool fanotify_should_merge(struct fsnotify_event *old_fsn,
8383
old->type != new->type || old->pid != new->pid)
8484
return false;
8585

86+
/*
87+
* We want to merge many dirent events in the same dir (i.e.
88+
* creates/unlinks/renames), but we do not want to merge dirent
89+
* events referring to subdirs with dirent events referring to
90+
* non subdirs, otherwise, user won't be able to tell from a
91+
* mask FAN_CREATE|FAN_DELETE|FAN_ONDIR if it describes mkdir+
92+
* unlink pair or rmdir+create pair of events.
93+
*/
94+
if ((old->mask & FS_ISDIR) != (new->mask & FS_ISDIR))
95+
return false;
96+
8697
switch (old->type) {
8798
case FANOTIFY_EVENT_TYPE_PATH:
8899
return fanotify_path_equal(fanotify_event_path(old),
89100
fanotify_event_path(new));
90101
case FANOTIFY_EVENT_TYPE_FID:
91-
/*
92-
* We want to merge many dirent events in the same dir (i.e.
93-
* creates/unlinks/renames), but we do not want to merge dirent
94-
* events referring to subdirs with dirent events referring to
95-
* non subdirs, otherwise, user won't be able to tell from a
96-
* mask FAN_CREATE|FAN_DELETE|FAN_ONDIR if it describes mkdir+
97-
* unlink pair or rmdir+create pair of events.
98-
*/
99-
if ((old->mask & FS_ISDIR) != (new->mask & FS_ISDIR))
100-
return false;
101-
102102
return fanotify_fid_event_equal(FANOTIFY_FE(old),
103103
FANOTIFY_FE(new));
104104
case FANOTIFY_EVENT_TYPE_FID_NAME:

0 commit comments

Comments
 (0)