argptr no longer needed, since copyin checks
This commit is contained in:
parent
629faafa36
commit
6507da772d
3 changed files with 11 additions and 26 deletions
|
@ -130,7 +130,6 @@ char* strncpy(char*, const char*, int);
|
||||||
|
|
||||||
// syscall.c
|
// syscall.c
|
||||||
int argint(int, int*);
|
int argint(int, int*);
|
||||||
int argptr(int, uint64*, int);
|
|
||||||
int argstr(int, char*, int);
|
int argstr(int, char*, int);
|
||||||
int argaddr(int, uint64 *);
|
int argaddr(int, uint64 *);
|
||||||
int fetchstr(uint64, char*, int);
|
int fetchstr(uint64, char*, int);
|
||||||
|
|
|
@ -33,7 +33,7 @@ fetchstr(uint64 addr, char *buf, int max)
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64
|
static uint64
|
||||||
fetcharg(int n)
|
argraw(int n)
|
||||||
{
|
{
|
||||||
struct proc *p = myproc();
|
struct proc *p = myproc();
|
||||||
switch (n) {
|
switch (n) {
|
||||||
|
@ -50,7 +50,7 @@ fetcharg(int n)
|
||||||
case 5:
|
case 5:
|
||||||
return p->tf->a5;
|
return p->tf->a5;
|
||||||
}
|
}
|
||||||
panic("fetcharg");
|
panic("argraw");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,31 +58,17 @@ fetcharg(int n)
|
||||||
int
|
int
|
||||||
argint(int n, int *ip)
|
argint(int n, int *ip)
|
||||||
{
|
{
|
||||||
*ip = fetcharg(n);
|
*ip = argraw(n);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve an argument as a pointer.
|
||||||
|
// Doesn't check for legality, since
|
||||||
|
// copyin/copyout will do that.
|
||||||
int
|
int
|
||||||
argaddr(int n, uint64 *ip)
|
argaddr(int n, uint64 *ip)
|
||||||
{
|
{
|
||||||
*ip = fetcharg(n);
|
*ip = argraw(n);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch the nth word-sized system call argument as a pointer
|
|
||||||
// to a block of memory of size bytes. Check that the pointer
|
|
||||||
// lies within the process address space.
|
|
||||||
int
|
|
||||||
argptr(int n, uint64 *pp, int size)
|
|
||||||
{
|
|
||||||
uint64 i;
|
|
||||||
struct proc *p = myproc();
|
|
||||||
|
|
||||||
if(argaddr(n, &i) < 0)
|
|
||||||
return -1;
|
|
||||||
if(size < 0 || (uint)i >= p->sz || (uint)i+size > p->sz)
|
|
||||||
return -1;
|
|
||||||
*pp = i;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ sys_read(void)
|
||||||
int n;
|
int n;
|
||||||
uint64 p;
|
uint64 p;
|
||||||
|
|
||||||
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
|
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return fileread(f, p, n);
|
return fileread(f, p, n);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ sys_write(void)
|
||||||
int n;
|
int n;
|
||||||
uint64 p;
|
uint64 p;
|
||||||
|
|
||||||
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
|
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return filewrite(f, p, n);
|
return filewrite(f, p, n);
|
||||||
|
@ -110,7 +110,7 @@ sys_fstat(void)
|
||||||
struct file *f;
|
struct file *f;
|
||||||
uint64 st; // user pointer to struct stat
|
uint64 st; // user pointer to struct stat
|
||||||
|
|
||||||
if(argfd(0, 0, &f) < 0 || argptr(1, &st, sizeof(struct stat)) < 0)
|
if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return filestat(f, st);
|
return filestat(f, st);
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ sys_pipe(void)
|
||||||
int fd0, fd1;
|
int fd0, fd1;
|
||||||
struct proc *p = myproc();
|
struct proc *p = myproc();
|
||||||
|
|
||||||
if(argptr(0, &fdarray, 2*sizeof(int)) < 0)
|
if(argaddr(0, &fdarray) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if(pipealloc(&rf, &wf) < 0)
|
if(pipealloc(&rf, &wf) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in a new issue