summaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2019-01-10 12:04:43 -0500
committerJan Kara <jack@suse.cz>2019-02-07 10:43:23 -0500
commit235328d1fa4251c6dcb32351219bb553a58838d2 (patch)
tree26cff20d85dca87e181957a4b4c9a4c9d565845f /fs/notify
parent83b535d2897d1d4ce22c2f656a53bdd7865d1df3 (diff)
fanotify: add support for create/attrib/move/delete events
Add support for events with data type FSNOTIFY_EVENT_INODE (e.g. create/attrib/move/delete) for inode and filesystem mark types. The "inode" events do not carry enough information (i.e. path) to report event->fd, so we do not allow setting a mask for those events unless group supports reporting fid. The "inode" events are not supported on a mount mark, because they do not carry enough information (i.e. path) to be filtered by mount point. The "dirent" events (create/move/delete) report the fid of the parent directory where events took place without specifying the filename of the child. In the future, fanotify may get support for reporting filename information for those events. Cc: <linux-api@vger.kernel.org> 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/fanotify/fanotify.c9
-rw-r--r--fs/notify/fanotify/fanotify_user.c12
2 files changed, 20 insertions, 1 deletions
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 974239b03442..158c69acb04d 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -313,9 +313,16 @@ static int fanotify_handle_event(struct fsnotify_group *group,
313 313
314 BUILD_BUG_ON(FAN_ACCESS != FS_ACCESS); 314 BUILD_BUG_ON(FAN_ACCESS != FS_ACCESS);
315 BUILD_BUG_ON(FAN_MODIFY != FS_MODIFY); 315 BUILD_BUG_ON(FAN_MODIFY != FS_MODIFY);
316 BUILD_BUG_ON(FAN_ATTRIB != FS_ATTRIB);
316 BUILD_BUG_ON(FAN_CLOSE_NOWRITE != FS_CLOSE_NOWRITE); 317 BUILD_BUG_ON(FAN_CLOSE_NOWRITE != FS_CLOSE_NOWRITE);
317 BUILD_BUG_ON(FAN_CLOSE_WRITE != FS_CLOSE_WRITE); 318 BUILD_BUG_ON(FAN_CLOSE_WRITE != FS_CLOSE_WRITE);
318 BUILD_BUG_ON(FAN_OPEN != FS_OPEN); 319 BUILD_BUG_ON(FAN_OPEN != FS_OPEN);
320 BUILD_BUG_ON(FAN_MOVED_TO != FS_MOVED_TO);
321 BUILD_BUG_ON(FAN_MOVED_FROM != FS_MOVED_FROM);
322 BUILD_BUG_ON(FAN_CREATE != FS_CREATE);
323 BUILD_BUG_ON(FAN_DELETE != FS_DELETE);
324 BUILD_BUG_ON(FAN_DELETE_SELF != FS_DELETE_SELF);
325 BUILD_BUG_ON(FAN_MOVE_SELF != FS_MOVE_SELF);
319 BUILD_BUG_ON(FAN_EVENT_ON_CHILD != FS_EVENT_ON_CHILD); 326 BUILD_BUG_ON(FAN_EVENT_ON_CHILD != FS_EVENT_ON_CHILD);
320 BUILD_BUG_ON(FAN_Q_OVERFLOW != FS_Q_OVERFLOW); 327 BUILD_BUG_ON(FAN_Q_OVERFLOW != FS_Q_OVERFLOW);
321 BUILD_BUG_ON(FAN_OPEN_PERM != FS_OPEN_PERM); 328 BUILD_BUG_ON(FAN_OPEN_PERM != FS_OPEN_PERM);
@@ -324,7 +331,7 @@ static int fanotify_handle_event(struct fsnotify_group *group,
324 BUILD_BUG_ON(FAN_OPEN_EXEC != FS_OPEN_EXEC); 331 BUILD_BUG_ON(FAN_OPEN_EXEC != FS_OPEN_EXEC);
325 BUILD_BUG_ON(FAN_OPEN_EXEC_PERM != FS_OPEN_EXEC_PERM); 332 BUILD_BUG_ON(FAN_OPEN_EXEC_PERM != FS_OPEN_EXEC_PERM);
326 333
327 BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 12); 334 BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 19);
328 335
329 mask = fanotify_group_event_mask(group, iter_info, mask, data, 336 mask = fanotify_group_event_mask(group, iter_info, mask, data,
330 data_type); 337 data_type);
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index bf06fd6ef761..6c61a06d0ef5 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -976,6 +976,18 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
976 group->priority == FS_PRIO_0) 976 group->priority == FS_PRIO_0)
977 goto fput_and_out; 977 goto fput_and_out;
978 978
979 /*
980 * Events with data type inode do not carry enough information to report
981 * event->fd, so we do not allow setting a mask for inode events unless
982 * group supports reporting fid.
983 * inode events are not supported on a mount mark, because they do not
984 * carry enough information (i.e. path) to be filtered by mount point.
985 */
986 if (mask & FANOTIFY_INODE_EVENTS &&
987 (!FAN_GROUP_FLAG(group, FAN_REPORT_FID) ||
988 mark_type == FAN_MARK_MOUNT))
989 goto fput_and_out;
990
979 if (flags & FAN_MARK_FLUSH) { 991 if (flags & FAN_MARK_FLUSH) {
980 ret = 0; 992 ret = 0;
981 if (mark_type == FAN_MARK_MOUNT) 993 if (mark_type == FAN_MARK_MOUNT)