summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/System.cpp
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2022-01-14 10:20:29 +0100
committerIdan Horowitz <idan.horowitz@gmail.com>2022-01-14 19:42:19 +0200
commitb3b40ae1fad25e04493836259fc87ef91f67aa8b (patch)
treed52d4829847c211e3fc9e003136e6e2b503ab6a2 /Userland/Libraries/LibCore/System.cpp
parent81532829233431b12f325df3f09a5e86460117b1 (diff)
downloadserenity-b3b40ae1fad25e04493836259fc87ef91f67aa8b.zip
LibCore: Add wrapper for sethostname
Diffstat (limited to 'Userland/Libraries/LibCore/System.cpp')
-rw-r--r--Userland/Libraries/LibCore/System.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index f29fb758ca..bbc1a08684 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -352,6 +352,14 @@ ErrorOr<String> gethostname()
return String(&hostname[0]);
}
+ErrorOr<void> sethostname(StringView hostname)
+{
+ int rc = ::sethostname(hostname.characters_without_null_termination(), hostname.length());
+ if (rc < 0)
+ return Error::from_syscall("sethostname"sv, -errno);
+ return {};
+}
+
ErrorOr<String> getcwd()
{
auto* cwd = ::getcwd(nullptr, 0);