diff options
author | Andreas Kling <kling@serenityos.org> | 2020-12-29 02:11:47 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-29 02:20:43 +0100 |
commit | 30dbe9c78a50e98befe1e6fa331aaa46ab60a162 (patch) | |
tree | c85d776ae59aaede4362fa005b64fcefff44b666 /Libraries/LibC/mman.cpp | |
parent | c1360ef22e1bf0a3e8745d63ad4f07b13d3acd2c (diff) | |
download | serenity-30dbe9c78a50e98befe1e6fa331aaa46ab60a162.zip |
Kernel+LibC: Add a very limited sys$mremap() implementation
This syscall can currently only remap a shared file-backed mapping into
a private file-backed mapping.
Diffstat (limited to 'Libraries/LibC/mman.cpp')
-rw-r--r-- | Libraries/LibC/mman.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibC/mman.cpp b/Libraries/LibC/mman.cpp index 9dd97d6a1e..3df02a46da 100644 --- a/Libraries/LibC/mman.cpp +++ b/Libraries/LibC/mman.cpp @@ -53,6 +53,17 @@ void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t return serenity_mmap(addr, size, prot, flags, fd, offset, PAGE_SIZE, name); } +void* mremap(void* old_address, size_t old_size, size_t new_size, int flags) +{ + Syscall::SC_mremap_params params { (uintptr_t)old_address, old_size, new_size, flags }; + ssize_t rc = syscall(SC_mremap, ¶ms); + if (rc < 0 && -rc < EMAXERRNO) { + errno = -rc; + return MAP_FAILED; + } + return (void*)rc; +} + int munmap(void* addr, size_t size) { int rc = syscall(SC_munmap, addr, size); |