Add Unix domain sockets for local IPC #37

Merged
apio merged 16 commits from unix-sockets into main 2023-07-30 09:49:38 +00:00
19 changed files with 24 additions and 24 deletions
Showing only changes of commit 187f0ff83e - Show all commits

View File

@ -310,7 +310,7 @@ class ATADevice : public Device
return err(ENOTSUP);
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -41,7 +41,7 @@ namespace MBR
Result<usize> write(const u8* buf, usize offset, usize length) override;
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -37,7 +37,7 @@ class MountInode : public VFS::Inode, public LinkedListNode<MountInode>
return err(EISDIR);
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -46,7 +46,7 @@ Result<usize> Pipe::write(const u8* buf, usize, usize length)
return length;
}
bool Pipe::blocking() const
bool Pipe::will_block_if_read() const
{
return !m_data_buffer.size() && m_writer;
}

View File

@ -15,7 +15,7 @@ class Pipe : public Shareable
Result<usize> write(const u8* buf, usize, usize length);
bool blocking() const;
bool will_block_if_read() const;
private:
Buffer m_data_buffer;
@ -40,9 +40,9 @@ class PipeInodeBase : public VFS::FileInode
return err(ENOTSUP);
}
bool blocking() const override
bool will_block_if_read() const override
{
return m_pipe->blocking();
return m_pipe->will_block_if_read();
}
usize size() const override

View File

@ -120,7 +120,7 @@ namespace VFS
virtual Result<void> truncate(usize size) = 0;
virtual bool blocking() const = 0;
virtual bool will_block_if_read() const = 0;
// Symlink-specific methods
virtual Result<StringView> readlink()
@ -231,7 +231,7 @@ namespace VFS
return 0;
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -64,7 +64,7 @@ Result<usize> ConsoleDevice::write(const u8* buf, usize, usize length)
return length;
}
bool ConsoleDevice::blocking() const
bool ConsoleDevice::will_block_if_read() const
{
return m_may_read_without_blocking ? false : m_input_buffer.size() == 0;
}

View File

@ -16,7 +16,7 @@ class ConsoleDevice : public Device
static void did_press_or_release_key(u8 scancode);
bool blocking() const override;
bool will_block_if_read() const override;
Result<u64> ioctl(int request, void* arg) override;

View File

@ -41,7 +41,7 @@ class Device : public Shareable
// Path in devfs.
virtual StringView device_path() const = 0;
virtual bool blocking() const = 0;
virtual bool will_block_if_read() const = 0;
virtual ~Device() = default;
};

View File

@ -28,7 +28,7 @@ usize FramebufferDevice::size() const
return Framebuffer::size();
}
bool FramebufferDevice::blocking() const
bool FramebufferDevice::will_block_if_read() const
{
return false;
}

View File

@ -11,7 +11,7 @@ class FramebufferDevice : public Device
Result<usize> write(const u8*, usize, usize) override;
bool blocking() const override;
bool will_block_if_read() const override;
bool is_block_device() const override
{

View File

@ -19,7 +19,7 @@ class FullDevice : public Device
return err(ENOSPC);
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -17,7 +17,7 @@ class NullDevice : public Device
return 0;
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -14,7 +14,7 @@ class UARTDevice : public Device
Result<usize> write(const u8*, usize, usize) override;
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -19,7 +19,7 @@ class ZeroDevice : public Device
return 0;
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -122,7 +122,7 @@ namespace Ext2
return m_entries.size();
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -281,9 +281,9 @@ namespace TmpFS
return m_device->isatty();
}
bool blocking() const override
bool will_block_if_read() const override
{
return m_device->blocking();
return m_device->will_block_if_read();
}
usize size() const override
@ -385,7 +385,7 @@ namespace TmpFS
return err(EISDIR);
}
bool blocking() const override
bool will_block_if_read() const override
{
return false;
}

View File

@ -12,7 +12,7 @@ class UnixSocket : public Socket
UnixSocket();
UnixSocket(UnixSocket* peer);
bool blocking() const override
bool will_block_if_read() const override
{
return (m_state == Connected || m_state == Reset) && !m_data.size();
}

View File

@ -26,7 +26,7 @@ Result<u64> sys_read(Registers* regs, SyscallArgs args)
if (!descriptor.is_readable()) return err(EBADF);
while (descriptor.inode()->blocking())
while (descriptor.inode()->will_block_if_read())
{
if (descriptor.should_block()) kernel_sleep(10);
else