try harder to get directory refcounts right

This commit is contained in:
kolya 2008-10-17 12:42:13 +00:00
parent f3e87bc838
commit 15a2693637

View file

@ -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;