diff options
author | Robert Morris <[email protected]> | 2017-08-08 13:27:06 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2017-08-08 13:27:06 -0400 |
commit | 14270288b7e5327832cdf6a8d9da52ef58fce652 (patch) | |
tree | b604cb49fb049a14966418eda4589cd1271f8e53 /sysfile.c | |
parent | aba8423c4a5ae01828040d04f668f07ec544dcd0 (diff) | |
parent | 825ce074b10a0e1f63fd3a1fe245220d04054e0a (diff) | |
download | xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.tar.gz xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.tar.bz2 xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.zip |
Merge branch 'master' of g.csail.mit.edu:xv6-dev
Diffstat (limited to 'sysfile.c')
-rw-r--r-- | sysfile.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -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; |