From: Joris Dolderer <vorstadtkind@googlemail.com>
To: linux-kernel@vger.kernel.org
Cc: eparis@redhat.com
Subject: [PATCH 3/3] inotify: tree-watching support
Date: Fri, 12 Feb 2010 22:10:50 +0100 [thread overview]
Message-ID: <20100212221050.756e4254@icecube> (raw)
Add tree-watching support to inotify.
In userspace, you have to add an IN_TREE flag to the mask.
Signed-off-by: Joris Dolderer <vorstadtkind@googlemail.com>
---
diff --git a/fs/notify/inotify/inotify_fsnotify.c
b/fs/notify/inotify/inotify_fsnotify.c index 1afb0a1..d42a8cd 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -89,6 +89,7 @@ static bool inotify_should_send_event(struct
fsnotify_group *group, struct inode {
struct fsnotify_mark_entry *entry;
bool send;
+ __u32 test_mask;
spin_lock(&inode->i_lock);
entry = fsnotify_find_mark_entry(group, inode);
@@ -96,8 +97,9 @@ static bool inotify_should_send_event(struct
fsnotify_group *group, struct inode if (!entry)
return false;
- mask = (mask & ~FS_EVENT_ON_CHILD);
- send = (entry->mask & mask);
+ test_mask = mask & ~FS_EVENT_ON_TREE;
+ send = entry->mask & test_mask;
+ send = send && ((mask & FS_EVENT_ON_TREE) ? ((entry->mask &
mask) & FS_EVENT_ON_TREE) : true);
/* find took a reference */
fsnotify_put_mark(entry);
diff --git a/fs/notify/inotify/inotify_user.c
b/fs/notify/inotify/inotify_user.c index a94e8bd..575bbf8 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -11,6 +11,8 @@
* Copyright (C) 2009 Eric Paris <Red Hat Inc>
* inotify was largely rewriten to make use of the fsnotify
infrastructure *
+ * Tree-watching support (C) 2010 Joris Dolderer
<vorstadtkind@googlemail.com>
+ *
* This program is free software; you can redistribute it and/or
modify it
* under the terms of the GNU General Public License as published by
the
* Free Software Foundation; either version 2, or (at your option) any
@@ -100,12 +102,15 @@ static inline __u32 inotify_arg_to_mask(u32 arg)
{
__u32 mask;
- /* everything should accept their own ignored and cares about
children */
- mask = (FS_IN_IGNORED | FS_EVENT_ON_CHILD);
+ /* everything should accept their own ignored*/
+ mask = FS_IN_IGNORED;
/* mask off the flags used to open the fd */
mask |= (arg & (IN_ALL_EVENTS | IN_ONESHOT));
+ /* care about children or descents */
+ mask |= (arg & IN_TREE) ? FS_EVENT_ON_DESCENT :
FS_EVENT_ON_CHILD; +
return mask;
}
@@ -505,7 +510,7 @@ static int inotify_update_existing_watch(struct
fsnotify_group *group,
/* update the inode with this new entry */
if (dropped || do_inode)
- fsnotify_recalc_inode_mask(inode);
+ fsnotify_recalc_inode_mask(inode, (old_mask ^
new_mask) & IN_TREE);
/* update the group mask with the new mask */
if (dropped || do_group)
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 37ea289..b5bef0b 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -49,12 +49,12 @@ struct inotify_event {
#define IN_MOVE (IN_MOVED_FROM |
IN_MOVED_TO) /* moves */
/* special flags */
+#define IN_TREE 0x00800000 /* watch the
whole directory tree */ #define IN_ONLYDIR
0x01000000 /* only watch the path if it is a directory */
#define IN_DONT_FOLLOW 0x02000000 /* don't follow
a sym link */ #define IN_MASK_ADD 0x20000000 /*
add to the mask of an already existing watch */ #define
IN_ISDIR 0x40000000 /* event occurred against dir
*/ #define IN_ONESHOT 0x80000000 /* only send
event once */ - /*
* All of the events - we build the list by hand so that we can add
flags in
* the future and not break backward compatibility. Apps will get
only the
next reply other threads:[~2010-02-12 21:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-12 21:10 Joris Dolderer [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-02-13 9:08 [PATCH 3/3] inotify: tree-watching support Joris Dolderer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100212221050.756e4254@icecube \
--to=vorstadtkind@googlemail.com \
--cc=eparis@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.