From 7585cb5ad84babe9db8c6595de464e33fb878f0c Mon Sep 17 00:00:00 2001 From: sotech117 Date: Mon, 13 May 2024 12:10:55 +0000 Subject: s5 fixes and issues with weenix --- kernel/api/access.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'kernel/api/access.c') 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 -- cgit v1.2.3-70-g09d2