iincref returns new ref
This commit is contained in:
parent
35a24c8318
commit
d80b06a1e0
3 changed files with 7 additions and 8 deletions
2
defs.h
2
defs.h
|
@ -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
10
fs.c
|
@ -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
3
proc.c
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue