tree acfe43ff758f7d7a6d0c575ca0e4f343b3640984
parent be2ac68f7b66e90b8d25c168fc4d033b034f5c43
author John McCutchan <[EMAIL PROTECTED]> Mon, 01 Aug 2005 19:00:45 -0400
committer Linus Torvalds <[EMAIL PROTECTED]> Mon, 01 Aug 2005 23:16:53 -0700
[PATCH] inotify: fix file deletion by rename detection
When a file is moved over an existing file that you are watching,
inotify won't send you a DELETE_SELF event and it won't unref the inode
until the inotify instance is closed by the application.
Signed-off-by: John McCutchan <[EMAIL PROTECTED]>
Signed-off-by: Robert Love <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
fs/namei.c | 2 +-
include/linux/fsnotify.h | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2218,7 +2218,7 @@ int vfs_rename(struct inode *old_dir, st
error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
if (!error) {
const char *new_name = old_dentry->d_name.name;
- fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir);
+ fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir,
new_dentry->d_inode);
}
fsnotify_oldname_free(old_name);
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -21,7 +21,7 @@
*/
static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
const char *old_name, const char *new_name,
- int isdir)
+ int isdir, struct inode *target)
{
u32 cookie = inotify_get_cookie();
@@ -36,6 +36,11 @@ static inline void fsnotify_move(struct
isdir = IN_ISDIR;
inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name);
inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name);
+
+ if (target) {
+ inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL);
+ inotify_inode_is_dead(target);
+ }
}
/*
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html