mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00

We can't be calling the virtual FS::flush_writes() in order to flush the disk cache from within the disk cache, since an FS subclass may try to do cache stuff in its flush_writes() implementation. Instead, separate out the implementation of DiskBackedFS's flushing logic into a flush_writes_impl() and call that from the cache code.
35 lines
846 B
C++
35 lines
846 B
C++
#pragma once
|
|
|
|
#include "FileSystem.h"
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
class DiskCache;
|
|
|
|
class DiskBackedFS : public FS {
|
|
public:
|
|
virtual ~DiskBackedFS() override;
|
|
|
|
virtual bool is_disk_backed() const override { return true; }
|
|
|
|
DiskDevice& device() { return *m_device; }
|
|
const DiskDevice& device() const { return *m_device; }
|
|
|
|
virtual void flush_writes() override;
|
|
|
|
void flush_writes_impl();
|
|
|
|
protected:
|
|
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
|
|
|
bool read_block(unsigned index, u8* buffer) const;
|
|
bool read_blocks(unsigned index, unsigned count, u8* buffer) const;
|
|
|
|
bool write_block(unsigned index, const u8*);
|
|
bool write_blocks(unsigned index, unsigned count, const u8*);
|
|
|
|
private:
|
|
DiskCache& cache() const;
|
|
|
|
NonnullRefPtr<DiskDevice> m_device;
|
|
mutable OwnPtr<DiskCache> m_cache;
|
|
};
|