[PATCH 1/3] Introduce inotify_add_watch_at system call

From: cdahlin
Date: Wed Sep 22 2010 - 01:18:10 EST


From: Casey Dahlin <cdahlin@xxxxxxxxxx>

This adds inotify to the *at family of system calls (openat(2), unlinkat(2),
etc) and lets you specify a directory file descriptor as a root for the
pathname argument. It is otherwise the same as the inotify_add_watch system
call.

Signed-off-by: Casey Dahlin <cdahlin@xxxxxxxxxx>
---
fs/notify/inotify/inotify_user.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index bf7f6d7..ed110ca 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -108,7 +108,7 @@ static inline u32 inotify_mask_to_arg(__u32 mask)
IN_Q_OVERFLOW);
}

-/* intofiy userspace file descriptor functions */
+/* inotfiy userspace file descriptor functions */
static unsigned int inotify_poll(struct file *file, poll_table *wait)
{
struct fsnotify_group *group = file->private_data;
@@ -350,11 +350,11 @@ static const struct file_operations inotify_fops = {
/*
* find_inode - resolve a user-given path to a specific inode
*/
-static int inotify_find_inode(const char __user *dirname, struct path *path, unsigned flags)
+static int inotify_find_inode(int dfd, const char __user *dirname, struct path *path, unsigned flags)
{
int error;

- error = user_path_at(AT_FDCWD, dirname, flags, path);
+ error = user_path_at(dfd, dirname, flags, path);
if (error)
return error;
/* you can only watch an inode if you have read permissions on it */
@@ -762,8 +762,8 @@ SYSCALL_DEFINE0(inotify_init)
return sys_inotify_init1(0);
}

-SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
- u32, mask)
+SYSCALL_DEFINE4(inotify_add_watch_at, int, fd, int, dfd, const char __user *,
+ pathname, u32, mask)
{
struct fsnotify_group *group;
struct inode *inode;
@@ -787,7 +787,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
if (mask & IN_ONLYDIR)
flags |= LOOKUP_DIRECTORY;

- ret = inotify_find_inode(pathname, &path, flags);
+ ret = inotify_find_inode(dfd, pathname, &path, flags);
if (ret)
goto fput_and_out;

@@ -803,6 +803,12 @@ fput_and_out:
return ret;
}

+SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
+ u32, mask)
+{
+ return sys_inotify_add_watch_at(fd, AT_FDCWD, pathname, mask);
+}
+
SYSCALL_DEFINE2(inotify_rm_watch, int, fd, __s32, wd)
{
struct fsnotify_group *group;
--
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/