diff options
author | Ian Moffett <ian@osmora.org> | 2024-04-25 00:57:02 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-04-25 00:57:02 -0400 |
commit | dbea81051df560226be46a149457e693337357d9 (patch) | |
tree | d07b5343746fb1242a25092fac6f241e154ea8d1 | |
parent | 3c50e6cf145ef8e9d661a80d40e85bceefca7dfa (diff) |
kernel: vm_map: Refactor mmap()
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/vm/vm_map.c | 10 |
1 files changed, 6 insertions, 4 deletions
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; + } } |