diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 15:54:56 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 15:54:56 +0200 |
commit | 189b342e6f372770395a764ffd88e96ab1ebc1a5 (patch) | |
tree | 7c574d48c8c03d1759f5e1556e7721fa50971528 /Kernel | |
parent | 5f26f83451ea046f76d1bb019510548714408de6 (diff) | |
download | serenity-189b342e6f372770395a764ffd88e96ab1ebc1a5.zip |
LibC: Add mmap_with_name() that names the allocation immediately.
This allows us to skip the separate call to set_mmap_name() in code that
we control, e.g malloc() and GraphicsBitmap.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.cpp | 7 | ||||
-rw-r--r-- | Kernel/Syscall.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index af6a8f2911..5bb934088f 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -151,12 +151,15 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params) { if (!validate_read(params, sizeof(Syscall::SC_mmap_params))) return (void*)-EFAULT; + if (params->name && !validate_read_str(params->name)) + return (void*)-EFAULT; void* addr = (void*)params->addr; size_t size = params->size; int prot = params->prot; int flags = params->flags; int fd = params->fd; off_t offset = params->offset; + const char* name = params->name; if (size == 0) return (void*)-EINVAL; if ((dword)addr & ~PAGE_MASK) @@ -167,6 +170,8 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params) return (void*)-ENOMEM; if (flags & MAP_SHARED) region->set_shared(true); + if (name) + region->set_name(name); return region->laddr().as_ptr(); } if (offset & ~PAGE_MASK) @@ -180,6 +185,8 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params) auto region = region_or_error.value(); if (flags & MAP_SHARED) region->set_shared(true); + if (name) + region->set_name(name); return region->laddr().as_ptr(); } diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index d2c884bade..5f66bb1df3 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -134,6 +134,7 @@ struct SC_mmap_params { int32_t flags; int32_t fd; int32_t offset; // FIXME: 64-bit off_t? + const char* name { nullptr }; }; struct SC_select_params { |