From c8bdcd90a8dd4ce9d173e339a20b58f482df78f4 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 9 Feb 2024 08:11:31 +0200 Subject: [PATCH] Kernel/Storage: Fix StorageDevice STORAGE_DEVICE_GET_SIZE ioctl option It calculated the disk size with the zero-based max addressable block value. For example, for a disk device with a block size of 512 bytes that has 2 LBAs so it can address LBA 0 and LBA 1 (so m_max_addressable_block is 1) the calculated disk size will be 512 instead of 1024 bytes. --- Kernel/Devices/Storage/StorageDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Devices/Storage/StorageDevice.cpp b/Kernel/Devices/Storage/StorageDevice.cpp index 7882b6d7a64..f94bebec65f 100644 --- a/Kernel/Devices/Storage/StorageDevice.cpp +++ b/Kernel/Devices/Storage/StorageDevice.cpp @@ -246,7 +246,7 @@ ErrorOr StorageDevice::ioctl(OpenFileDescription&, unsigned request, Users { switch (request) { case STORAGE_DEVICE_GET_SIZE: { - u64 disk_size = m_max_addressable_block * block_size(); + u64 disk_size = max_mathematical_addressable_block() * block_size(); return copy_to_user(static_ptr_cast(arg), &disk_size); break; }