From c33246235af6e291d6ef42f6f68ab50a06bfb0eb Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 9 Feb 2024 08:04:38 +0200 Subject: [PATCH] Kernel/Storage: Change semantics for addressing block methods Add a method for matehmatical operations when verifying IO operation boundaries. Also, make max_addressable_block method non-virtual, since no other derived class actually has ever overrided this method. --- Kernel/Devices/Storage/StorageDevice.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Kernel/Devices/Storage/StorageDevice.h b/Kernel/Devices/Storage/StorageDevice.h index 52e916587e..bae2c779e7 100644 --- a/Kernel/Devices/Storage/StorageDevice.h +++ b/Kernel/Devices/Storage/StorageDevice.h @@ -54,7 +54,12 @@ public: }; public: - virtual u64 max_addressable_block() const { return m_max_addressable_block; } + u64 max_addressable_block() const { return m_max_addressable_block; } + + // NOTE: This method should be used when we need to calculate the actual + // end of the storage device, because LBAs start counting at 0, which is not + // practical in many cases for verifying IO operation boundaries. + u64 max_mathematical_addressable_block() const { return m_max_addressable_block + 1; } // ^BlockDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;