support read() and write() bigger than one page

This commit is contained in:
Robert Morris 2019-06-04 05:57:47 -04:00
parent cefe223bf5
commit 8baac76050
12 changed files with 95 additions and 62 deletions

29
proc.c
View file

@ -526,3 +526,32 @@ kill(int pid)
}
#endif
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.
int
either_copyout(int user_dst, uint64 dst, char *src, uint64 len)
{
struct proc *p = myproc();
if(user_dst){
return copyout(p->pagetable, dst, src, len);
} else {
memmove((char *)dst, src, len);
}
}
// Copy from either a user address, or kernel address,
// depending on usr_src.
// Returns 0 on success, -1 on error.
int
either_copyin(char *dst, int user_src, uint64 src, uint64 len)
{
struct proc *p = myproc();
if(user_src){
return copyin(p->pagetable, dst, src, len);
} else {
memmove(dst, (char*)src, len);
}
}