1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 17:07:35 +00:00

Kernel/Storage: Declare proper blocking support for StorageDevices

We remove can_read() and can_write(), as both of these methods should be
implemented for proper blocking support.
For our case, the previous code will simply block the user if they tries
to read beyond the max addressable offset, which is not a correct
behavior.

Instead, just do proper EOF guarding when calling read() and write() on
such objects.
This commit is contained in:
Liav A 2023-06-30 08:55:57 +03:00 committed by Andrew Kaster
parent c33246235a
commit 763ef690c6
2 changed files with 16 additions and 18 deletions

View file

@ -63,9 +63,9 @@ public:
// ^BlockDevice
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
virtual bool can_read(OpenFileDescription const&, u64) const override;
virtual bool can_read(OpenFileDescription const&, u64) const override { return true; }
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
virtual bool can_write(OpenFileDescription const&, u64) const override;
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
virtual void prepare_for_unplug() { m_partitions.clear(); }
Vector<NonnullLockRefPtr<DiskPartition>> const& partitions() const { return m_partitions; }