From 15a269363777c0cd95e2a56e7def0a4dc3122e21 Mon Sep 17 00:00:00 2001 From: kolya Date: Fri, 17 Oct 2008 12:42:13 +0000 Subject: [PATCH] try harder to get directory refcounts right --- sysfile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sysfile.c b/sysfile.c index ce812f5..8808073 100644 --- a/sysfile.c +++ b/sysfile.c @@ -199,6 +199,10 @@ sys_unlink(void) memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); + if(ip->type == T_DIR){ + dp->nlink--; + iupdate(dp); + } iunlockput(dp); ip->nlink--; @@ -247,8 +251,10 @@ create(char *path, int canexist, short type, short major, short minor) } if(dirlink(dp, name, ip->inum) < 0){ - dp->nlink--; - iupdate(dp); + if(type == T_DIR){ + dp->nlink--; + iupdate(dp); + } iunlockput(dp); ip->nlink = 0;