mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 05:08:56 +00:00
Kernel: Use the Syscall string and buffer types more
While I was updating syscalls to stop passing null-terminated strings,
I added some helpful struct types:
- StringArgument { const char*; size_t; }
- ImmutableBuffer<Data, Size> { const Data*; Size; }
- MutableBuffer<Data, Size> { Data*; Size; }
The Process class has some convenience functions for validating and
optionally extracting the contents from these structs:
- get_syscall_path_argument(StringArgument)
- validate_and_copy_string_from_user(StringArgument)
- validate(ImmutableBuffer)
- validate(MutableBuffer)
There's still so much code around this and I'm wondering if we should
generate most of it instead. Possible nice little project.
This commit is contained in:
@@ -711,7 +711,7 @@ char* realpath(const char* pathname, char* buffer)
|
||||
size_t size = PATH_MAX;
|
||||
if (buffer == nullptr)
|
||||
buffer = (char*)malloc(size);
|
||||
Syscall::SC_realpath_params params { pathname, strlen(pathname), buffer, size };
|
||||
Syscall::SC_realpath_params params { { pathname, strlen(pathname) }, { buffer, size } };
|
||||
int rc = syscall(SC_realpath, ¶ms);
|
||||
if (rc < 0) {
|
||||
errno = -rc;
|
||||
|
||||
Reference in New Issue
Block a user