blob: 87ea2ad88d3403ea27385f70605b50c5270b2a19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#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, FileDescription* = nullptr) const;
bool read_blocks(unsigned index, unsigned count, u8* buffer, FileDescription* = nullptr) const;
bool write_block(unsigned index, const u8*, FileDescription* = nullptr);
bool write_blocks(unsigned index, unsigned count, const u8*, FileDescription* = nullptr);
private:
DiskCache& cache() const;
void flush_specific_block_if_needed(unsigned index);
NonnullRefPtr<DiskDevice> m_device;
mutable OwnPtr<DiskCache> m_cache;
};
|