mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-05 16:14:38 +00:00
LibCore: Add syscall wrapper for gethostname()
This commit is contained in:
committed by
Andreas Kling
parent
8c4625e3b1
commit
951d8a06d8
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Kenneth Myhra <kennethmyhra@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@@ -195,4 +196,13 @@ ErrorOr<String> ptsname(int fd)
|
||||
return String(name);
|
||||
}
|
||||
|
||||
ErrorOr<String> gethostname()
|
||||
{
|
||||
char hostname[256];
|
||||
int rc = ::gethostname(hostname, sizeof(hostname));
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("gethostname"sv, -errno);
|
||||
return String(&hostname[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,5 +32,6 @@ ErrorOr<ssize_t> write(int fd, void const* data, size_t data_size);
|
||||
ErrorOr<void> kill(pid_t, int signal);
|
||||
ErrorOr<int> dup2(int source_fd, int destination_fd);
|
||||
ErrorOr<String> ptsname(int fd);
|
||||
ErrorOr<String> gethostname();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user