1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 18:45:08 +00:00
serenity/VirtualFileSystem/DiskBackedFileSystem.h
Andreas Kling 2529925fe9 Some more renaming:
FileSystem -> FS
SyntheticFileSystem -> SynthFS
ProcFileSystem -> ProcFS
Ext2FileSystem -> Ext2FS
Ext2Inode -> Ext2FSInode
2018-11-15 17:13:10 +01:00

35 lines
901 B
C++

#pragma once
#include "FileSystem.h"
#include <AK/ByteBuffer.h>
#include <AK/HashMap.h>
#include <AK/Lock.h>
class DiskBackedFS : public FS {
public:
virtual ~DiskBackedFS() override;
DiskDevice& device() { return *m_device; }
const DiskDevice& device() const { return *m_device; }
unsigned blockSize() const { return m_blockSize; }
protected:
explicit DiskBackedFS(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;
mutable SpinLock m_blockCacheLock;
mutable HashMap<unsigned, ByteBuffer> m_blockCache;
};