2018-10-10 11:53:07 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "FileSystem.h"
|
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
|
|
2019-09-30 10:31:06 +02:00
|
|
|
class DiskCache;
|
|
|
|
|
|
2018-11-15 17:13:10 +01:00
|
|
|
class DiskBackedFS : public FS {
|
2018-10-10 11:53:07 +02:00
|
|
|
public:
|
2018-11-15 17:13:10 +01:00
|
|
|
virtual ~DiskBackedFS() override;
|
2018-10-10 11:53:07 +02:00
|
|
|
|
2019-08-17 12:17:36 +03:00
|
|
|
virtual bool is_disk_backed() const override { return true; }
|
|
|
|
|
|
2018-10-16 11:21:49 +02:00
|
|
|
DiskDevice& device() { return *m_device; }
|
|
|
|
|
const DiskDevice& device() const { return *m_device; }
|
2018-10-10 11:53:07 +02:00
|
|
|
|
2019-04-25 22:05:53 +02:00
|
|
|
virtual void flush_writes() override;
|
|
|
|
|
|
2018-10-10 11:53:07 +02:00
|
|
|
protected:
|
2019-06-21 18:37:47 +02:00
|
|
|
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
2018-10-10 11:53:07 +02:00
|
|
|
|
2019-09-30 11:04:30 +02:00
|
|
|
bool read_block(unsigned index, u8* buffer) const;
|
|
|
|
|
bool read_blocks(unsigned index, unsigned count, u8* buffer) const;
|
2018-10-10 11:53:07 +02:00
|
|
|
|
2019-09-30 11:20:51 +02:00
|
|
|
bool write_block(unsigned index, const u8*);
|
|
|
|
|
bool write_blocks(unsigned index, unsigned count, const u8*);
|
2018-10-10 11:53:07 +02:00
|
|
|
|
|
|
|
|
private:
|
2019-09-30 10:31:06 +02:00
|
|
|
DiskCache& cache() const;
|
|
|
|
|
|
2019-06-21 18:37:47 +02:00
|
|
|
NonnullRefPtr<DiskDevice> m_device;
|
2019-09-30 10:31:06 +02:00
|
|
|
mutable OwnPtr<DiskCache> m_cache;
|
2018-10-10 11:53:07 +02:00
|
|
|
};
|