iincref returns new ref

This commit is contained in:
rsc 2007-08-08 09:30:42 +00:00
parent 35a24c8318
commit d80b06a1e0
3 changed files with 7 additions and 8 deletions

2
defs.h
View file

@ -128,7 +128,7 @@ void ilock(struct inode*);
void iunlock(struct inode*);
void itrunc(struct inode*);
void idecref(struct inode*);
void iincref(struct inode*);
struct inode* iincref(struct inode*);
void iput(struct inode*);
struct inode* namei(char*, int, uint*, char**, struct inode**);
void stati(struct inode*, struct stat*);

10
fs.c
View file

@ -266,8 +266,7 @@ iunlock(struct inode *ip)
uint
bmap(struct inode *ip, uint bn)
{
unsigned x;
uint *a;
uint *a, x;
struct buf *inbp;
if(bn >= MAXFILE)
@ -350,12 +349,14 @@ idecref(struct inode *ip)
}
// Increment reference count for ip.
void
// Returns ip to enable ip = iincref(ip1) idiom.
struct inode*
iincref(struct inode *ip)
{
ilock(ip);
ip->ref++;
iunlock(ip);
return ip;
}
// Copy stat information from inode.
@ -511,8 +512,7 @@ namei(char *path, int mode, uint *ret_off,
if(*cp == '/')
dp = iget(rootdev, 1);
else {
dp = p->cwd;
iincref(dp);
dp = iincref(p->cwd);
ilock(dp);
}

3
proc.c
View file

@ -150,8 +150,7 @@ copyproc(struct proc *p)
fileincref(np->ofile[i]);
}
np->cwd = p->cwd;
iincref(p->cwd);
np->cwd = iincref(p->cwd);
return np;
}