From f4f8b89730a3b94d5118d5ec66438e7dec8e6b3d Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 27 Jan 2004 17:04:59 +0000 Subject: [PATCH] minor fixes --- ChangeLog | 2 ++ kernel/dir.c | 16 ++++++++++++++-- lib/fuse.c | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 969342b..cb4b313 100644 --- 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 * Released 1.1-pre2 diff --git a/kernel/dir.c b/kernel/dir.c index cd41a88..739b677 100644 --- a/kernel/dir.c +++ b/kernel/dir.c @@ -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, diff --git a/lib/fuse.c b/lib/fuse.c index 50ae3a8..f88653d 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -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; } -- 2.30.2