diff options
author | John McCutchan <ttb@tentacle.dhs.org> | 2005-08-01 11:00:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-08-01 12:16:53 -0400 |
commit | 7544953685859875b5ac0260b6b1856066c092d6 (patch) | |
tree | acfe43ff758f7d7a6d0c575ca0e4f343b3640984 | |
parent | be2ac68f7b66e90b8d25c168fc4d033b034f5c43 (diff) |
[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>
-rw-r--r-- | fs/namei.c | 2 | ||||
-rw-r--r-- | include/linux/fsnotify.h | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c index 02a824cd3c5c..4a27eb798118 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2218,7 +2218,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2218 | error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); | 2218 | error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); |
2219 | if (!error) { | 2219 | if (!error) { |
2220 | const char *new_name = old_dentry->d_name.name; | 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 | fsnotify_oldname_free(old_name); | 2223 | fsnotify_oldname_free(old_name); |
2224 | 2224 | ||
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index d07a92c94776..e96a4306ab3b 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
@@ -21,7 +21,7 @@ | |||
21 | */ | 21 | */ |
22 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | 22 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, |
23 | const char *old_name, const char *new_name, | 23 | const char *old_name, const char *new_name, |
24 | int isdir) | 24 | int isdir, struct inode *target) |
25 | { | 25 | { |
26 | u32 cookie = inotify_get_cookie(); | 26 | u32 cookie = inotify_get_cookie(); |
27 | 27 | ||
@@ -36,6 +36,11 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | |||
36 | isdir = IN_ISDIR; | 36 | isdir = IN_ISDIR; |
37 | inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name); | 37 | inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name); |
38 | inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name); | 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 | /* |