fanotify: hooks the fanotify_mark syscall to the vfsmount code

Create a new fanotify_mark flag which indicates we should attach the mark
to the vfsmount holding the object referenced by dfd and pathname rather
than the inode itself.

Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Eric Paris 2009-12-17 21:24:29 -05:00
Родитель 90dd201d1a
Коммит 0ff21db9fc
2 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -485,7 +485,8 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
__u64 mask, int dfd, __u64 mask, int dfd,
const char __user * pathname) const char __user * pathname)
{ {
struct inode *inode; struct inode *inode = NULL;
struct vfsmount *mnt = NULL;
struct fsnotify_group *group; struct fsnotify_group *group;
struct file *filp; struct file *filp;
struct path path; struct path path;
@ -515,16 +516,22 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
goto fput_and_out; goto fput_and_out;
/* inode held in place by reference to path; group by fget on fd */ /* inode held in place by reference to path; group by fget on fd */
inode = path.dentry->d_inode; if (!(flags & FAN_MARK_ON_VFSMOUNT))
inode = path.dentry->d_inode;
else
mnt = path.mnt;
group = filp->private_data; group = filp->private_data;
/* create/update an inode mark */ /* create/update an inode mark */
switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)) { switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)) {
case FAN_MARK_ADD: case FAN_MARK_ADD:
ret = fanotify_add_inode_mark(group, inode, mask); if (flags & FAN_MARK_ON_VFSMOUNT)
ret = fanotify_add_vfsmount_mark(group, mnt, mask);
else
ret = fanotify_add_inode_mark(group, inode, mask);
break; break;
case FAN_MARK_REMOVE: case FAN_MARK_REMOVE:
ret = fanotify_remove_mark(group, inode, NULL, mask); ret = fanotify_remove_mark(group, inode, mnt, mask);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;

Просмотреть файл

@ -29,11 +29,13 @@
#define FAN_MARK_REMOVE 0x00000002 #define FAN_MARK_REMOVE 0x00000002
#define FAN_MARK_DONT_FOLLOW 0x00000004 #define FAN_MARK_DONT_FOLLOW 0x00000004
#define FAN_MARK_ONLYDIR 0x00000008 #define FAN_MARK_ONLYDIR 0x00000008
#define FAN_MARK_ON_VFSMOUNT 0x00000010
#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\ #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\
FAN_MARK_REMOVE |\ FAN_MARK_REMOVE |\
FAN_MARK_DONT_FOLLOW |\ FAN_MARK_DONT_FOLLOW |\
FAN_MARK_ONLYDIR) FAN_MARK_ONLYDIR |\
FAN_MARK_ON_VFSMOUNT)
/* /*
* All of the events - we build the list by hand so that we can add flags in * All of the events - we build the list by hand so that we can add flags in