aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify/fanotify
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2014-06-04 19:05:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:53:52 -0400
commit0a8dd2db579f7a0ac7033d6b857c3d5dbaa77563 (patch)
tree26d2c8028c7a1b619e08efe87ca17ac48cb62b98 /fs/notify/fanotify
parent3185a88ce37490938d56119c474aa48616d386e8 (diff)
fanotify: FAN_MARK_FLUSH: avoid having to provide a fake/invalid fd and path
Originally from Tvrtko Ursulin (https://lkml.org/lkml/2011/1/12/112) Avoid having to provide a fake/invalid fd and path when flushing marks Currently for a group to flush marks it has set it needs to provide a fake or invalid (but resolvable) file descriptor and path when calling fanotify_mark. This patch pulls the flush handling a bit up so file descriptor and path are completely ignored when flushing. I reworked the patch to be applicable again (the signature of fanotify_mark has changed since Tvrtko's work). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Tvrtko Ursulin <tvrtko.ursulin@onelan.co.uk> Reviewed-by: Jan Kara <jack@suse.cz> Acked-by: Eric Paris <eparis@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/notify/fanotify')
-rw-r--r--fs/notify/fanotify/fanotify_user.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 732648b270dc..f6ac6a2fa91e 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -813,6 +813,15 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
813 group->priority == FS_PRIO_0) 813 group->priority == FS_PRIO_0)
814 goto fput_and_out; 814 goto fput_and_out;
815 815
816 if (flags & FAN_MARK_FLUSH) {
817 ret = 0;
818 if (flags & FAN_MARK_MOUNT)
819 fsnotify_clear_vfsmount_marks_by_group(group);
820 else
821 fsnotify_clear_inode_marks_by_group(group);
822 goto fput_and_out;
823 }
824
816 ret = fanotify_find_path(dfd, pathname, &path, flags); 825 ret = fanotify_find_path(dfd, pathname, &path, flags);
817 if (ret) 826 if (ret)
818 goto fput_and_out; 827 goto fput_and_out;
@@ -824,7 +833,7 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
824 mnt = path.mnt; 833 mnt = path.mnt;
825 834
826 /* create/update an inode mark */ 835 /* create/update an inode mark */
827 switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) { 836 switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)) {
828 case FAN_MARK_ADD: 837 case FAN_MARK_ADD:
829 if (flags & FAN_MARK_MOUNT) 838 if (flags & FAN_MARK_MOUNT)
830 ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags); 839 ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags);
@@ -837,12 +846,6 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
837 else 846 else
838 ret = fanotify_remove_inode_mark(group, inode, mask, flags); 847 ret = fanotify_remove_inode_mark(group, inode, mask, flags);
839 break; 848 break;
840 case FAN_MARK_FLUSH:
841 if (flags & FAN_MARK_MOUNT)
842 fsnotify_clear_vfsmount_marks_by_group(group);
843 else
844 fsnotify_clear_inode_marks_by_group(group);
845 break;
846 default: 849 default:
847 ret = -EINVAL; 850 ret = -EINVAL;
848 } 851 }