mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
LibCore: Add wrapper for sethostname
This commit is contained in:
parent
8153282923
commit
b3b40ae1fa
2 changed files with 10 additions and 0 deletions
|
@ -352,6 +352,14 @@ ErrorOr<String> gethostname()
|
||||||
return String(&hostname[0]);
|
return String(&hostname[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> sethostname(StringView hostname)
|
||||||
|
{
|
||||||
|
int rc = ::sethostname(hostname.characters_without_null_termination(), hostname.length());
|
||||||
|
if (rc < 0)
|
||||||
|
return Error::from_syscall("sethostname"sv, -errno);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<String> getcwd()
|
ErrorOr<String> getcwd()
|
||||||
{
|
{
|
||||||
auto* cwd = ::getcwd(nullptr, 0);
|
auto* cwd = ::getcwd(nullptr, 0);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Error.h>
|
#include <AK/Error.h>
|
||||||
|
#include <AK/StringView.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
@ -72,6 +73,7 @@ ErrorOr<int> dup(int source_fd);
|
||||||
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();
|
ErrorOr<String> gethostname();
|
||||||
|
ErrorOr<void> sethostname(StringView);
|
||||||
ErrorOr<String> getcwd();
|
ErrorOr<String> getcwd();
|
||||||
ErrorOr<void> ioctl(int fd, unsigned request, ...);
|
ErrorOr<void> ioctl(int fd, unsigned request, ...);
|
||||||
ErrorOr<struct termios> tcgetattr(int fd);
|
ErrorOr<struct termios> tcgetattr(int fd);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue