summaryrefslogtreecommitdiff
path: root/sysfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysfile.c')
-rw-r--r--sysfile.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sysfile.c b/sysfile.c
index 98e8c43..87e508b 100644
--- a/sysfile.c
+++ b/sysfile.c
@@ -26,7 +26,7 @@ argfd(int n, int *pfd, struct file **pf)
if(argint(n, &fd) < 0)
return -1;
- if(fd < 0 || fd >= NOFILE || (f=proc->ofile[fd]) == 0)
+ if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
return -1;
if(pfd)
*pfd = fd;
@@ -41,10 +41,11 @@ static int
fdalloc(struct file *f)
{
int fd;
+ struct proc *curproc = myproc();
for(fd = 0; fd < NOFILE; fd++){
- if(proc->ofile[fd] == 0){
- proc->ofile[fd] = f;
+ if(curproc->ofile[fd] == 0){
+ curproc->ofile[fd] = f;
return fd;
}
}
@@ -97,7 +98,7 @@ sys_close(void)
if(argfd(0, &fd, &f) < 0)
return -1;
- proc->ofile[fd] = 0;
+ myproc()->ofile[fd] = 0;
fileclose(f);
return 0;
}
@@ -373,7 +374,8 @@ sys_chdir(void)
{
char *path;
struct inode *ip;
-
+ struct proc *curproc = myproc();
+
begin_op();
if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){
end_op();
@@ -386,9 +388,9 @@ sys_chdir(void)
return -1;
}
iunlock(ip);
- iput(proc->cwd);
+ iput(curproc->cwd);
end_op();
- proc->cwd = ip;
+ curproc->cwd = ip;
return 0;
}
@@ -432,7 +434,7 @@ sys_pipe(void)
fd0 = -1;
if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
if(fd0 >= 0)
- proc->ofile[fd0] = 0;
+ myproc()->ofile[fd0] = 0;
fileclose(rf);
fileclose(wf);
return -1;