diff options
author | Justin <sw1tchbl4d3@sw1tchbl4d3.com> | 2021-05-18 21:04:52 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-19 21:33:29 +0200 |
commit | 721a867c65435b62d4ba4575156ab5d4ba22af04 (patch) | |
tree | 59f2b98a2f44e2a25cb88edba38fc7942c1f8d7e /Kernel/FileSystem | |
parent | 145e246a5e9f229656bc1182bdc6c397ca8efe8a (diff) | |
download | serenity-721a867c65435b62d4ba4575156ab5d4ba22af04.zip |
Kernel: Expose FileSystem's fragment size
This commit will add a fragment_size() function similar to the
block_size() function.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 1 | ||||
-rw-r--r-- | Kernel/FileSystem/FileSystem.cpp | 8 | ||||
-rw-r--r-- | Kernel/FileSystem/FileSystem.h | 3 |
3 files changed, 12 insertions, 0 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index d36b710401..cbd7867621 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -114,6 +114,7 @@ bool Ext2FS::initialize() } set_block_size(EXT2_BLOCK_SIZE(&super_block)); + set_fragment_size(EXT2_FRAG_SIZE(&super_block)); VERIFY(block_size() <= (int)max_block_size); diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp index 9ada4d1443..17399b5f3f 100644 --- a/Kernel/FileSystem/FileSystem.cpp +++ b/Kernel/FileSystem/FileSystem.cpp @@ -81,4 +81,12 @@ void FS::set_block_size(size_t block_size) m_block_size = block_size; } +void FS::set_fragment_size(size_t fragment_size) +{ + VERIFY(fragment_size > 0); + if (fragment_size == m_fragment_size) + return; + m_fragment_size = fragment_size; +} + } diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index b2a6eda8ae..a96a8a0698 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -61,6 +61,7 @@ public: virtual void flush_writes() { } size_t block_size() const { return m_block_size; } + size_t fragment_size() const { return m_fragment_size; } virtual bool is_file_backed() const { return false; } @@ -71,12 +72,14 @@ protected: FS(); void set_block_size(size_t); + void set_fragment_size(size_t); mutable Lock m_lock { "FS" }; private: unsigned m_fsid { 0 }; size_t m_block_size { 0 }; + size_t m_fragment_size { 0 }; bool m_readonly { false }; }; |