1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:05:08 +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:
Andreas Kling 2020-01-11 12:47:47 +01:00
parent 1434f30f92
commit 24c736b0e7
8 changed files with 148 additions and 121 deletions

View file

@ -539,11 +539,19 @@ int pthread_setspecific(pthread_key_t key, const void* value)
}
int pthread_setname_np(pthread_t thread, const char* buffer, int buffer_size)
{
if (buffer_size < 0) {
errno = EINVAL;
return -1;
}
return syscall(SC_set_thread_name, thread, buffer, buffer_size);
}
int pthread_getname_np(pthread_t thread, char* buffer, int buffer_size)
{
if (buffer_size < 0) {
errno = EINVAL;
return -1;
}
return syscall(SC_get_thread_name, thread, buffer, buffer_size);
}