]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] inotify: fix file deletion by rename detection
authorJohn McCutchan <ttb@tentacle.dhs.org>
Mon, 1 Aug 2005 15:00:45 +0000 (11:00 -0400)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 1 Aug 2005 16:16:53 +0000 (09:16 -0700)
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 <ttb@tentacle.dhs.org>
Signed-off-by: Robert Love <rml@novell.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/namei.c
include/linux/fsnotify.h

index 02a824cd3c5c01b7af923ad81e96b940c2cd1a08..4a27eb798118957544d52c9edbe013f30ce9cc43 100644 (file)
@@ -2218,7 +2218,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                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);
 
index d07a92c94776a90866ab1327f1c6dfc80bbfbf7f..e96a4306ab3bff63419241157c12629a2eeb78f7 100644 (file)
@@ -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 inode *old_dir, struct inode *new_dir,
                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);
+       }
 }
 
 /*