Kernel: Remove the assumption of 512 block size in read/write_block

Devices such as NVMe can have blocks bigger that 512. Use the
m_block_size variable in read/write_block function instead of the
hardcoded 512 block size.
This commit is contained in:
Pankaj Raghav 2022-01-29 11:29:09 +05:30 committed by Idan Horowitz
parent caecb6ba72
commit cf44d71edf
Notes: sideshowbarker 2024-07-17 20:02:16 +09:00

View file

@ -30,7 +30,7 @@ BlockDevice::~BlockDevice()
bool BlockDevice::read_block(u64 index, UserOrKernelBuffer& buffer)
{
auto read_request_or_error = try_make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Read, index, 1, buffer, 512);
auto read_request_or_error = try_make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Read, index, 1, buffer, m_block_size);
if (read_request_or_error.is_error()) {
dbgln("BlockDevice::read_block({}): try_make_request failed", index);
return false;
@ -56,7 +56,7 @@ bool BlockDevice::read_block(u64 index, UserOrKernelBuffer& buffer)
bool BlockDevice::write_block(u64 index, const UserOrKernelBuffer& buffer)
{
auto write_request_or_error = try_make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Write, index, 1, buffer, 512);
auto write_request_or_error = try_make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Write, index, 1, buffer, m_block_size);
if (write_request_or_error.is_error()) {
dbgln("BlockDevice::write_block({}): try_make_request failed", index);
return false;