mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibCore: Add syscall wrapper for gethostname()
This commit is contained in:
parent
8c4625e3b1
commit
951d8a06d8
2 changed files with 11 additions and 0 deletions
|
@ -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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue