diff options
author | sotech117 <michael_foiani@brown.edu> | 2024-05-13 12:10:55 +0000 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2024-05-13 12:10:55 +0000 |
commit | 7585cb5ad84babe9db8c6595de464e33fb878f0c (patch) | |
tree | 3acdd29920420ca341ea7e3f90d60b16c384ce51 /kernel/api/access.c | |
parent | f09878f6327426631d9419d825a4e8396e3b9dc4 (diff) |
s5 fixes and issues with weenix
Diffstat (limited to 'kernel/api/access.c')
-rw-r--r-- | kernel/api/access.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/kernel/api/access.c b/kernel/api/access.c index 9a7bed0..9941971 100644 --- a/kernel/api/access.c +++ b/kernel/api/access.c @@ -118,16 +118,28 @@ long addr_perm(proc_t *p, const void *vaddr, int perm) { // NOT_YET_IMPLEMENTED("VM: addr_perm"); - // loop through the vmareas in the process's vmmap - vmarea_t *vma = vmmap_lookup(p->p_vmmap, ADDR_TO_PN(vaddr)); + // // loop through the vmareas in the process's vmmap + // vmarea_t *vma = vmmap_lookup(p->p_vmmap, ADDR_TO_PN(vaddr)); - // if the vma doesn't exist, return 0 - if (!vma) - { + // // if the vma doesn't exist, return 0 + // if (!vma) + // { + // return 0; + // } + + // return !!(perm & vma->vma_prot); + + // TODO: FIX MEEE + + vmarea_t* area = vmmap_lookup(p->p_vmmap, ADDR_TO_PN(vaddr)); + if (!area) { + return 0; + } + if (perm & area->vma_prot) { + return 1; + } else { return 0; } - - return !!(perm & vma->vma_prot); } /* @@ -145,7 +157,7 @@ long range_perm(proc_t *p, const void *vaddr, size_t len, int perm) // loop through the page numbers in the range size_t vfn = ADDR_TO_PN(vaddr); - size_t end_vfn = ADDR_TO_PN(vaddr + len); + size_t end_vfn = ADDR_TO_PN((uintptr_t)vaddr + len); for (size_t i = vfn; i < end_vfn; i++) { // check the permissions for each page |