jffs2: fix IN_DELETE_SELF on overwriting rename() killing a directory
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Jul 2011 19:57:47 +0000 (15:57 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 22 Jul 2011 23:42:11 +0000 (19:42 -0400)
We don't generate IN_DELETE_SELF on victim of overwriting rename() if
it happens to be a directory.  Trivially fixed by doing to ->i_nlink
what we do ->pino_nlink a couple of lines later in jffs2_rename().

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

index 8f40ce4f1777c62ef593f0168510ed06859fa34a..5f243cd63afc330e817f1dbfa1a52cb5eb83b33c 100644 (file)
@@ -820,7 +820,10 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
 
        if (victim_f) {
                /* There was a victim. Kill it off nicely */
-               drop_nlink(new_dentry->d_inode);
+               if (S_ISDIR(new_dentry->d_inode->i_mode))
+                       clear_nlink(new_dentry->d_inode);
+               else
+                       drop_nlink(new_dentry->d_inode);
                /* Don't oops if the victim was a dirent pointing to an
                   inode which didn't exist. */
                if (victim_f->inocache) {