summaryrefslogtreecommitdiff
path: root/Libraries
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 /Libraries
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 'Libraries')
-rw-r--r--Libraries/LibC/unistd.cpp6
-rw-r--r--Libraries/LibC/unistd.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp
index 8b03c9df3e..03c44bd060 100644
--- a/Libraries/LibC/unistd.cpp
+++ b/Libraries/LibC/unistd.cpp
@@ -352,6 +352,12 @@ int gethostname(char* buffer, size_t size)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
+int sethostname(const char* hostname, ssize_t size)
+{
+ int rc = syscall(SC_sethostname, hostname, size);
+ __RETURN_WITH_ERRNO(rc, rc, -1);
+}
+
ssize_t readlink(const char* path, char* buffer, size_t size)
{
Syscall::SC_readlink_params params { { path, strlen(path) }, { buffer, size } };
diff --git a/Libraries/LibC/unistd.h b/Libraries/LibC/unistd.h
index bf8e80068c..7ed9ebeee8 100644
--- a/Libraries/LibC/unistd.h
+++ b/Libraries/LibC/unistd.h
@@ -104,6 +104,7 @@ int stat(const char* path, struct stat* statbuf);
int sleep(unsigned seconds);
int usleep(useconds_t);
int gethostname(char*, size_t);
+int sethostname(const char*, ssize_t);
ssize_t readlink(const char* path, char* buffer, size_t);
char* ttyname(int fd);
int ttyname_r(int fd, char* buffer, size_t);