diff options
author | Amir Goldstein <amir73il@gmail.com> | 2019-01-10 12:04:40 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2019-02-07 10:38:35 -0500 |
commit | 0a20df7ed3349dfa3260ddee2efa919df44d0ad5 (patch) | |
tree | a67f25db1275679997c0d7348c0c25896e33dde7 /fs/notify | |
parent | 73072283a249c798838e09813760db8bcdd9cd3a (diff) |
fsnotify: report FS_ISDIR flag with MOVE_SELF and DELETE_SELF events
We need to report FS_ISDIR flag with MOVE_SELF and DELETE_SELF events
for fanotify, because fanotify API requires the user to explicitly
request events on directories by FAN_ONDIR flag.
inotify never reported IN_ISDIR with those events. It looks like an
oversight, but to avoid the risk of breaking existing inotify programs,
mask the FS_ISDIR flag out when reprting those events to inotify backend.
We also add the FS_ISDIR flag with FS_ATTRIB event in the case of rename
over an empty target directory. inotify did not report IN_ISDIR in this
case, but it normally does report IN_ISDIR along with IN_ATTRIB event,
so in this case, we do not mask out the FS_ISDIR flag.
[JK: Simplify the checks in fsnotify_move()]
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify')
-rw-r--r-- | fs/notify/inotify/inotify_fsnotify.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index fe97299975f2..ff30abd6a49b 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c | |||
@@ -113,6 +113,15 @@ int inotify_handle_event(struct fsnotify_group *group, | |||
113 | return -ENOMEM; | 113 | return -ENOMEM; |
114 | } | 114 | } |
115 | 115 | ||
116 | /* | ||
117 | * We now report FS_ISDIR flag with MOVE_SELF and DELETE_SELF events | ||
118 | * for fanotify. inotify never reported IN_ISDIR with those events. | ||
119 | * It looks like an oversight, but to avoid the risk of breaking | ||
120 | * existing inotify programs, mask the flag out from those events. | ||
121 | */ | ||
122 | if (mask & (IN_MOVE_SELF | IN_DELETE_SELF)) | ||
123 | mask &= ~IN_ISDIR; | ||
124 | |||
116 | fsn_event = &event->fse; | 125 | fsn_event = &event->fse; |
117 | fsnotify_init_event(fsn_event, inode); | 126 | fsnotify_init_event(fsn_event, inode); |
118 | event->mask = mask; | 127 | event->mask = mask; |