1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:58:10 +00:00

Kernel: Split BlockBasedFileSystem off FileBackedFileSystem

FileBackedFileSystem is one that's backed by (mounted from) a file, in other
words one that has a "source" of the mount; that doesn't mean it deals in
blocks. The hierarchy now becomes:

* FS
  * ProcFS
  * DevPtsFS
  * TmpFS
  * FileBackedFS
    * (future) Plan9FS
    * BlockBasedFS
      * Ext2FS
This commit is contained in:
Sergey Bugaev 2020-07-02 12:48:08 +03:00 committed by Andreas Kling
parent 0c72a9eda7
commit 187b785a05
7 changed files with 371 additions and 294 deletions

View file

@ -28,7 +28,6 @@
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/Forward.h>
namespace Kernel {
@ -39,39 +38,15 @@ public:
File& file() { return m_file_description->file(); }
FileDescription& file_description() { return *m_file_description; }
const File& file() const { return m_file_description->file(); }
const FileDescription& file_description() const { return *m_file_description; }
virtual void flush_writes() override;
void flush_writes_impl();
size_t logical_block_size() const { return m_logical_block_size; };
FileDescription& file_description() const { return *m_file_description; }
protected:
explicit FileBackedFS(FileDescription&);
bool read_block(unsigned index, u8* buffer, size_t count, size_t offset = 0, bool allow_cache = true) const;
bool read_blocks(unsigned index, unsigned count, u8* buffer, bool allow_cache = true) const;
bool raw_read(unsigned index, u8* buffer);
bool raw_write(unsigned index, const u8* buffer);
bool raw_read_blocks(unsigned index, size_t count, u8* buffer);
bool raw_write_blocks(unsigned index, size_t count, const u8* buffer);
bool write_block(unsigned index, const u8* buffer, size_t count, size_t offset = 0, bool allow_cache = true);
bool write_blocks(unsigned index, unsigned count, const u8*, bool allow_cache = true);
size_t m_logical_block_size { 512 };
private:
virtual bool is_file_backed() const override { return true; }
DiskCache& cache() const;
void flush_specific_block_if_needed(unsigned index);
mutable NonnullRefPtr<FileDescription> m_file_description;
mutable OwnPtr<DiskCache> m_cache;
};
}