From 187f0ff83ed71bf31e53db089b57726e596a4550 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 30 Jul 2023 11:41:53 +0200 Subject: [PATCH] kernel: Rename Inode::blocking() to Inode::will_block_if_read() --- kernel/src/arch/x86_64/disk/ATA.h | 2 +- kernel/src/fs/MBR.h | 2 +- kernel/src/fs/Mount.h | 2 +- kernel/src/fs/Pipe.cpp | 2 +- kernel/src/fs/Pipe.h | 6 +++--- kernel/src/fs/VFS.h | 4 ++-- kernel/src/fs/devices/ConsoleDevice.cpp | 2 +- kernel/src/fs/devices/ConsoleDevice.h | 2 +- kernel/src/fs/devices/Device.h | 2 +- kernel/src/fs/devices/FramebufferDevice.cpp | 2 +- kernel/src/fs/devices/FramebufferDevice.h | 2 +- kernel/src/fs/devices/FullDevice.h | 2 +- kernel/src/fs/devices/NullDevice.h | 2 +- kernel/src/fs/devices/UARTDevice.h | 2 +- kernel/src/fs/devices/ZeroDevice.h | 2 +- kernel/src/fs/ext2/Inode.h | 2 +- kernel/src/fs/tmpfs/Inode.h | 6 +++--- kernel/src/net/UnixSocket.h | 2 +- kernel/src/sys/file.cpp | 2 +- 19 files changed, 24 insertions(+), 24 deletions(-) diff --git a/kernel/src/arch/x86_64/disk/ATA.h b/kernel/src/arch/x86_64/disk/ATA.h index 6b3e367d..2cc4bc0b 100644 --- a/kernel/src/arch/x86_64/disk/ATA.h +++ b/kernel/src/arch/x86_64/disk/ATA.h @@ -310,7 +310,7 @@ class ATADevice : public Device return err(ENOTSUP); } - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/MBR.h b/kernel/src/fs/MBR.h index 7203febb..184a339c 100644 --- a/kernel/src/fs/MBR.h +++ b/kernel/src/fs/MBR.h @@ -41,7 +41,7 @@ namespace MBR Result write(const u8* buf, usize offset, usize length) override; - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/Mount.h b/kernel/src/fs/Mount.h index e3f74faf..bb8ee36d 100644 --- a/kernel/src/fs/Mount.h +++ b/kernel/src/fs/Mount.h @@ -37,7 +37,7 @@ class MountInode : public VFS::Inode, public LinkedListNode return err(EISDIR); } - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/Pipe.cpp b/kernel/src/fs/Pipe.cpp index 5b232b7b..edbb180f 100644 --- a/kernel/src/fs/Pipe.cpp +++ b/kernel/src/fs/Pipe.cpp @@ -46,7 +46,7 @@ Result 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; } diff --git a/kernel/src/fs/Pipe.h b/kernel/src/fs/Pipe.h index e84368ef..76bc0d73 100644 --- a/kernel/src/fs/Pipe.h +++ b/kernel/src/fs/Pipe.h @@ -15,7 +15,7 @@ class Pipe : public Shareable Result 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 diff --git a/kernel/src/fs/VFS.h b/kernel/src/fs/VFS.h index c0959394..e7dff461 100644 --- a/kernel/src/fs/VFS.h +++ b/kernel/src/fs/VFS.h @@ -120,7 +120,7 @@ namespace VFS virtual Result truncate(usize size) = 0; - virtual bool blocking() const = 0; + virtual bool will_block_if_read() const = 0; // Symlink-specific methods virtual Result readlink() @@ -231,7 +231,7 @@ namespace VFS return 0; } - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/devices/ConsoleDevice.cpp b/kernel/src/fs/devices/ConsoleDevice.cpp index 0d469c65..5b21e486 100644 --- a/kernel/src/fs/devices/ConsoleDevice.cpp +++ b/kernel/src/fs/devices/ConsoleDevice.cpp @@ -64,7 +64,7 @@ Result 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; } diff --git a/kernel/src/fs/devices/ConsoleDevice.h b/kernel/src/fs/devices/ConsoleDevice.h index 0408a9e8..d6b7d186 100644 --- a/kernel/src/fs/devices/ConsoleDevice.h +++ b/kernel/src/fs/devices/ConsoleDevice.h @@ -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 ioctl(int request, void* arg) override; diff --git a/kernel/src/fs/devices/Device.h b/kernel/src/fs/devices/Device.h index e72a9e24..130aec8d 100644 --- a/kernel/src/fs/devices/Device.h +++ b/kernel/src/fs/devices/Device.h @@ -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; }; diff --git a/kernel/src/fs/devices/FramebufferDevice.cpp b/kernel/src/fs/devices/FramebufferDevice.cpp index c42b8904..23ab7b32 100644 --- a/kernel/src/fs/devices/FramebufferDevice.cpp +++ b/kernel/src/fs/devices/FramebufferDevice.cpp @@ -28,7 +28,7 @@ usize FramebufferDevice::size() const return Framebuffer::size(); } -bool FramebufferDevice::blocking() const +bool FramebufferDevice::will_block_if_read() const { return false; } diff --git a/kernel/src/fs/devices/FramebufferDevice.h b/kernel/src/fs/devices/FramebufferDevice.h index 4bf2928c..76b5ebb7 100644 --- a/kernel/src/fs/devices/FramebufferDevice.h +++ b/kernel/src/fs/devices/FramebufferDevice.h @@ -11,7 +11,7 @@ class FramebufferDevice : public Device Result write(const u8*, usize, usize) override; - bool blocking() const override; + bool will_block_if_read() const override; bool is_block_device() const override { diff --git a/kernel/src/fs/devices/FullDevice.h b/kernel/src/fs/devices/FullDevice.h index 9102db20..fa9e67b9 100644 --- a/kernel/src/fs/devices/FullDevice.h +++ b/kernel/src/fs/devices/FullDevice.h @@ -19,7 +19,7 @@ class FullDevice : public Device return err(ENOSPC); } - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/devices/NullDevice.h b/kernel/src/fs/devices/NullDevice.h index 9f434718..fd245edb 100644 --- a/kernel/src/fs/devices/NullDevice.h +++ b/kernel/src/fs/devices/NullDevice.h @@ -17,7 +17,7 @@ class NullDevice : public Device return 0; } - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/devices/UARTDevice.h b/kernel/src/fs/devices/UARTDevice.h index 7c2bed02..24017130 100644 --- a/kernel/src/fs/devices/UARTDevice.h +++ b/kernel/src/fs/devices/UARTDevice.h @@ -14,7 +14,7 @@ class UARTDevice : public Device Result write(const u8*, usize, usize) override; - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/devices/ZeroDevice.h b/kernel/src/fs/devices/ZeroDevice.h index 8b2fed80..98fb20e8 100644 --- a/kernel/src/fs/devices/ZeroDevice.h +++ b/kernel/src/fs/devices/ZeroDevice.h @@ -19,7 +19,7 @@ class ZeroDevice : public Device return 0; } - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/ext2/Inode.h b/kernel/src/fs/ext2/Inode.h index 2f7a2484..5c9c0c7c 100644 --- a/kernel/src/fs/ext2/Inode.h +++ b/kernel/src/fs/ext2/Inode.h @@ -122,7 +122,7 @@ namespace Ext2 return m_entries.size(); } - bool blocking() const override + bool will_block_if_read() const override { return false; } diff --git a/kernel/src/fs/tmpfs/Inode.h b/kernel/src/fs/tmpfs/Inode.h index e2815a91..cdf87f70 100644 --- a/kernel/src/fs/tmpfs/Inode.h +++ b/kernel/src/fs/tmpfs/Inode.h @@ -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; } diff --git a/kernel/src/net/UnixSocket.h b/kernel/src/net/UnixSocket.h index 88c8150e..9d8114d5 100644 --- a/kernel/src/net/UnixSocket.h +++ b/kernel/src/net/UnixSocket.h @@ -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(); } diff --git a/kernel/src/sys/file.cpp b/kernel/src/sys/file.cpp index 75403566..6a7d2ddd 100644 --- a/kernel/src/sys/file.cpp +++ b/kernel/src/sys/file.cpp @@ -26,7 +26,7 @@ Result 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