Skip to content
Snippets Groups Projects
Commit e79b1659 authored by rsc's avatar rsc
Browse files

nits

parent 13491bf3
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment