mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:55:09 +00:00
Kernel: Make Socket inherit from File.
This commit is contained in:
parent
03da7046bd
commit
2470fdcd9b
18 changed files with 81 additions and 73 deletions
|
@ -14,7 +14,7 @@ Device::~Device()
|
||||||
VFS::the().unregister_device(*this);
|
VFS::the().unregister_device(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Device::absolute_path() const
|
String Device::absolute_path(FileDescriptor&) const
|
||||||
{
|
{
|
||||||
return String::format("device:%u,%u (%s)", m_major, m_minor, class_name());
|
return String::format("device:%u,%u (%s)", m_major, m_minor, class_name());
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
unsigned major() const { return m_major; }
|
unsigned major() const { return m_major; }
|
||||||
unsigned minor() const { return m_minor; }
|
unsigned minor() const { return m_minor; }
|
||||||
|
|
||||||
virtual String absolute_path() const override;
|
virtual String absolute_path(FileDescriptor&) const override;
|
||||||
|
|
||||||
uid_t uid() const { return m_uid; }
|
uid_t uid() const { return m_uid; }
|
||||||
uid_t gid() const { return m_gid; }
|
uid_t gid() const { return m_gid; }
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg);
|
virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg);
|
||||||
virtual KResultOr<Region*> mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t size);
|
virtual KResultOr<Region*> mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t size);
|
||||||
|
|
||||||
virtual String absolute_path() const = 0;
|
virtual String absolute_path(FileDescriptor&) const = 0;
|
||||||
|
|
||||||
virtual const char* class_name() const = 0;
|
virtual const char* class_name() const = 0;
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ public:
|
||||||
virtual bool is_master_pty() const { return false; }
|
virtual bool is_master_pty() const { return false; }
|
||||||
virtual bool is_block_device() const { return false; }
|
virtual bool is_block_device() const { return false; }
|
||||||
virtual bool is_character_device() const { return false; }
|
virtual bool is_character_device() const { return false; }
|
||||||
|
virtual bool is_socket() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
File();
|
File();
|
||||||
|
|
|
@ -115,7 +115,7 @@ ssize_t FIFO::write(FileDescriptor&, const byte* buffer, ssize_t size)
|
||||||
return m_buffer.write(buffer, size);
|
return m_buffer.write(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
String FIFO::absolute_path() const
|
String FIFO::absolute_path(FileDescriptor&) const
|
||||||
{
|
{
|
||||||
return String::format("fifo:%u", this);
|
return String::format("fifo:%u", this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ private:
|
||||||
virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
|
virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
|
||||||
virtual bool can_read(FileDescriptor&) const override;
|
virtual bool can_read(FileDescriptor&) const override;
|
||||||
virtual bool can_write(FileDescriptor&) const override;
|
virtual bool can_write(FileDescriptor&) const override;
|
||||||
virtual String absolute_path() const override;
|
virtual String absolute_path(FileDescriptor&) const override;
|
||||||
virtual const char* class_name() const override { return "FIFO"; }
|
virtual const char* class_name() const override { return "FIFO"; }
|
||||||
virtual bool is_fifo() const override { return true; }
|
virtual bool is_fifo() const override { return true; }
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,9 @@ Retained<FileDescriptor> FileDescriptor::create(RetainPtr<Inode>&& inode)
|
||||||
return adopt(*new FileDescriptor(move(inode)));
|
return adopt(*new FileDescriptor(move(inode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Retained<FileDescriptor> FileDescriptor::create(RetainPtr<File>&& file)
|
Retained<FileDescriptor> FileDescriptor::create(RetainPtr<File>&& file, SocketRole role)
|
||||||
{
|
{
|
||||||
return adopt(*new FileDescriptor(move(file)));
|
return adopt(*new FileDescriptor(move(file), role));
|
||||||
}
|
|
||||||
|
|
||||||
Retained<FileDescriptor> FileDescriptor::create(RetainPtr<Socket>&& socket, SocketRole role)
|
|
||||||
{
|
|
||||||
return adopt(*new FileDescriptor(move(socket), role));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDescriptor::FileDescriptor(RetainPtr<Inode>&& inode)
|
FileDescriptor::FileDescriptor(RetainPtr<Inode>&& inode)
|
||||||
|
@ -33,23 +28,16 @@ FileDescriptor::FileDescriptor(RetainPtr<Inode>&& inode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDescriptor::FileDescriptor(RetainPtr<File>&& file)
|
FileDescriptor::FileDescriptor(RetainPtr<File>&& file, SocketRole role)
|
||||||
: m_file(move(file))
|
: m_file(move(file))
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FileDescriptor::FileDescriptor(RetainPtr<Socket>&& socket, SocketRole role)
|
|
||||||
: m_socket(move(socket))
|
|
||||||
{
|
{
|
||||||
set_socket_role(role);
|
set_socket_role(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDescriptor::~FileDescriptor()
|
FileDescriptor::~FileDescriptor()
|
||||||
{
|
{
|
||||||
if (m_socket) {
|
if (is_socket())
|
||||||
m_socket->detach(*this);
|
socket()->detach(*this);
|
||||||
m_socket = nullptr;
|
|
||||||
}
|
|
||||||
if (is_fifo())
|
if (is_fifo())
|
||||||
static_cast<FIFO*>(m_file.ptr())->detach(m_fifo_direction);
|
static_cast<FIFO*>(m_file.ptr())->detach(m_fifo_direction);
|
||||||
if (m_file) {
|
if (m_file) {
|
||||||
|
@ -64,11 +52,11 @@ void FileDescriptor::set_socket_role(SocketRole role)
|
||||||
if (role == m_socket_role)
|
if (role == m_socket_role)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(m_socket);
|
ASSERT(is_socket());
|
||||||
if (m_socket_role != SocketRole::None)
|
if (m_socket_role != SocketRole::None)
|
||||||
m_socket->detach(*this);
|
socket()->detach(*this);
|
||||||
m_socket_role = role;
|
m_socket_role = role;
|
||||||
m_socket->attach(*this);
|
socket()->attach(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Retained<FileDescriptor> FileDescriptor::clone()
|
Retained<FileDescriptor> FileDescriptor::clone()
|
||||||
|
@ -78,10 +66,7 @@ Retained<FileDescriptor> FileDescriptor::clone()
|
||||||
descriptor = fifo()->open_direction(m_fifo_direction);
|
descriptor = fifo()->open_direction(m_fifo_direction);
|
||||||
} else {
|
} else {
|
||||||
if (m_file) {
|
if (m_file) {
|
||||||
descriptor = FileDescriptor::create(m_file.copy_ref());
|
descriptor = FileDescriptor::create(m_file.copy_ref(), m_socket_role);
|
||||||
descriptor->m_inode = m_inode.copy_ref();
|
|
||||||
} else if (m_socket) {
|
|
||||||
descriptor = FileDescriptor::create(m_socket.copy_ref(), m_socket_role);
|
|
||||||
descriptor->m_inode = m_inode.copy_ref();
|
descriptor->m_inode = m_inode.copy_ref();
|
||||||
} else {
|
} else {
|
||||||
descriptor = FileDescriptor::create(m_inode.copy_ref());
|
descriptor = FileDescriptor::create(m_inode.copy_ref());
|
||||||
|
@ -180,8 +165,6 @@ ssize_t FileDescriptor::read(byte* buffer, ssize_t count)
|
||||||
m_current_offset += nread;
|
m_current_offset += nread;
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
if (m_socket)
|
|
||||||
return m_socket->read(*this, buffer, count);
|
|
||||||
ASSERT(inode());
|
ASSERT(inode());
|
||||||
ssize_t nread = inode()->read_bytes(m_current_offset, count, buffer, this);
|
ssize_t nread = inode()->read_bytes(m_current_offset, count, buffer, this);
|
||||||
m_current_offset += nread;
|
m_current_offset += nread;
|
||||||
|
@ -196,8 +179,6 @@ ssize_t FileDescriptor::write(const byte* data, ssize_t size)
|
||||||
m_current_offset += nwritten;
|
m_current_offset += nwritten;
|
||||||
return nwritten;
|
return nwritten;
|
||||||
}
|
}
|
||||||
if (m_socket)
|
|
||||||
return m_socket->write(*this, data, size);
|
|
||||||
ASSERT(m_inode);
|
ASSERT(m_inode);
|
||||||
ssize_t nwritten = m_inode->write_bytes(m_current_offset, size, data, this);
|
ssize_t nwritten = m_inode->write_bytes(m_current_offset, size, data, this);
|
||||||
m_current_offset += nwritten;
|
m_current_offset += nwritten;
|
||||||
|
@ -208,8 +189,6 @@ bool FileDescriptor::can_write()
|
||||||
{
|
{
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->can_write(*this);
|
return m_file->can_write(*this);
|
||||||
if (m_socket)
|
|
||||||
return m_socket->can_write(*this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +196,6 @@ bool FileDescriptor::can_read()
|
||||||
{
|
{
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->can_read(*this);
|
return m_file->can_read(*this);
|
||||||
if (m_socket)
|
|
||||||
return m_socket->can_read(*this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,20 +299,6 @@ int FileDescriptor::close()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* to_string(SocketRole role)
|
|
||||||
{
|
|
||||||
switch (role) {
|
|
||||||
case SocketRole::Listener:
|
|
||||||
return "Listener";
|
|
||||||
case SocketRole::Accepted:
|
|
||||||
return "Accepted";
|
|
||||||
case SocketRole::Connected:
|
|
||||||
return "Connected";
|
|
||||||
default:
|
|
||||||
return "None";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FileDescriptor::is_fsfile() const
|
bool FileDescriptor::is_fsfile() const
|
||||||
{
|
{
|
||||||
return !is_tty() && !is_fifo() && !is_device() && !is_socket() && !is_shared_memory();
|
return !is_tty() && !is_fifo() && !is_device() && !is_socket() && !is_shared_memory();
|
||||||
|
@ -344,9 +307,7 @@ bool FileDescriptor::is_fsfile() const
|
||||||
KResultOr<String> FileDescriptor::absolute_path()
|
KResultOr<String> FileDescriptor::absolute_path()
|
||||||
{
|
{
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->absolute_path();
|
return m_file->absolute_path(*this);
|
||||||
if (is_socket())
|
|
||||||
return String::format("socket:%x (role: %s)", m_socket.ptr(), to_string(m_socket_role));
|
|
||||||
ASSERT(m_inode);
|
ASSERT(m_inode);
|
||||||
return VFS::the().absolute_path(*m_inode);
|
return VFS::the().absolute_path(*m_inode);
|
||||||
}
|
}
|
||||||
|
@ -428,3 +389,22 @@ FIFO* FileDescriptor::fifo()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return static_cast<FIFO*>(m_file.ptr());
|
return static_cast<FIFO*>(m_file.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileDescriptor::is_socket() const
|
||||||
|
{
|
||||||
|
return m_file && m_file->is_socket();
|
||||||
|
}
|
||||||
|
|
||||||
|
Socket* FileDescriptor::socket()
|
||||||
|
{
|
||||||
|
if (!is_socket())
|
||||||
|
return nullptr;
|
||||||
|
return static_cast<Socket*>(m_file.ptr());
|
||||||
|
}
|
||||||
|
|
||||||
|
const Socket* FileDescriptor::socket() const
|
||||||
|
{
|
||||||
|
if (!is_socket())
|
||||||
|
return nullptr;
|
||||||
|
return static_cast<const Socket*>(m_file.ptr());
|
||||||
|
}
|
||||||
|
|
|
@ -20,9 +20,8 @@ class SharedMemory;
|
||||||
|
|
||||||
class FileDescriptor : public Retainable<FileDescriptor> {
|
class FileDescriptor : public Retainable<FileDescriptor> {
|
||||||
public:
|
public:
|
||||||
static Retained<FileDescriptor> create(RetainPtr<Socket>&&, SocketRole = SocketRole::None);
|
|
||||||
static Retained<FileDescriptor> create(RetainPtr<Inode>&&);
|
static Retained<FileDescriptor> create(RetainPtr<Inode>&&);
|
||||||
static Retained<FileDescriptor> create(RetainPtr<File>&&);
|
static Retained<FileDescriptor> create(RetainPtr<File>&&, SocketRole = SocketRole::None);
|
||||||
~FileDescriptor();
|
~FileDescriptor();
|
||||||
|
|
||||||
Retained<FileDescriptor> clone();
|
Retained<FileDescriptor> clone();
|
||||||
|
@ -74,9 +73,9 @@ public:
|
||||||
dword file_flags() const { return m_file_flags; }
|
dword file_flags() const { return m_file_flags; }
|
||||||
void set_file_flags(dword flags) { m_file_flags = flags; }
|
void set_file_flags(dword flags) { m_file_flags = flags; }
|
||||||
|
|
||||||
bool is_socket() const { return m_socket; }
|
bool is_socket() const;
|
||||||
Socket* socket() { return m_socket.ptr(); }
|
Socket* socket();
|
||||||
const Socket* socket() const { return m_socket.ptr(); }
|
const Socket* socket() const;
|
||||||
|
|
||||||
bool is_fifo() const;
|
bool is_fifo() const;
|
||||||
FIFO* fifo();
|
FIFO* fifo();
|
||||||
|
@ -99,9 +98,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class VFS;
|
friend class VFS;
|
||||||
FileDescriptor(RetainPtr<Socket>&&, SocketRole);
|
FileDescriptor(RetainPtr<File>&&, SocketRole);
|
||||||
explicit FileDescriptor(RetainPtr<Inode>&&);
|
explicit FileDescriptor(RetainPtr<Inode>&&);
|
||||||
explicit FileDescriptor(RetainPtr<File>&&);
|
|
||||||
FileDescriptor(FIFO&, FIFO::Direction);
|
FileDescriptor(FIFO&, FIFO::Direction);
|
||||||
|
|
||||||
RetainPtr<Inode> m_inode;
|
RetainPtr<Inode> m_inode;
|
||||||
|
@ -114,7 +112,6 @@ private:
|
||||||
bool m_is_blocking { true };
|
bool m_is_blocking { true };
|
||||||
dword m_file_flags { 0 };
|
dword m_file_flags { 0 };
|
||||||
|
|
||||||
RetainPtr<Socket> m_socket;
|
|
||||||
SocketRole m_socket_role { SocketRole::None };
|
SocketRole m_socket_role { SocketRole::None };
|
||||||
|
|
||||||
FIFO::Direction m_fifo_direction { FIFO::Neither };
|
FIFO::Direction m_fifo_direction { FIFO::Neither };
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IPv4Socket(int type, int protocol);
|
IPv4Socket(int type, int protocol);
|
||||||
|
virtual const char* class_name() const override { return "IPv4Socket"; }
|
||||||
|
|
||||||
int allocate_source_port_if_needed();
|
int allocate_source_port_if_needed();
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,8 @@ void LocalSocket::attach(FileDescriptor& descriptor)
|
||||||
case SocketRole::Connecting:
|
case SocketRole::Connecting:
|
||||||
++m_connecting_fds_open;
|
++m_connecting_fds_open;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +133,8 @@ void LocalSocket::detach(FileDescriptor& descriptor)
|
||||||
ASSERT(m_connecting_fds_open);
|
ASSERT(m_connecting_fds_open);
|
||||||
--m_connecting_fds_open;
|
--m_connecting_fds_open;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||||
#include <Kernel/Net/Socket.h>
|
#include <Kernel/Net/Socket.h>
|
||||||
#include <Kernel/Net/LocalSocket.h>
|
#include <Kernel/Net/LocalSocket.h>
|
||||||
#include <Kernel/Net/IPv4Socket.h>
|
#include <Kernel/Net/IPv4Socket.h>
|
||||||
|
@ -119,3 +120,22 @@ void Socket::load_send_deadline()
|
||||||
m_send_deadline.tv_sec += (m_send_timeout.tv_usec / 1000000) * 1;
|
m_send_deadline.tv_sec += (m_send_timeout.tv_usec / 1000000) * 1;
|
||||||
m_send_deadline.tv_usec %= 1000000;
|
m_send_deadline.tv_usec %= 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* to_string(SocketRole role)
|
||||||
|
{
|
||||||
|
switch (role) {
|
||||||
|
case SocketRole::Listener:
|
||||||
|
return "Listener";
|
||||||
|
case SocketRole::Accepted:
|
||||||
|
return "Accepted";
|
||||||
|
case SocketRole::Connected:
|
||||||
|
return "Connected";
|
||||||
|
default:
|
||||||
|
return "None";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String Socket::absolute_path(FileDescriptor& descriptor) const
|
||||||
|
{
|
||||||
|
return String::format("socket:%x (role: %s)", this, to_string(descriptor.socket_role()));
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <AK/RetainPtr.h>
|
#include <AK/RetainPtr.h>
|
||||||
#include <AK/HashTable.h>
|
#include <AK/HashTable.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
#include <Kernel/File.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
#include <Kernel/KResult.h>
|
#include <Kernel/KResult.h>
|
||||||
|
|
||||||
|
@ -13,10 +14,10 @@ enum class ShouldBlock { No = 0, Yes = 1 };
|
||||||
|
|
||||||
class FileDescriptor;
|
class FileDescriptor;
|
||||||
|
|
||||||
class Socket : public Retainable<Socket> {
|
class Socket : public File {
|
||||||
public:
|
public:
|
||||||
static KResultOr<Retained<Socket>> create(int domain, int type, int protocol);
|
static KResultOr<Retained<Socket>> create(int domain, int type, int protocol);
|
||||||
virtual ~Socket();
|
virtual ~Socket() override;
|
||||||
|
|
||||||
int domain() const { return m_domain; }
|
int domain() const { return m_domain; }
|
||||||
int type() const { return m_type; }
|
int type() const { return m_type; }
|
||||||
|
@ -34,10 +35,6 @@ public:
|
||||||
virtual bool is_ipv4() const { return false; }
|
virtual bool is_ipv4() const { return false; }
|
||||||
virtual void attach(FileDescriptor&) = 0;
|
virtual void attach(FileDescriptor&) = 0;
|
||||||
virtual void detach(FileDescriptor&) = 0;
|
virtual void detach(FileDescriptor&) = 0;
|
||||||
virtual bool can_read(FileDescriptor&) const = 0;
|
|
||||||
virtual ssize_t read(FileDescriptor&, byte*, ssize_t) = 0;
|
|
||||||
virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) = 0;
|
|
||||||
virtual bool can_write(FileDescriptor&) const = 0;
|
|
||||||
virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int flags, const sockaddr*, socklen_t) = 0;
|
virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int flags, const sockaddr*, socklen_t) = 0;
|
||||||
virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) = 0;
|
virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) = 0;
|
||||||
|
|
||||||
|
@ -53,6 +50,8 @@ public:
|
||||||
|
|
||||||
Lock& lock() { return m_lock; }
|
Lock& lock() { return m_lock; }
|
||||||
|
|
||||||
|
virtual String absolute_path(FileDescriptor&) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Socket(int domain, int type, int protocol);
|
Socket(int domain, int type, int protocol);
|
||||||
|
|
||||||
|
@ -61,7 +60,11 @@ protected:
|
||||||
void load_receive_deadline();
|
void load_receive_deadline();
|
||||||
void load_send_deadline();
|
void load_send_deadline();
|
||||||
|
|
||||||
|
virtual const char* class_name() const override { return "Socket"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual bool is_socket() const final { return true; }
|
||||||
|
|
||||||
Lock m_lock { "Socket" };
|
Lock m_lock { "Socket" };
|
||||||
pid_t m_origin_pid { 0 };
|
pid_t m_origin_pid { 0 };
|
||||||
int m_domain { 0 };
|
int m_domain { 0 };
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit TCPSocket(int protocol);
|
explicit TCPSocket(int protocol);
|
||||||
|
virtual const char* class_name() const override { return "TCPSocket"; }
|
||||||
|
|
||||||
NetworkOrdered<word> compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket&, word payload_size);
|
NetworkOrdered<word> compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket&, word payload_size);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit UDPSocket(int protocol);
|
explicit UDPSocket(int protocol);
|
||||||
|
virtual const char* class_name() const override { return "UDPSocket"; }
|
||||||
|
|
||||||
virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override;
|
virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override;
|
||||||
virtual int protocol_send(const void*, int) override;
|
virtual int protocol_send(const void*, int) override;
|
||||||
|
|
|
@ -29,7 +29,7 @@ int ProcessTracer::read(FileDescriptor&, byte* buffer, int buffer_size)
|
||||||
return sizeof(data);
|
return sizeof(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
String ProcessTracer::absolute_path() const
|
String ProcessTracer::absolute_path(FileDescriptor&) const
|
||||||
{
|
{
|
||||||
return String::format("tracer:%d", m_pid);
|
return String::format("tracer:%d", m_pid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
virtual bool can_write(FileDescriptor&) const override { return true; }
|
virtual bool can_write(FileDescriptor&) const override { return true; }
|
||||||
virtual int write(FileDescriptor&, const byte*, int) override { return -EIO; }
|
virtual int write(FileDescriptor&, const byte*, int) override { return -EIO; }
|
||||||
|
|
||||||
virtual String absolute_path() const override;
|
virtual String absolute_path(FileDescriptor&) const override;
|
||||||
|
|
||||||
void did_syscall(dword function, dword arg1, dword arg2, dword arg3, dword result);
|
void did_syscall(dword function, dword arg1, dword arg2, dword arg3, dword result);
|
||||||
pid_t pid() const { return m_pid; }
|
pid_t pid() const { return m_pid; }
|
||||||
|
|
|
@ -68,7 +68,7 @@ KResult SharedMemory::truncate(int length)
|
||||||
return KResult(-ENOTIMPL);
|
return KResult(-ENOTIMPL);
|
||||||
}
|
}
|
||||||
|
|
||||||
String SharedMemory::absolute_path() const
|
String SharedMemory::absolute_path(FileDescriptor&) const
|
||||||
{
|
{
|
||||||
return String::format("shm:%u", this);
|
return String::format("shm:%u", this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ private:
|
||||||
virtual bool can_write(FileDescriptor&) const override { return true; }
|
virtual bool can_write(FileDescriptor&) const override { return true; }
|
||||||
virtual int read(FileDescriptor&, byte*, int) override;
|
virtual int read(FileDescriptor&, byte*, int) override;
|
||||||
virtual int write(FileDescriptor&, const byte*, int) override;
|
virtual int write(FileDescriptor&, const byte*, int) override;
|
||||||
virtual String absolute_path() const override;
|
virtual String absolute_path(FileDescriptor&) const override;
|
||||||
virtual const char* class_name() const override { return "SharedMemory"; }
|
virtual const char* class_name() const override { return "SharedMemory"; }
|
||||||
virtual bool is_shared_memory() const override { return true; }
|
virtual bool is_shared_memory() const override { return true; }
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
virtual bool can_read(FileDescriptor&) const override;
|
virtual bool can_read(FileDescriptor&) const override;
|
||||||
virtual bool can_write(FileDescriptor&) const override;
|
virtual bool can_write(FileDescriptor&) const override;
|
||||||
virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg) override final;
|
virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg) override final;
|
||||||
virtual String absolute_path() const override { return tty_name(); }
|
virtual String absolute_path(FileDescriptor&) const override { return tty_name(); }
|
||||||
|
|
||||||
virtual String tty_name() const = 0;
|
virtual String tty_name() const = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue