mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
FileSystem: Move block_size() from DiskBackedFS to FS
Let's just say that all filesystems have a block size, to keep things nice and simple.
This commit is contained in:
parent
752de9cd27
commit
c0bfea1b5c
4 changed files with 12 additions and 14 deletions
|
@ -139,14 +139,6 @@ ByteBuffer DiskBackedFS::read_blocks(unsigned index, unsigned count) const
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiskBackedFS::set_block_size(int block_size)
|
|
||||||
{
|
|
||||||
ASSERT(block_size > 0);
|
|
||||||
if (block_size == m_block_size)
|
|
||||||
return;
|
|
||||||
m_block_size = block_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiskBackedFS::flush_writes()
|
void DiskBackedFS::flush_writes()
|
||||||
{
|
{
|
||||||
LOCKER(m_lock);
|
LOCKER(m_lock);
|
||||||
|
|
|
@ -10,15 +10,11 @@ public:
|
||||||
DiskDevice& device() { return *m_device; }
|
DiskDevice& device() { return *m_device; }
|
||||||
const DiskDevice& device() const { return *m_device; }
|
const DiskDevice& device() const { return *m_device; }
|
||||||
|
|
||||||
int block_size() const { return m_block_size; }
|
|
||||||
|
|
||||||
virtual void flush_writes() override;
|
virtual void flush_writes() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
||||||
|
|
||||||
void set_block_size(int);
|
|
||||||
|
|
||||||
ByteBuffer read_block(unsigned index) const;
|
ByteBuffer read_block(unsigned index) const;
|
||||||
ByteBuffer read_blocks(unsigned index, unsigned count) const;
|
ByteBuffer read_blocks(unsigned index, unsigned count) const;
|
||||||
|
|
||||||
|
@ -26,8 +22,6 @@ protected:
|
||||||
bool write_blocks(unsigned index, unsigned count, const ByteBuffer&);
|
bool write_blocks(unsigned index, unsigned count, const ByteBuffer&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_block_size { 0 };
|
|
||||||
NonnullRefPtr<DiskDevice> m_device;
|
NonnullRefPtr<DiskDevice> m_device;
|
||||||
|
|
||||||
HashMap<unsigned, ByteBuffer> m_write_cache;
|
HashMap<unsigned, ByteBuffer> m_write_cache;
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,3 +76,10 @@ void FS::lock_all()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FS::set_block_size(int block_size)
|
||||||
|
{
|
||||||
|
ASSERT(block_size > 0);
|
||||||
|
if (block_size == m_block_size)
|
||||||
|
return;
|
||||||
|
m_block_size = block_size;
|
||||||
|
}
|
||||||
|
|
|
@ -61,13 +61,18 @@ public:
|
||||||
|
|
||||||
virtual void flush_writes() {}
|
virtual void flush_writes() {}
|
||||||
|
|
||||||
|
int block_size() const { return m_block_size; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FS();
|
FS();
|
||||||
|
|
||||||
|
void set_block_size(int);
|
||||||
|
|
||||||
mutable Lock m_lock { "FS" };
|
mutable Lock m_lock { "FS" };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned m_fsid { 0 };
|
unsigned m_fsid { 0 };
|
||||||
|
int m_block_size { 0 };
|
||||||
bool m_readonly { false };
|
bool m_readonly { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue