diff options
| author | rsc <rsc> | 2007-08-08 09:30:42 +0000 | 
|---|---|---|
| committer | rsc <rsc> | 2007-08-08 09:30:42 +0000 | 
| commit | d80b06a1e0232f4c5e9b9c8ff635e4022e13667c (patch) | |
| tree | a8967e433841b6987fbc1025564d339590c9fe67 | |
| parent | 35a24c8318dd784b62c57b1933ded6e880faaa55 (diff) | |
| download | xv6-labs-d80b06a1e0232f4c5e9b9c8ff635e4022e13667c.tar.gz xv6-labs-d80b06a1e0232f4c5e9b9c8ff635e4022e13667c.tar.bz2 xv6-labs-d80b06a1e0232f4c5e9b9c8ff635e4022e13667c.zip | |
iincref returns new ref
| -rw-r--r-- | defs.h | 2 | ||||
| -rw-r--r-- | fs.c | 10 | ||||
| -rw-r--r-- | proc.c | 3 | 
3 files changed, 7 insertions, 8 deletions
| @@ -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*); @@ -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);    } @@ -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;  } | 
