Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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 <ttb@tentacle.dhs.org>
Signed-off-by: Robert Love <rml@novell.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

John McCutchan and committed by
Linus Torvalds
75449536 be2ac68f

+7 -2
+1 -1
fs/namei.c
··· 2218 2218 error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); 2219 2219 if (!error) { 2220 2220 const char *new_name = old_dentry->d_name.name; 2221 - fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir); 2221 + fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir, new_dentry->d_inode); 2222 2222 } 2223 2223 fsnotify_oldname_free(old_name); 2224 2224
+6 -1
include/linux/fsnotify.h
··· 21 21 */ 22 22 static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, 23 23 const char *old_name, const char *new_name, 24 - int isdir) 24 + int isdir, struct inode *target) 25 25 { 26 26 u32 cookie = inotify_get_cookie(); 27 27 ··· 36 36 isdir = IN_ISDIR; 37 37 inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name); 38 38 inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name); 39 + 40 + if (target) { 41 + inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL); 42 + inotify_inode_is_dead(target); 43 + } 39 44 } 40 45 41 46 /*