mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
28 lines
437 B
C
28 lines
437 B
C
#include <kernel/syscalls.h>
|
|
#include <kernel/mm.h>
|
|
#include <errno.h>
|
|
|
|
syscallret_t syscall_munmap(context_t *ctx, void *addr, size_t length) {
|
|
syscallret_t ret = {
|
|
.ret = -1,
|
|
.errno = 0
|
|
};
|
|
|
|
if (addr > USERSPACE_END) {
|
|
ret.errno = EFAULT;
|
|
return ret;
|
|
}
|
|
|
|
if (length == 0 || (uintptr_t)addr % PAGE_SIZE > 0) {
|
|
ret.errno = EINVAL;
|
|
return ret;
|
|
}
|
|
|
|
mm_unmap(addr, length, 0);
|
|
|
|
ret.ret = 0;
|
|
ret.errno = 0;
|
|
|
|
return ret;
|
|
}
|