summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorLuke Payne <1432762+lukepayne@users.noreply.github.com>2020-04-26 15:59:47 +1000
committerAndreas Kling <kling@serenityos.org>2020-04-26 12:59:09 +0200
commitf191b84b5032880f17d3a8973a3b6b21048013dc (patch)
tree0d8d38d3a10fa93e2f49bc1c252f7e22e5929159 /Kernel/Process.cpp
parent03f68a51af9c9cf7bbdffbc2ab7a29ee29dd8464 (diff)
downloadserenity-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.cpp12
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);