mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Refactor storage stack with u64 as file operations offset
This commit is contained in:
parent
999c57ef2d
commit
b05b4d4b24
Notes:
sideshowbarker
2024-07-18 21:15:59 +09:00
Author: https://github.com/boricj Commit: https://github.com/SerenityOS/serenity/commit/b05b4d4b249 Pull-request: https://github.com/SerenityOS/serenity/pull/5766 Reviewed-by: https://github.com/supercomputer7
43 changed files with 83 additions and 83 deletions
|
@ -65,14 +65,14 @@ bool Console::can_read(const Kernel::FileDescription&, size_t) const
|
|||
return false;
|
||||
}
|
||||
|
||||
Kernel::KResultOr<size_t> Console::read(Kernel::FileDescription&, size_t, Kernel::UserOrKernelBuffer&, size_t)
|
||||
Kernel::KResultOr<size_t> Console::read(FileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t)
|
||||
{
|
||||
// FIXME: Implement reading from the console.
|
||||
// Maybe we could use a ring buffer for this device?
|
||||
return 0;
|
||||
}
|
||||
|
||||
Kernel::KResultOr<size_t> Console::write(Kernel::FileDescription&, size_t, const Kernel::UserOrKernelBuffer& data, size_t size)
|
||||
Kernel::KResultOr<size_t> Console::write(FileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return 0;
|
||||
|
|
|
@ -43,8 +43,8 @@ public:
|
|||
// ^CharacterDevice
|
||||
virtual bool can_read(const Kernel::FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const Kernel::FileDescription&, size_t) const override { return true; }
|
||||
virtual Kernel::KResultOr<size_t> read(Kernel::FileDescription&, size_t, Kernel::UserOrKernelBuffer&, size_t) override;
|
||||
virtual Kernel::KResultOr<size_t> write(Kernel::FileDescription&, size_t, const Kernel::UserOrKernelBuffer&, size_t) override;
|
||||
virtual Kernel::KResultOr<size_t> read(FileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) override;
|
||||
virtual Kernel::KResultOr<size_t> write(FileDescription&, u64, const Kernel::UserOrKernelBuffer&, size_t) override;
|
||||
virtual const char* class_name() const override { return "Console"; }
|
||||
|
||||
void put_char(char);
|
||||
|
|
|
@ -53,8 +53,8 @@ private:
|
|||
virtual bool can_read(const FileDescription&, size_t) const override { return true; }
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
virtual void start_request(AsyncBlockDeviceRequest& request) override { request.complete(AsyncDeviceRequest::Failure); }
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
|
||||
void set_safe_resolution();
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ bool FullDevice::can_read(const FileDescription&, size_t) const
|
|||
return true;
|
||||
}
|
||||
|
||||
KResultOr<size_t> FullDevice::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> FullDevice::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
ssize_t count = min(static_cast<size_t>(PAGE_SIZE), size);
|
||||
if (!buffer.memset(0, count))
|
||||
|
@ -54,7 +54,7 @@ KResultOr<size_t> FullDevice::read(FileDescription&, size_t, UserOrKernelBuffer&
|
|||
return count;
|
||||
}
|
||||
|
||||
KResultOr<size_t> FullDevice::write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t size)
|
||||
KResultOr<size_t> FullDevice::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
|
|
@ -42,8 +42,8 @@ public:
|
|||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
virtual const char* class_name() const override { return "FullDevice"; }
|
||||
|
|
|
@ -430,7 +430,7 @@ bool KeyboardDevice::can_read(const FileDescription&, size_t) const
|
|||
return !m_queue.is_empty();
|
||||
}
|
||||
|
||||
KResultOr<size_t> KeyboardDevice::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> KeyboardDevice::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
size_t nread = 0;
|
||||
ScopedSpinLock lock(m_queue_lock);
|
||||
|
@ -458,7 +458,7 @@ KResultOr<size_t> KeyboardDevice::read(FileDescription&, size_t, UserOrKernelBuf
|
|||
return nread;
|
||||
}
|
||||
|
||||
KResultOr<size_t> KeyboardDevice::write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t)
|
||||
KResultOr<size_t> KeyboardDevice::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ public:
|
|||
const String keymap_name() { return m_character_map.character_map_name(); }
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
|
||||
virtual const char* purpose() const override { return class_name(); }
|
||||
|
|
|
@ -51,8 +51,8 @@ private:
|
|||
virtual const char* class_name() const override { return "MBVGA"; }
|
||||
virtual bool can_read(const FileDescription&, size_t) const override { return true; }
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual void start_request(AsyncBlockDeviceRequest& request) override { request.complete(AsyncDeviceRequest::Failure); }
|
||||
|
||||
size_t framebuffer_size_in_bytes() const { return m_framebuffer_pitch * m_framebuffer_height; }
|
||||
|
|
|
@ -42,7 +42,7 @@ UNMAP_AFTER_INIT MemoryDevice::~MemoryDevice()
|
|||
{
|
||||
}
|
||||
|
||||
KResultOr<size_t> MemoryDevice::read(FileDescription&, size_t, UserOrKernelBuffer&, size_t)
|
||||
KResultOr<size_t> MemoryDevice::read(FileDescription&, u64, UserOrKernelBuffer&, size_t)
|
||||
{
|
||||
TODO();
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ private:
|
|||
virtual bool can_read(const FileDescription&, size_t) const override { return true; }
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return false; }
|
||||
virtual bool is_seekable() const { return true; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
|
||||
virtual void did_seek(FileDescription&, off_t) override;
|
||||
|
||||
|
|
|
@ -56,12 +56,12 @@ bool NullDevice::can_read(const FileDescription&, size_t) const
|
|||
return true;
|
||||
}
|
||||
|
||||
KResultOr<size_t> NullDevice::read(FileDescription&, size_t, UserOrKernelBuffer&, size_t)
|
||||
KResultOr<size_t> NullDevice::read(FileDescription&, u64, UserOrKernelBuffer&, size_t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
KResultOr<size_t> NullDevice::write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t buffer_size)
|
||||
KResultOr<size_t> NullDevice::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t buffer_size)
|
||||
{
|
||||
return min(static_cast<size_t>(PAGE_SIZE), buffer_size);
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual const char* class_name() const override { return "NullDevice"; }
|
||||
|
|
|
@ -273,7 +273,7 @@ bool PS2MouseDevice::can_read(const FileDescription&, size_t) const
|
|||
return !m_queue.is_empty();
|
||||
}
|
||||
|
||||
KResultOr<size_t> PS2MouseDevice::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> PS2MouseDevice::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
VERIFY(size > 0);
|
||||
size_t nread = 0;
|
||||
|
@ -300,7 +300,7 @@ KResultOr<size_t> PS2MouseDevice::read(FileDescription&, size_t, UserOrKernelBuf
|
|||
return nread;
|
||||
}
|
||||
|
||||
KResultOr<size_t> PS2MouseDevice::write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t)
|
||||
KResultOr<size_t> PS2MouseDevice::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
|
||||
virtual const char* purpose() const override { return class_name(); }
|
||||
|
|
|
@ -43,7 +43,7 @@ bool RandomDevice::can_read(const FileDescription&, size_t) const
|
|||
return true;
|
||||
}
|
||||
|
||||
KResultOr<size_t> RandomDevice::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> RandomDevice::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
bool success = buffer.write_buffered<256>(size, [&](u8* data, size_t data_size) {
|
||||
get_good_random_bytes(data, data_size);
|
||||
|
@ -54,7 +54,7 @@ KResultOr<size_t> RandomDevice::read(FileDescription&, size_t, UserOrKernelBuffe
|
|||
return size;
|
||||
}
|
||||
|
||||
KResultOr<size_t> RandomDevice::write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t size)
|
||||
KResultOr<size_t> RandomDevice::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t size)
|
||||
{
|
||||
// FIXME: Use input for entropy? I guess that could be a neat feature?
|
||||
return min(static_cast<size_t>(PAGE_SIZE), size);
|
||||
|
|
|
@ -42,8 +42,8 @@ public:
|
|||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
virtual const char* class_name() const override { return "RandomDevice"; }
|
||||
|
|
|
@ -189,7 +189,7 @@ bool SB16::can_read(const FileDescription&, size_t) const
|
|||
return false;
|
||||
}
|
||||
|
||||
KResultOr<size_t> SB16::read(FileDescription&, size_t, UserOrKernelBuffer&, size_t)
|
||||
KResultOr<size_t> SB16::read(FileDescription&, u64, UserOrKernelBuffer&, size_t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ void SB16::wait_for_irq()
|
|||
disable_irq();
|
||||
}
|
||||
|
||||
KResultOr<size_t> SB16::write(FileDescription&, size_t, const UserOrKernelBuffer& data, size_t length)
|
||||
KResultOr<size_t> SB16::write(FileDescription&, u64, const UserOrKernelBuffer& data, size_t length)
|
||||
{
|
||||
if (!m_dma_region) {
|
||||
auto page = MM.allocate_supervisor_physical_page();
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
|
||||
virtual const char* purpose() const override { return class_name(); }
|
||||
|
|
|
@ -45,7 +45,7 @@ bool SerialDevice::can_read(const FileDescription&, size_t) const
|
|||
return (get_line_status() & DataReady) != 0;
|
||||
}
|
||||
|
||||
KResultOr<size_t> SerialDevice::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> SerialDevice::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return 0;
|
||||
|
@ -69,7 +69,7 @@ bool SerialDevice::can_write(const FileDescription&, size_t) const
|
|||
return (get_line_status() & EmptyTransmitterHoldingRegister) != 0;
|
||||
}
|
||||
|
||||
KResultOr<size_t> SerialDevice::write(FileDescription&, size_t, const UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> SerialDevice::write(FileDescription&, u64, const UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return 0;
|
||||
|
|
|
@ -43,9 +43,9 @@ public:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
|
||||
enum InterruptEnable {
|
||||
LowPowerMode = 0x01 << 5,
|
||||
|
|
|
@ -44,7 +44,7 @@ bool ZeroDevice::can_read(const FileDescription&, size_t) const
|
|||
return true;
|
||||
}
|
||||
|
||||
KResultOr<size_t> ZeroDevice::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> ZeroDevice::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
ssize_t count = min(static_cast<size_t>(PAGE_SIZE), size);
|
||||
if (!buffer.memset(0, count))
|
||||
|
@ -52,7 +52,7 @@ KResultOr<size_t> ZeroDevice::read(FileDescription&, size_t, UserOrKernelBuffer&
|
|||
return count;
|
||||
}
|
||||
|
||||
KResultOr<size_t> ZeroDevice::write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t size)
|
||||
KResultOr<size_t> ZeroDevice::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t size)
|
||||
{
|
||||
return min(static_cast<size_t>(PAGE_SIZE), size);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ public:
|
|||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
virtual const char* class_name() const override { return "ZeroDevice"; }
|
||||
|
|
|
@ -46,8 +46,8 @@ private:
|
|||
virtual String absolute_path(const FileDescription&) const override { return ":anonymous-file:"; }
|
||||
virtual bool can_read(const FileDescription&, size_t) const override { return false; }
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return false; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
|
||||
|
||||
explicit AnonymousFile(NonnullRefPtr<AnonymousVMObject>);
|
||||
|
||||
|
|
|
@ -144,14 +144,14 @@ bool FIFO::can_write(const FileDescription&, size_t) const
|
|||
return m_buffer.space_for_writing() || !m_readers;
|
||||
}
|
||||
|
||||
KResultOr<size_t> FIFO::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> FIFO::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (!m_writers && m_buffer.is_empty())
|
||||
return 0;
|
||||
return m_buffer.read(buffer, size);
|
||||
}
|
||||
|
||||
KResultOr<size_t> FIFO::write(FileDescription&, size_t, const UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> FIFO::write(FileDescription&, u64, const UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (!m_readers) {
|
||||
Thread::current()->send_signal(SIGPIPE, Process::current());
|
||||
|
|
|
@ -57,8 +57,8 @@ public:
|
|||
|
||||
private:
|
||||
// ^File
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResult stat(::stat&) const override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
|
|
|
@ -111,8 +111,8 @@ public:
|
|||
virtual KResult attach(FileDescription&) { return KSuccess; }
|
||||
virtual void detach(FileDescription&) { }
|
||||
virtual void did_seek(FileDescription&, off_t) { }
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) = 0;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) = 0;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) = 0;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0;
|
||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg);
|
||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared);
|
||||
virtual KResult stat(::stat&) const { return EBADF; }
|
||||
|
|
|
@ -46,7 +46,7 @@ InodeFile::~InodeFile()
|
|||
{
|
||||
}
|
||||
|
||||
KResultOr<size_t> InodeFile::read(FileDescription& description, size_t offset, UserOrKernelBuffer& buffer, size_t count)
|
||||
KResultOr<size_t> InodeFile::read(FileDescription& description, u64 offset, UserOrKernelBuffer& buffer, size_t count)
|
||||
{
|
||||
if (Checked<off_t>::addition_would_overflow(offset, count))
|
||||
return EOVERFLOW;
|
||||
|
@ -61,7 +61,7 @@ KResultOr<size_t> InodeFile::read(FileDescription& description, size_t offset, U
|
|||
return nread;
|
||||
}
|
||||
|
||||
KResultOr<size_t> InodeFile::write(FileDescription& description, size_t offset, const UserOrKernelBuffer& data, size_t count)
|
||||
KResultOr<size_t> InodeFile::write(FileDescription& description, u64 offset, const UserOrKernelBuffer& data, size_t count)
|
||||
{
|
||||
if (Checked<off_t>::addition_would_overflow(offset, count))
|
||||
return EOVERFLOW;
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
virtual bool can_read(const FileDescription&, size_t) const override { return true; }
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared) override;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ bool InodeWatcher::can_write(const FileDescription&, size_t) const
|
|||
return true;
|
||||
}
|
||||
|
||||
KResultOr<size_t> InodeWatcher::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t buffer_size)
|
||||
KResultOr<size_t> InodeWatcher::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t buffer_size)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
VERIFY(!m_queue.is_empty() || !m_inode);
|
||||
|
@ -82,7 +82,7 @@ KResultOr<size_t> InodeWatcher::read(FileDescription&, size_t, UserOrKernelBuffe
|
|||
return bytes_to_write;
|
||||
}
|
||||
|
||||
KResultOr<size_t> InodeWatcher::write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t)
|
||||
KResultOr<size_t> InodeWatcher::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t)
|
||||
{
|
||||
return EIO;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ public:
|
|||
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual String absolute_path(const FileDescription&) const override;
|
||||
virtual const char* class_name() const override { return "InodeWatcher"; };
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ KResult Socket::getsockopt(FileDescription&, int level, int option, Userspace<vo
|
|||
}
|
||||
}
|
||||
|
||||
KResultOr<size_t> Socket::read(FileDescription& description, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> Socket::read(FileDescription& description, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (is_shut_down_for_reading())
|
||||
return 0;
|
||||
|
@ -251,7 +251,7 @@ KResultOr<size_t> Socket::read(FileDescription& description, size_t, UserOrKerne
|
|||
return recvfrom(description, buffer, size, 0, {}, 0, t);
|
||||
}
|
||||
|
||||
KResultOr<size_t> Socket::write(FileDescription& description, size_t, const UserOrKernelBuffer& data, size_t size)
|
||||
KResultOr<size_t> Socket::write(FileDescription& description, u64, const UserOrKernelBuffer& data, size_t size)
|
||||
{
|
||||
if (is_shut_down_for_writing())
|
||||
return EPIPE;
|
||||
|
|
|
@ -123,8 +123,8 @@ public:
|
|||
Lock& lock() { return m_lock; }
|
||||
|
||||
// ^File
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override final;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override final;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override final;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override final;
|
||||
virtual KResult stat(::stat&) const override;
|
||||
virtual String absolute_path(const FileDescription&) const override = 0;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ void DiskPartition::start_request(AsyncBlockDeviceRequest& request)
|
|||
request.block_index() + m_metadata.start_block(), request.block_count(), request.buffer(), request.buffer_size()));
|
||||
}
|
||||
|
||||
KResultOr<size_t> DiskPartition::read(FileDescription& fd, size_t offset, UserOrKernelBuffer& outbuf, size_t len)
|
||||
KResultOr<size_t> DiskPartition::read(FileDescription& fd, u64 offset, UserOrKernelBuffer& outbuf, size_t len)
|
||||
{
|
||||
unsigned adjust = m_metadata.start_block() * block_size();
|
||||
dbgln_if(OFFD_DEBUG, "DiskPartition::read offset={}, adjust={}, len={}", fd.offset(), adjust, len);
|
||||
|
@ -71,7 +71,7 @@ bool DiskPartition::can_read(const FileDescription& fd, size_t offset) const
|
|||
return m_device->can_read(fd, offset + adjust);
|
||||
}
|
||||
|
||||
KResultOr<size_t> DiskPartition::write(FileDescription& fd, size_t offset, const UserOrKernelBuffer& inbuf, size_t len)
|
||||
KResultOr<size_t> DiskPartition::write(FileDescription& fd, u64 offset, const UserOrKernelBuffer& inbuf, size_t len)
|
||||
{
|
||||
unsigned adjust = m_metadata.start_block() * block_size();
|
||||
dbgln_if(OFFD_DEBUG, "DiskPartition::write offset={}, adjust={}, len={}", offset, adjust, len);
|
||||
|
|
|
@ -40,9 +40,9 @@ public:
|
|||
virtual void start_request(AsyncBlockDeviceRequest&) override;
|
||||
|
||||
// ^BlockDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
|
||||
// ^Device
|
||||
|
|
|
@ -57,7 +57,7 @@ NonnullRefPtr<StorageController> StorageDevice::controller() const
|
|||
return m_storage_controller;
|
||||
}
|
||||
|
||||
KResultOr<size_t> StorageDevice::read(FileDescription&, size_t offset, UserOrKernelBuffer& outbuf, size_t len)
|
||||
KResultOr<size_t> StorageDevice::read(FileDescription&, u64 offset, UserOrKernelBuffer& outbuf, size_t len)
|
||||
{
|
||||
unsigned index = offset / block_size();
|
||||
u16 whole_blocks = len / block_size();
|
||||
|
@ -122,7 +122,7 @@ bool StorageDevice::can_read(const FileDescription&, size_t offset) const
|
|||
return offset < (max_addressable_block() * block_size());
|
||||
}
|
||||
|
||||
KResultOr<size_t> StorageDevice::write(FileDescription&, size_t offset, const UserOrKernelBuffer& inbuf, size_t len)
|
||||
KResultOr<size_t> StorageDevice::write(FileDescription&, u64 offset, const UserOrKernelBuffer& inbuf, size_t len)
|
||||
{
|
||||
unsigned index = offset / block_size();
|
||||
u16 whole_blocks = len / block_size();
|
||||
|
|
|
@ -52,9 +52,9 @@ public:
|
|||
NonnullRefPtr<StorageController> controller() const;
|
||||
|
||||
// ^BlockDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
|
||||
// ^Device
|
||||
|
|
|
@ -62,14 +62,14 @@ String MasterPTY::pts_name() const
|
|||
return m_pts_name;
|
||||
}
|
||||
|
||||
KResultOr<size_t> MasterPTY::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> MasterPTY::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (!m_slave && m_buffer.is_empty())
|
||||
return 0;
|
||||
return m_buffer.read(buffer, size);
|
||||
}
|
||||
|
||||
KResultOr<size_t> MasterPTY::write(FileDescription&, size_t, const UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> MasterPTY::write(FileDescription&, u64, const UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (!m_slave)
|
||||
return EIO;
|
||||
|
|
|
@ -54,8 +54,8 @@ public:
|
|||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
virtual KResult close() override;
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<NonnullRefPtr<FileDescription>> open(int options) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override { return 0; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override { return 0; }
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return 0; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return 0; }
|
||||
virtual bool can_read(const FileDescription&, size_t) const override { return true; }
|
||||
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ bool SlavePTY::can_read(const FileDescription& description, size_t offset) const
|
|||
return TTY::can_read(description, offset);
|
||||
}
|
||||
|
||||
KResultOr<size_t> SlavePTY::read(FileDescription& description, size_t offset, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> SlavePTY::read(FileDescription& description, u64 offset, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (m_master->is_closed())
|
||||
return 0;
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
virtual const char* class_name() const override { return "SlavePTY"; }
|
||||
virtual KResult close() override;
|
||||
|
|
|
@ -52,7 +52,7 @@ void TTY::set_default_termios()
|
|||
memcpy(m_termios.c_cc, default_cc, sizeof(default_cc));
|
||||
}
|
||||
|
||||
KResultOr<size_t> TTY::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> TTY::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (Process::current()->pgid() != pgid()) {
|
||||
// FIXME: Should we propagate this error path somehow?
|
||||
|
@ -100,7 +100,7 @@ KResultOr<size_t> TTY::read(FileDescription&, size_t, UserOrKernelBuffer& buffer
|
|||
return (size_t)nwritten;
|
||||
}
|
||||
|
||||
KResultOr<size_t> TTY::write(FileDescription&, size_t, const UserOrKernelBuffer& buffer, size_t size)
|
||||
KResultOr<size_t> TTY::write(FileDescription&, u64, const UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
if (m_termios.c_lflag & TOSTOP && Process::current()->pgid() != pgid()) {
|
||||
[[maybe_unused]] auto rc = Process::current()->send_signal(SIGTTOU, nullptr);
|
||||
|
|
|
@ -39,8 +39,8 @@ class TTY : public CharacterDevice {
|
|||
public:
|
||||
virtual ~TTY() override;
|
||||
|
||||
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override final;
|
||||
|
|
Loading…
Reference in a new issue