1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

Kernel: Begin implementing UNIX domain sockets.

This commit is contained in:
Andreas Kling 2019-02-14 14:17:38 +01:00
parent dc200923f2
commit 2f35e54f80
12 changed files with 177 additions and 1 deletions

View file

@ -20,6 +20,7 @@
#include "KSyms.h"
#include <WindowServer/WSMessageLoop.h>
#include <Kernel/BochsVGADevice.h>
#include <Kernel/Socket.h>
#include "MasterPTY.h"
#include "elf.h"
@ -2242,3 +2243,41 @@ DisplayInfo Process::set_video_resolution(int width, int height)
BochsVGADevice::the().set_resolution(width, height);
return info;
}
int Process::sys$socket(int domain, int type, int protocol)
{
if (number_of_open_file_descriptors() >= m_max_open_file_descriptors)
return -EMFILE;
int fd = 0;
for (; fd < (int)m_max_open_file_descriptors; ++fd) {
if (!m_fds[fd])
break;
}
int error;
auto socket = Socket::create(domain, type, protocol, error);
if (!socket)
return error;
auto descriptor = FileDescriptor::create(move(socket));
m_fds[fd].set(move(descriptor));
return fd;
}
int Process::sys$bind(int sockfd, const sockaddr* addr, socklen_t)
{
return -ENOTIMPL;
}
int Process::sys$listen(int sockfd, int backlog)
{
return -ENOTIMPL;
}
int Process::sys$accept(int sockfd, sockaddr*, socklen_t)
{
return -ENOTIMPL;
}
int Process::sys$connect(int sockfd, const sockaddr*, socklen_t)
{
return -ENOTIMPL;
}