diff options
| author | rsc <rsc> | 2007-08-27 14:39:50 +0000 | 
|---|---|---|
| committer | rsc <rsc> | 2007-08-27 14:39:50 +0000 | 
| commit | e79b16598cce3a69d5f4711a6795cec9037056b7 (patch) | |
| tree | 76ddea26e10ded1d93f0a2c3a99dc0efd8568998 | |
| parent | 13491bf367a64f65cf77b8a8fbc89c146db4fae8 (diff) | |
| download | xv6-labs-e79b16598cce3a69d5f4711a6795cec9037056b7.tar.gz xv6-labs-e79b16598cce3a69d5f4711a6795cec9037056b7.tar.bz2 xv6-labs-e79b16598cce3a69d5f4711a6795cec9037056b7.zip | |
nits
| -rw-r--r-- | sysfile.c | 24 | 
1 files changed, 7 insertions, 17 deletions
| @@ -213,7 +213,7 @@ sys_unlink(void)  }  static struct inode* -mkpath(char *path, int canexist, short type, short major, short minor) +create(char *path, int canexist, short type, short major, short minor)  {    uint off;    struct inode *ip, *dp; @@ -240,8 +240,6 @@ mkpath(char *path, int canexist, short type, short major, short minor)    ilock(ip);    ip->major = major;    ip->minor = minor; -  ip->size = 0; -  ip->nlink = 1;    iupdate(ip);    if(dirlink(dp, name, ip->inum) < 0){ @@ -256,7 +254,7 @@ mkpath(char *path, int canexist, short type, short major, short minor)      iupdate(dp);      // No ip->nlink++ for ".": avoid cyclic ref count.      if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) -      panic("mkpath dots"); +      panic("create dots");    }    iunlockput(dp);    return ip; @@ -274,7 +272,7 @@ sys_open(void)      return -1;    if(omode & O_CREATE){ -    if((ip = mkpath(path, 1, T_FILE, 0, 0)) == 0) +    if((ip = create(path, 1, T_FILE, 0, 0)) == 0)        return -1;    }else{      if((ip = namei(path)) == 0) @@ -297,16 +295,8 @@ sys_open(void)    f->type = FD_INODE;    f->ip = ip;    f->off = 0; -  if(omode & O_RDWR) { -    f->readable = 1; -    f->writable = 1; -  } else if(omode & O_WRONLY) { -    f->readable = 0; -    f->writable = 1; -  } else { -    f->readable = 1; -    f->writable = 0; -  } +  f->readable = !(omode & O_WRONLY); +  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);    return fd;  } @@ -322,7 +312,7 @@ sys_mknod(void)    if((len=argstr(0, &path)) < 0 ||       argint(1, &major) < 0 ||       argint(2, &minor) < 0 || -     (ip = mkpath(path, 0, T_DEV, major, minor)) == 0) +     (ip = create(path, 0, T_DEV, major, minor)) == 0)      return -1;    iunlockput(ip);    return 0; @@ -334,7 +324,7 @@ sys_mkdir(void)    char *path;    struct inode *ip; -  if(argstr(0, &path) < 0 || (ip = mkpath(path, 0, T_DIR, 0, 0)) == 0) +  if(argstr(0, &path) < 0 || (ip = create(path, 0, T_DIR, 0, 0)) == 0)      return -1;    iunlockput(ip);    return 0; | 
