mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
Kernel: Support sending filedescriptors with sendmsg(2) and SCM_RIGHTS
This is necessary to support the wayland protocol. I also moved the CMSG_* macros to the kernel API since they are used in both kernel and userspace. this does not break ntpquery/SCM_TIMESTAMP.
This commit is contained in:
parent
ae5d7f542c
commit
f20902deb3
5 changed files with 97 additions and 37 deletions
|
@ -520,6 +520,26 @@ ErrorOr<NonnullLockRefPtr<OpenFileDescription>> LocalSocket::recvfd(OpenFileDesc
|
|||
return queue.take_first();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtrVector<OpenFileDescription>> LocalSocket::recvfds(OpenFileDescription const& socket_description, int n)
|
||||
{
|
||||
MutexLocker locker(mutex());
|
||||
NonnullLockRefPtrVector<OpenFileDescription> fds;
|
||||
|
||||
auto role = this->role(socket_description);
|
||||
if (role != Role::Connected && role != Role::Accepted)
|
||||
return set_so_error(EINVAL);
|
||||
auto& queue = recvfd_queue_for(socket_description);
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (queue.is_empty())
|
||||
break;
|
||||
|
||||
fds.append(queue.take_first());
|
||||
}
|
||||
|
||||
return fds;
|
||||
}
|
||||
|
||||
ErrorOr<void> LocalSocket::try_set_path(StringView path)
|
||||
{
|
||||
m_path = TRY(KString::try_create(path));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue