mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 13:47:35 +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, 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