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

8
exec.c
View file

@ -30,7 +30,7 @@ exec(char *path, char **argv)
ilock(ip);
// Check ELF header
if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf))
if(readi(ip, 0, (uint64)&elf, 0, sizeof(elf)) != sizeof(elf))
goto bad;
if(elf.magic != ELF_MAGIC)
goto bad;
@ -41,7 +41,7 @@ exec(char *path, char **argv)
// Load program into memory.
sz = 0;
for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph))
if(readi(ip, 0, (uint64)&ph, off, sizeof(ph)) != sizeof(ph))
goto bad;
if(ph.type != ELF_PROG_LOAD)
continue;
@ -128,6 +128,7 @@ loadseg(pagetable_t pagetable, uint64 va, struct inode *ip, uint offset, uint sz
if((va % PGSIZE) != 0)
panic("loadseg: va must be page aligned");
for(i = 0; i < sz; i += PGSIZE){
pa = walkaddr(pagetable, va + i);
if(pa == 0)
@ -136,8 +137,9 @@ loadseg(pagetable_t pagetable, uint64 va, struct inode *ip, uint offset, uint sz
n = sz - i;
else
n = PGSIZE;
if(readi(ip, (char *)pa, offset+i, n) != n)
if(readi(ip, 0, (uint64)pa, offset+i, n) != n)
return -1;
}
return 0;
}