serenity/VirtualFileSystem/DiskBackedFileSystem.h
Andreas Kling 9cd0a34b5c BlockDevice -> DiskDevice.
BlockDevice was the wrong name for this abstraction, since a block device
is a type of file in a unix system, and we should use that name for that
concept in the fs implementation.
2018-10-16 11:21:49 +02:00

31 lines
792 B
C++

#pragma once
#include "FileSystem.h"
#include <AK/ByteBuffer.h>
class DiskBackedFileSystem : public FileSystem {
public:
virtual ~DiskBackedFileSystem() override;
DiskDevice& device() { return *m_device; }
const DiskDevice& device() const { return *m_device; }
unsigned blockSize() const { return m_blockSize; }
protected:
explicit DiskBackedFileSystem(RetainPtr<DiskDevice>&&);
void setBlockSize(unsigned);
void invalidateCaches();
ByteBuffer readBlock(unsigned index) const;
ByteBuffer readBlocks(unsigned index, unsigned count) const;
bool writeBlock(unsigned index, const ByteBuffer&);
bool writeBlocks(unsigned index, unsigned count, const ByteBuffer&);
private:
unsigned m_blockSize { 0 };
RetainPtr<DiskDevice> m_device;
};