fix IN_DELETE_SELF on overwriting rename() on ramfs et.al.
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Jul 2011 19:49:09 +0000 (15:49 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 22 Jul 2011 23:42:11 +0000 (19:42 -0400)
On ramfs and other simple_rename() users IN_DELETE_SELF is not generated
for victim of overwriting rename() if it's is a directory.  Works on
most of the local filesystems and really trivial to fix...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/libfs.c

index 8f2271a5df53c119eb05b86fa9834652ede9c57b..c18e9a1235b6594373d5c18f2e615b5bf4b06596 100644 (file)
@@ -328,8 +328,10 @@ int simple_rename(struct inode *old_dir, struct dentry *old_dentry,
 
        if (new_dentry->d_inode) {
                simple_unlink(new_dir, new_dentry);
-               if (they_are_dirs)
+               if (they_are_dirs) {
+                       drop_nlink(new_dentry->d_inode);
                        drop_nlink(old_dir);
+               }
        } else if (they_are_dirs) {
                drop_nlink(old_dir);
                inc_nlink(new_dir);