]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
HFS+: fix unlink of links
authorRoman Zippel <zippel@linux-m68k.org>
Wed, 9 Apr 2008 15:44:07 +0000 (17:44 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 10 Apr 2008 20:37:51 +0000 (13:37 -0700)
Some time ago while attempting to handle invalid link counts, I botched
the unlink of links itself, so this patch fixes this now correctly, so
that only the link count of nodes that don't point to links is ignored.
Thanks to Vlado Plaga <rechner@vlado-do.de> to notify me of this
problem.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/hfsplus/dir.c

index 29683645fa0a7ad7c3d6beb4fbb6be2eddce861c..5f4023678251b9b9ee8da40e27eff7f6c33e4a63 100644 (file)
@@ -340,16 +340,23 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
 
        if (inode->i_nlink > 0)
                drop_nlink(inode);
-       hfsplus_delete_inode(inode);
-       if (inode->i_ino != cnid && !inode->i_nlink) {
-               if (!atomic_read(&HFSPLUS_I(inode).opencnt)) {
-                       res = hfsplus_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL);
-                       if (!res)
-                               hfsplus_delete_inode(inode);
+       if (inode->i_ino == cnid)
+               clear_nlink(inode);
+       if (!inode->i_nlink) {
+               if (inode->i_ino != cnid) {
+                       HFSPLUS_SB(sb).file_count--;
+                       if (!atomic_read(&HFSPLUS_I(inode).opencnt)) {
+                               res = hfsplus_delete_cat(inode->i_ino,
+                                                        HFSPLUS_SB(sb).hidden_dir,
+                                                        NULL);
+                               if (!res)
+                                       hfsplus_delete_inode(inode);
+                       } else
+                               inode->i_flags |= S_DEAD;
                } else
-                       inode->i_flags |= S_DEAD;
+                       hfsplus_delete_inode(inode);
        } else
-               clear_nlink(inode);
+               HFSPLUS_SB(sb).file_count--;
        inode->i_ctime = CURRENT_TIME_SEC;
        mark_inode_dirty(inode);