aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inotify.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/inotify.c')
-rw-r--r--fs/inotify.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/inotify.c b/fs/inotify.c
index bf7ce1d2412b..878ccca61213 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -33,6 +33,7 @@
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/writeback.h> 34#include <linux/writeback.h>
35#include <linux/inotify.h> 35#include <linux/inotify.h>
36#include <linux/syscalls.h>
36 37
37#include <asm/ioctls.h> 38#include <asm/ioctls.h>
38 39
@@ -364,11 +365,12 @@ static int inotify_dev_get_wd(struct inotify_device *dev,
364/* 365/*
365 * find_inode - resolve a user-given path to a specific inode and return a nd 366 * find_inode - resolve a user-given path to a specific inode and return a nd
366 */ 367 */
367static int find_inode(const char __user *dirname, struct nameidata *nd) 368static int find_inode(const char __user *dirname, struct nameidata *nd,
369 unsigned flags)
368{ 370{
369 int error; 371 int error;
370 372
371 error = __user_walk(dirname, LOOKUP_FOLLOW, nd); 373 error = __user_walk(dirname, flags, nd);
372 if (error) 374 if (error)
373 return error; 375 return error;
374 /* you can only watch an inode if you have read permissions on it */ 376 /* you can only watch an inode if you have read permissions on it */
@@ -933,6 +935,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
933 struct file *filp; 935 struct file *filp;
934 int ret, fput_needed; 936 int ret, fput_needed;
935 int mask_add = 0; 937 int mask_add = 0;
938 unsigned flags = 0;
936 939
937 filp = fget_light(fd, &fput_needed); 940 filp = fget_light(fd, &fput_needed);
938 if (unlikely(!filp)) 941 if (unlikely(!filp))
@@ -944,7 +947,12 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
944 goto fput_and_out; 947 goto fput_and_out;
945 } 948 }
946 949
947 ret = find_inode(path, &nd); 950 if (!(mask & IN_DONT_FOLLOW))
951 flags |= LOOKUP_FOLLOW;
952 if (mask & IN_ONLYDIR)
953 flags |= LOOKUP_DIRECTORY;
954
955 ret = find_inode(path, &nd, flags);
948 if (unlikely(ret)) 956 if (unlikely(ret))
949 goto fput_and_out; 957 goto fput_and_out;
950 958