提交 0a8dd2db 编写于 作者: H Heinrich Schuchardt 提交者: Linus Torvalds

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: NHeinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Tvrtko Ursulin <tvrtko.ursulin@onelan.co.uk>
Reviewed-by: NJan Kara <jack@suse.cz>
Acked-by: NEric Paris <eparis@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 3185a88c
...@@ -813,6 +813,15 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, ...@@ -813,6 +813,15 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
group->priority == FS_PRIO_0) group->priority == FS_PRIO_0)
goto fput_and_out; goto fput_and_out;
if (flags & FAN_MARK_FLUSH) {
ret = 0;
if (flags & FAN_MARK_MOUNT)
fsnotify_clear_vfsmount_marks_by_group(group);
else
fsnotify_clear_inode_marks_by_group(group);
goto fput_and_out;
}
ret = fanotify_find_path(dfd, pathname, &path, flags); ret = fanotify_find_path(dfd, pathname, &path, flags);
if (ret) if (ret)
goto fput_and_out; goto fput_and_out;
...@@ -824,7 +833,7 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, ...@@ -824,7 +833,7 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
mnt = path.mnt; mnt = path.mnt;
/* create/update an inode mark */ /* create/update an inode mark */
switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) { switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)) {
case FAN_MARK_ADD: case FAN_MARK_ADD:
if (flags & FAN_MARK_MOUNT) if (flags & FAN_MARK_MOUNT)
ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags); ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags);
...@@ -837,12 +846,6 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, ...@@ -837,12 +846,6 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
else else
ret = fanotify_remove_inode_mark(group, inode, mask, flags); ret = fanotify_remove_inode_mark(group, inode, mask, flags);
break; break;
case FAN_MARK_FLUSH:
if (flags & FAN_MARK_MOUNT)
fsnotify_clear_vfsmount_marks_by_group(group);
else
fsnotify_clear_inode_marks_by_group(group);
break;
default: default:
ret = -EINVAL; ret = -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册