From e79b16598cce3a69d5f4711a6795cec9037056b7 Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 27 Aug 2007 14:39:50 +0000 Subject: [PATCH] nits --- sysfile.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/sysfile.c b/sysfile.c index 712a220..ab5be04 100644 --- a/sysfile.c +++ b/sysfile.c @@ -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;