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.
This commit is contained in:
Liav A 2024-02-09 08:11:31 +02:00 committed by Andrew Kaster
parent 763ef690c6
commit c8bdcd90a8
Notes: sideshowbarker 2024-07-17 03:30:41 +09:00

View File

@ -246,7 +246,7 @@ ErrorOr<void> 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<u64*>(arg), &disk_size);
break;
}