Skip to content
Snippets Groups Projects
Commit 80331b15 authored by Fache Charles's avatar Fache Charles
Browse files

4.11 passes all tests

parent 1d265655
No related branches found
Tags tp2-act-4-11
No related merge requests found
......@@ -356,8 +356,7 @@ uvmclear(pagetable_t pagetable, uint64 va)
int load_from_file(char* file,
uint64 file_start_offset,
uint64 pa,
uint64 nbytes
){
uint64 nbytes){
struct inode* ip;
begin_op(ROOTDEV);
if((ip = namei(file)) == 0){
......@@ -405,7 +404,23 @@ int do_allocate(pagetable_t pagetable, struct proc* p, uint64 addr){
}
int do_allocate_range(pagetable_t pagetable, struct proc* p, uint64 addr, uint64 len){
return 0;
int ret = 0;
uint64 base = PGROUNDDOWN(addr);
if(addr + len < base) return ENOVMA;
acquire(&p->vma_lock);
while(base < addr + len) {
ret = do_allocate(pagetable, p, base);
if (ret) {
release(&p->vma_lock);
return ret;}
base += PGSIZE;
}
release(&p->vma_lock);
return ret;
}
// Copy from kernel to user.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment