From dbea81051df560226be46a149457e693337357d9 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 25 Apr 2024 00:57:02 -0400 Subject: kernel: vm_map: Refactor mmap() Signed-off-by: Ian Moffett --- sys/vm/vm_map.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 2d7638e..05f4c20 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -321,12 +321,12 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) size_t misalign = ((vaddr_t)addr) & (GRANULE - 1); paddr_t physmem = 0; - mapping->prot = prot | PROT_USER; - /* Ensure of valid prot flags */ if ((prot & ~PROT_MASK) != 0) return MAP_FAILED; + mapping->prot = prot | PROT_USER; + /* * Now we check what type of map request * this is. @@ -364,12 +364,14 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) } /* Did this work? */ - if (physmem == 0 && addr == NULL) + if (physmem == 0 && addr == NULL) { return MAP_FAILED; + } } else if (__TEST(flags, MAP_SHARED)) { physmem = vm_fd_map(addr, prot, len, off, fildes, mapping); - if (physmem == 0) + if (physmem == 0) { return MAP_FAILED; + } } -- cgit v1.2.3