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 /syscall.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 'syscall.c')
-rw-r--r-- | syscall.c | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -17,7 +17,9 @@ int fetchint(uint addr, int *ip) { - if(addr >= proc->sz || addr+4 > proc->sz) + struct proc *curproc = myproc(); + + if(addr >= curproc->sz || addr+4 > curproc->sz) return -1; *ip = *(int*)(addr); return 0; @@ -30,14 +32,16 @@ int fetchstr(uint addr, char **pp) { char *s, *ep; + struct proc *curproc = myproc(); - if(addr >= proc->sz) + if(addr >= curproc->sz) return -1; *pp = (char*)addr; - ep = (char*)proc->sz; - for(s = *pp; s < ep; s++) + ep = (char*)curproc->sz; + for(s = *pp; s < ep; s++){ if(*s == 0) return s - *pp; + } return -1; } @@ -45,7 +49,7 @@ fetchstr(uint addr, char **pp) int argint(int n, int *ip) { - return fetchint(proc->tf->esp + 4 + 4*n, ip); + return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); } // Fetch the nth word-sized system call argument as a pointer @@ -55,10 +59,11 @@ int argptr(int n, char **pp, int size) { int i; - + struct proc *curproc = myproc(); + if(argint(n, &i) < 0) return -1; - if(size < 0 || (uint)i >= proc->sz || (uint)i+size > proc->sz) + if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) return -1; *pp = (char*)i; return 0; @@ -127,13 +132,14 @@ void syscall(void) { int num; + struct proc *curproc = myproc(); - num = proc->tf->eax; + num = curproc->tf->eax; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { - proc->tf->eax = syscalls[num](); + curproc->tf->eax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", - proc->pid, proc->name, num); - proc->tf->eax = -1; + curproc->pid, curproc->name, num); + curproc->tf->eax = -1; } } |