minor fixes
authorMiklos Szeredi <miklos@szeredi.hu>
Tue, 27 Jan 2004 17:04:59 +0000 (17:04 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Tue, 27 Jan 2004 17:04:59 +0000 (17:04 +0000)
ChangeLog
kernel/dir.c
lib/fuse.c

index 969342bde44706c3d65003492f1fc6e7dd0361a6..cb4b313be14db4d2e116fb40046b5543e95a8990 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
        printed if the cause of the program exit is that the filesystem
        has already been unmounted
 
+       * Fix i_nlink correctness after rmdir/unlink
+
 2004-01-26  Miklos Szeredi <mszeredi@inf.bme.hu>
 
        * Released 1.1-pre2
index cd41a88da4c8c98ba8d7bece4d624534eee04c4b..739b677fa57fe3270bbff9a5bf8bdcd4975b4739 100644 (file)
@@ -272,12 +272,24 @@ static int fuse_remove(struct inode *dir, struct dentry *entry,
 
 static int fuse_unlink(struct inode *dir, struct dentry *entry)
 {
-       return fuse_remove(dir, entry, FUSE_UNLINK);
+       int err = fuse_remove(dir, entry, FUSE_UNLINK);
+       if(!err) {
+               /* FIXME: the new i_nlink could be returned by the
+                   unlink operation */
+               err = fuse_do_getattr(entry->d_inode);
+               if(err == -ENOENT)
+                       entry->d_inode->i_nlink = 0;
+               return 0;
+       }
+       return err;
 }
 
 static int fuse_rmdir(struct inode *dir, struct dentry *entry)
 {
-       return fuse_remove(dir, entry, FUSE_RMDIR);
+       int err = fuse_remove(dir, entry, FUSE_RMDIR);
+       if(!err)
+               entry->d_inode->i_nlink = 0;
+       return err;
 }
 
 static int fuse_rename(struct inode *olddir, struct dentry *oldent,
index 50ae3a8fbbbb0d2608dccf7335bc4aa9829f87f0..f88653d19196e145a381081a302925ef04cfbed1 100644 (file)
@@ -109,8 +109,8 @@ static fino_t get_ino(struct node *node)
 
 static fino_t next_ino(struct fuse *f)
 {
-    while(f->ctr == 0 || __get_node(f, f->ctr) != NULL)
-        f->ctr++;
+    do f->ctr++;
+    while(f->ctr == 0 || __get_node(f, f->ctr) != NULL);
     
     return f->ctr;
 }