diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index b9002a7057b..e99682714aa 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -45,9 +45,9 @@ static Atomic next_pid; static Singleton> s_all_instances; READONLY_AFTER_INIT Memory::Region* g_signal_trampoline_region; -static Singleton> s_hostname; +static Singleton>> s_hostname; -MutexProtected& hostname() +MutexProtected>& hostname() { return *s_hostname; } @@ -73,7 +73,7 @@ UNMAP_AFTER_INIT void Process::initialize() // Note: This is called before scheduling is initialized, and before APs are booted. // So we can "safely" bypass the lock here. - reinterpret_cast(hostname()) = "courage"; + reinterpret_cast&>(hostname()) = KString::must_create("courage"sv); create_signal_trampoline(); } diff --git a/Kernel/Process.h b/Kernel/Process.h index 416da472d52..090a7d9da9c 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -39,7 +39,7 @@ namespace Kernel { -MutexProtected& hostname(); +MutexProtected>& hostname(); Time kgettimeofday(); #define ENUMERATE_PLEDGE_PROMISES \ diff --git a/Kernel/Syscalls/hostname.cpp b/Kernel/Syscalls/hostname.cpp index da30c4d2bcb..8c96a39a44d 100644 --- a/Kernel/Syscalls/hostname.cpp +++ b/Kernel/Syscalls/hostname.cpp @@ -15,9 +15,9 @@ ErrorOr Process::sys$gethostname(Userspace buffer, size_t size) if (size > NumericLimits::max()) return EINVAL; return hostname().with_shared([&](const auto& name) -> ErrorOr { - if (size < (name.length() + 1)) + if (size < (name->length() + 1)) return ENAMETOOLONG; - TRY(copy_to_user(buffer, name.characters(), name.length() + 1)); + TRY(copy_to_user(buffer, name->characters(), name->length() + 1)); return 0; }); } @@ -33,7 +33,7 @@ ErrorOr Process::sys$sethostname(Userspace buffer, size_t return ENAMETOOLONG; auto new_name = TRY(try_copy_kstring_from_user(buffer, length)); hostname().with_exclusive([&](auto& name) { - name = new_name->view(); + name = move(new_name); }); return 0; } diff --git a/Kernel/Syscalls/uname.cpp b/Kernel/Syscalls/uname.cpp index ab6ac949efe..b652630bb83 100644 --- a/Kernel/Syscalls/uname.cpp +++ b/Kernel/Syscalls/uname.cpp @@ -24,7 +24,7 @@ ErrorOr Process::sys$uname(Userspace user_buf) #endif hostname().with_shared([&](const auto& name) { - memcpy(buf.nodename, name.characters(), name.length() + 1); + memcpy(buf.nodename, name->characters(), name->length() + 1); }); TRY(copy_to_user(user_buf, &buf));