nits
This commit is contained in:
parent
13491bf367
commit
e79b16598c
1 changed files with 7 additions and 17 deletions
24
sysfile.c
24
sysfile.c
|
@ -213,7 +213,7 @@ sys_unlink(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct inode*
|
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;
|
uint off;
|
||||||
struct inode *ip, *dp;
|
struct inode *ip, *dp;
|
||||||
|
@ -240,8 +240,6 @@ mkpath(char *path, int canexist, short type, short major, short minor)
|
||||||
ilock(ip);
|
ilock(ip);
|
||||||
ip->major = major;
|
ip->major = major;
|
||||||
ip->minor = minor;
|
ip->minor = minor;
|
||||||
ip->size = 0;
|
|
||||||
ip->nlink = 1;
|
|
||||||
iupdate(ip);
|
iupdate(ip);
|
||||||
|
|
||||||
if(dirlink(dp, name, ip->inum) < 0){
|
if(dirlink(dp, name, ip->inum) < 0){
|
||||||
|
@ -256,7 +254,7 @@ mkpath(char *path, int canexist, short type, short major, short minor)
|
||||||
iupdate(dp);
|
iupdate(dp);
|
||||||
// No ip->nlink++ for ".": avoid cyclic ref count.
|
// No ip->nlink++ for ".": avoid cyclic ref count.
|
||||||
if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
|
if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
|
||||||
panic("mkpath dots");
|
panic("create dots");
|
||||||
}
|
}
|
||||||
iunlockput(dp);
|
iunlockput(dp);
|
||||||
return ip;
|
return ip;
|
||||||
|
@ -274,7 +272,7 @@ sys_open(void)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(omode & O_CREATE){
|
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;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
if((ip = namei(path)) == 0)
|
if((ip = namei(path)) == 0)
|
||||||
|
@ -297,16 +295,8 @@ sys_open(void)
|
||||||
f->type = FD_INODE;
|
f->type = FD_INODE;
|
||||||
f->ip = ip;
|
f->ip = ip;
|
||||||
f->off = 0;
|
f->off = 0;
|
||||||
if(omode & O_RDWR) {
|
f->readable = !(omode & O_WRONLY);
|
||||||
f->readable = 1;
|
f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
|
||||||
f->writable = 1;
|
|
||||||
} else if(omode & O_WRONLY) {
|
|
||||||
f->readable = 0;
|
|
||||||
f->writable = 1;
|
|
||||||
} else {
|
|
||||||
f->readable = 1;
|
|
||||||
f->writable = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +312,7 @@ sys_mknod(void)
|
||||||
if((len=argstr(0, &path)) < 0 ||
|
if((len=argstr(0, &path)) < 0 ||
|
||||||
argint(1, &major) < 0 ||
|
argint(1, &major) < 0 ||
|
||||||
argint(2, &minor) < 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;
|
return -1;
|
||||||
iunlockput(ip);
|
iunlockput(ip);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -334,7 +324,7 @@ sys_mkdir(void)
|
||||||
char *path;
|
char *path;
|
||||||
struct inode *ip;
|
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;
|
return -1;
|
||||||
iunlockput(ip);
|
iunlockput(ip);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue