1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:58:13 +00:00

Kernel: Move DiskDevice::block_size() up to BlockDevice

All block devices should have a block size, after all. This defaults to
PAGE_SIZE if no size is specified.
This commit is contained in:
Andreas Kling 2019-08-21 16:45:52 +02:00
parent 52366e3f02
commit 5de483cfbb
11 changed files with 23 additions and 45 deletions

View file

@ -12,9 +12,9 @@ RefPtr<FileBackedDiskDevice> FileBackedDiskDevice::create(String&& image_path, u
return adopt(*new FileBackedDiskDevice(move(image_path), block_size));
}
FileBackedDiskDevice::FileBackedDiskDevice(String&& image_path, unsigned block_size)
: m_image_path(move(image_path))
, m_block_size(block_size)
FileBackedDiskDevice::FileBackedDiskDevice(const String& image_path, size_t block_size)
: DiskDevice(0, 0, block_size)
, m_image_path(image_path)
{
struct stat st;
int result = stat(m_image_path.characters(), &st);
@ -27,20 +27,15 @@ FileBackedDiskDevice::~FileBackedDiskDevice()
{
}
unsigned FileBackedDiskDevice::block_size() const
{
return m_block_size;
}
bool FileBackedDiskDevice::read_block(unsigned index, u8* out) const
{
DiskOffset offset = index * m_block_size;
DiskOffset offset = index * block_size();
return read_internal(offset, block_size(), out);
}
bool FileBackedDiskDevice::write_block(unsigned index, const u8* data)
{
DiskOffset offset = index * m_block_size;
DiskOffset offset = index * block_size();
return write_internal(offset, block_size(), data);
}