Some checks failed
continuous-integration/drone/push Build is failing
The trick being caching lol.
41 lines
805 B
C++
41 lines
805 B
C++
#pragma once
|
|
#include "fs/StorageCache.h"
|
|
#include "fs/devices/Device.h"
|
|
|
|
class BlockDevice : public Device
|
|
{
|
|
public:
|
|
BlockDevice(u64 block_size, u64 num_blocks);
|
|
|
|
Result<usize> read(u8* buf, usize offset, usize length) const override;
|
|
|
|
virtual Result<void> read_block(Buffer& buf, u64 block) const = 0;
|
|
|
|
Result<usize> write(const u8*, usize, usize) override
|
|
{
|
|
return err(ENOTSUP);
|
|
}
|
|
|
|
usize size() const override
|
|
{
|
|
return m_block_size * m_num_blocks;
|
|
}
|
|
|
|
bool is_block_device() const override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Result<usize> block_size() const override
|
|
{
|
|
return m_block_size;
|
|
}
|
|
|
|
virtual ~BlockDevice() = default;
|
|
|
|
protected:
|
|
mutable StorageCache m_cache;
|
|
u64 m_block_size;
|
|
u64 m_num_blocks;
|
|
};
|