diff options
author | Luke Payne <1432762+lukepayne@users.noreply.github.com> | 2020-04-26 15:59:47 +1000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-26 12:59:09 +0200 |
commit | f191b84b5032880f17d3a8973a3b6b21048013dc (patch) | |
tree | 0d8d38d3a10fa93e2f49bc1c252f7e22e5929159 /Kernel/Process.cpp | |
parent | 03f68a51af9c9cf7bbdffbc2ab7a29ee29dd8464 (diff) | |
download | serenity-f191b84b5032880f17d3a8973a3b6b21048013dc.zip |
Kernel: Added the ability to set the hostname via new syscall
Userland/hostname: Now takes parameter to set the hostname
LibC/unistd: Added sethostname function
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r-- | Kernel/Process.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index ec5befdc5e..c81e9598ed 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -712,6 +712,18 @@ int Process::sys$gethostname(char* buffer, ssize_t size) return 0; } +int Process::sys$sethostname(const char* hostname, ssize_t length) +{ + REQUIRE_PROMISE(stdio); + if (length < 0) + return -EINVAL; + LOCKER(*s_hostname_lock, Lock::Mode::Shared); + if (length > 64) + return -ENAMETOOLONG; + *s_hostname = validate_and_copy_string_from_user(hostname, length); + return 0; +} + pid_t Process::sys$fork(RegisterState& regs) { REQUIRE_PROMISE(proc); |