LibCore: Add wrapper for posix_openpt(), grantpt() and unlockpt()

This commit is contained in:
Lucas CHOLLET 2022-03-01 23:44:53 +01:00 committed by Andreas Kling
parent ddf9987c39
commit 5d29f64c99
Notes: sideshowbarker 2024-07-17 18:03:16 +09:00
2 changed files with 27 additions and 0 deletions

View file

@ -1084,4 +1084,28 @@ ErrorOr<void> setenv(StringView name, StringView value, bool overwrite)
return {};
}
ErrorOr<int> posix_openpt(int flags)
{
int const rc = ::posix_openpt(flags);
if (rc < 0)
return Error::from_syscall("posix_openpt", -errno);
return rc;
}
ErrorOr<void> grantpt(int fildes)
{
auto const rc = ::grantpt(fildes);
if (rc < 0)
return Error::from_syscall("grantpt", -errno);
return {};
}
ErrorOr<void> unlockpt(int fildes)
{
auto const rc = ::unlockpt(fildes);
if (rc < 0)
return Error::from_syscall("unlockpt", -errno);
return {};
}
}

View file

@ -146,5 +146,8 @@ ErrorOr<Vector<gid_t>> getgroups();
ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev);
ErrorOr<void> mkfifo(StringView pathname, mode_t mode);
ErrorOr<void> setenv(StringView, StringView, bool);
ErrorOr<int> posix_openpt(int flags);
ErrorOr<void> grantpt(int fildes);
ErrorOr<void> unlockpt(int fildes);
}