diff options
| author | Frans Kaashoek <kaashoek@mit.edu> | 2018-10-07 18:14:53 -0400 | 
|---|---|---|
| committer | Frans Kaashoek <kaashoek@mit.edu> | 2018-10-07 18:14:53 -0400 | 
| commit | f241e67d911d790376de26698f8bf8ba02550212 (patch) | |
| tree | 7d51923123e041681a84e95f23518941ebd741c2 | |
| parent | 704775b63d2d78445e45a8b65e87a67abbc45e75 (diff) | |
| download | xv6-labs-f241e67d911d790376de26698f8bf8ba02550212.tar.gz xv6-labs-f241e67d911d790376de26698f8bf8ba02550212.tar.bz2 xv6-labs-f241e67d911d790376de26698f8bf8ba02550212.zip | |
x
| -rw-r--r-- | syscall.c | 25 | 
1 files changed, 13 insertions, 12 deletions
| @@ -25,6 +25,17 @@ fetchint(uint64 addr, int *ip)    return 0;  } +// Fetch the uint64 at addr from the current process. +int +fetchaddr(uint64 addr, uint64 *ip) +{ +  struct proc *curproc = myproc(); +  if(addr >= curproc->sz || addr+sizeof(uint64) > curproc->sz) +    return -1; +  *ip = *(uint64*)(addr); +  return 0; +} +  // Fetch the nul-terminated string at addr from the current process.  // Doesn't actually copy the string - just sets *pp to point at it.  // Returns length of string, not including nul. @@ -67,16 +78,6 @@ fetcharg(int n)    return -1;  } -int -fetchaddr(uint64 addr, uint64 *ip) -{ -  struct proc *curproc = myproc(); -  if(addr >= curproc->sz || addr+sizeof(uint64) > curproc->sz) -    return -1; -  *ip = *(uint64*)(addr); -  return 0; -} -  // Fetch the nth 32-bit system call argument.  int  argint(int n, int *ip) @@ -116,8 +117,8 @@ argptr(int n, char **pp, int size)  int  argstr(int n, char **pp)  { -  int addr; -  if(argint(n, &addr) < 0) +  uint64 addr; +  if(argaddr(n, &addr) < 0)      return -1;    return fetchstr(addr, pp);  } | 
