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 iunlock(struct inode*);
void itrunc(struct inode*); void itrunc(struct inode*);
void idecref(struct inode*); void idecref(struct inode*);
void iincref(struct inode*); struct inode* iincref(struct inode*);
void iput(struct inode*); void iput(struct inode*);
struct inode* namei(char*, int, uint*, char**, struct inode**); struct inode* namei(char*, int, uint*, char**, struct inode**);
void stati(struct inode*, struct stat*); void stati(struct inode*, struct stat*);

10
fs.c
View file

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

3
proc.c
View file

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