LibCore: Add syscall wrappers for sendfd() and recvfd()
This commit is contained in:
parent
86a3ef2709
commit
982ac34437
Notes:
sideshowbarker
2024-07-18 00:33:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/982ac34437f
2 changed files with 18 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
|
||||
|
@ -49,6 +50,21 @@ ErrorOr<Array<int, 2>> pipe2(int flags)
|
|||
return Error::from_syscall("pipe2"sv, -errno);
|
||||
return fds;
|
||||
}
|
||||
|
||||
ErrorOr<void> sendfd(int sockfd, int fd)
|
||||
{
|
||||
if (::sendfd(sockfd, fd) < 0)
|
||||
return Error::from_syscall("sendfd"sv, -errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<int> recvfd(int sockfd, int options)
|
||||
{
|
||||
auto fd = ::recvfd(sockfd, options);
|
||||
if (fd < 0)
|
||||
return Error::from_syscall("recvfd"sv, -errno);
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action)
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace Core::System {
|
|||
ErrorOr<void> pledge(StringView promises, StringView execpromises = {});
|
||||
ErrorOr<void> unveil(StringView path, StringView permissions);
|
||||
ErrorOr<Array<int, 2>> pipe2(int flags);
|
||||
ErrorOr<void> sendfd(int sockfd, int fd);
|
||||
ErrorOr<int> recvfd(int sockfd, int options);
|
||||
#endif
|
||||
|
||||
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);
|
||||
|
|
Loading…
Add table
Reference in a new issue