try harder to get directory refcounts right
This commit is contained in:
parent
f3e87bc838
commit
15a2693637
1 changed files with 8 additions and 2 deletions
10
sysfile.c
10
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;
|
||||
|
|
Loading…
Reference in a new issue