From: Eric Paris <eparis@redhat.com>
To: linux-audit@redhat.com
Cc: viro@ZenIV.linux.org.uk
Subject: [PATCH 5/7] fsnotify: allow addition of duplicate fsnotify marks
Date: Fri, 12 Jun 2009 16:32:21 -0400 [thread overview]
Message-ID: <20090612203221.12332.82787.stgit@paris.rdu.redhat.com> (raw)
In-Reply-To: <20090612203159.12332.42771.stgit@paris.rdu.redhat.com>
This patch allows a task to add a second fsnotify mark to an inode for the
same group. This mark will be added to the end of the inode's list and
this will never be found by the stand fsnotify_find_mark() function. This
is useful if a user wants to add a new mark before removing the old one.
Signed-off-by: Eric Paris <eparis@redhat.com>
---
fs/notify/dnotify/dnotify.c | 2 +-
fs/notify/inode_mark.c | 8 +++++---
fs/notify/inotify/inotify_user.c | 2 +-
include/linux/fsnotify_backend.h | 2 +-
kernel/audit_watch.c | 2 +-
5 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
index 828a889..6b71be9 100644
--- a/fs/notify/dnotify/dnotify.c
+++ b/fs/notify/dnotify/dnotify.c
@@ -361,7 +361,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
dnentry = container_of(entry, struct dnotify_mark_entry, fsn_entry);
spin_lock(&entry->lock);
} else {
- fsnotify_add_mark(new_entry, dnotify_group, inode);
+ fsnotify_add_mark(new_entry, dnotify_group, inode, 0);
spin_lock(&new_entry->lock);
entry = new_entry;
dnentry = new_dnentry;
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index f560ad5..3f3261b 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -313,9 +313,10 @@ void fsnotify_init_mark(struct fsnotify_mark_entry *entry,
* event types should be delivered to which group and for which inodes.
*/
int fsnotify_add_mark(struct fsnotify_mark_entry *entry,
- struct fsnotify_group *group, struct inode *inode)
+ struct fsnotify_group *group, struct inode *inode,
+ int allow_dups)
{
- struct fsnotify_mark_entry *lentry;
+ struct fsnotify_mark_entry *lentry = NULL;
int ret = 0;
inode = igrab(inode);
@@ -335,7 +336,8 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry,
entry->group = group;
entry->inode = inode;
- lentry = fsnotify_find_mark_entry(group, inode);
+ if (!allow_dups)
+ lentry = fsnotify_find_mark_entry(group, inode);
if (!lentry) {
hlist_add_head(&entry->i_list, &inode->i_fsnotify_mark_entries);
list_add(&entry->g_list, &group->mark_entries);
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 982a412..289a7ce 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -467,7 +467,7 @@ find_entry:
goto out_err;
}
- ret = fsnotify_add_mark(&ientry->fsn_entry, group, inode);
+ ret = fsnotify_add_mark(&ientry->fsn_entry, group, inode, 0);
if (ret == -EEXIST)
goto find_entry;
else if (ret)
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 4c187c6..2ab2b7d 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -345,7 +345,7 @@ extern struct fsnotify_mark_entry *fsnotify_find_mark_entry(struct fsnotify_grou
/* copy the values from old into new */
extern void fsnotify_duplicate_mark(struct fsnotify_mark_entry *new, struct fsnotify_mark_entry *old);
/* attach the mark to both the group and the inode */
-extern int fsnotify_add_mark(struct fsnotify_mark_entry *entry, struct fsnotify_group *group, struct inode *inode);
+extern int fsnotify_add_mark(struct fsnotify_mark_entry *entry, struct fsnotify_group *group, struct inode *inode, int allow_dups);
/* given a mark, flag it to be freed when all references are dropped */
extern void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry);
/* run all the marks in a group, and flag them to be freed */
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index 231f2a6..e56286b 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -163,7 +163,7 @@ static struct audit_parent *audit_init_parent(struct path *parent_path)
fsnotify_init_mark(&parent->mark, audit_watch_free_mark);
parent->mark.mask = AUDIT_FS_WATCH;
- ret = fsnotify_add_mark(&parent->mark, audit_watch_group, inode);
+ ret = fsnotify_add_mark(&parent->mark, audit_watch_group, inode, 0);
if (ret < 0) {
audit_free_parent(parent);
return ERR_PTR(ret);
next prev parent reply other threads:[~2009-06-12 20:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-12 20:31 [PATCH 1/7] audit: convert audit watches to use fsnotify instead of inotify Eric Paris
2009-06-12 20:32 ` [PATCH 2/7] audit: redo audit watch locking and refcnt in light of fsnotify Eric Paris
2009-06-12 20:32 ` [PATCH 3/7] audit: do not get and put just to free a watch Eric Paris
2009-06-12 20:32 ` [PATCH 4/7] fsnotify: duplicate fsnotify_mark_entry data between 2 marks Eric Paris
2009-06-12 20:32 ` Eric Paris [this message]
2009-06-12 20:32 ` [PATCH 6/7] audit: reimplement audit_trees using fsnotify rather than inotify Eric Paris
2009-06-12 20:32 ` [PATCH 7/7] audit: move audit to a subdirectory Eric Paris
2009-06-16 15:25 ` [PATCH 1/7] audit: convert audit watches to use fsnotify instead of inotify Klaus Heinrich Kiwi
2009-06-16 15:43 ` Eric Paris
2009-06-16 16:09 ` Klaus Heinrich Kiwi
2009-06-19 21:03 ` Eric Paris
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=20090612203221.12332.82787.stgit@paris.rdu.redhat.com \
--to=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=viro@ZenIV.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox