mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
LibCore: Add syscall wrapper for gethostname()
This commit is contained in:
parent
8c4625e3b1
commit
951d8a06d8
Notes:
sideshowbarker
2024-07-18 00:38:11 +09:00
Author: https://github.com/kennethmyhra
Commit: 951d8a06d8
Pull-request: https://github.com/SerenityOS/serenity/pull/11096
2 changed files with 11 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Kenneth Myhra <kennethmyhra@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -195,4 +196,13 @@ ErrorOr<String> ptsname(int fd)
|
||||||
return String(name);
|
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<void> kill(pid_t, int signal);
|
||||||
ErrorOr<int> dup2(int source_fd, int destination_fd);
|
ErrorOr<int> dup2(int source_fd, int destination_fd);
|
||||||
ErrorOr<String> ptsname(int fd);
|
ErrorOr<String> ptsname(int fd);
|
||||||
|
ErrorOr<String> gethostname();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue