aboutsummaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorMarcel Braun <marcel.braun@ost.ch>2026-05-13 11:27:49 +0200
committerMarcel Braun <marcel.braun@ost.ch>2026-05-13 11:27:49 +0200
commit9b8aa22868a510ac15463e7d4376a506df2db110 (patch)
treeee783d6c71963054835f04767eff93ce0e9c1337 /kernel/include
parent9d77ac6e5ae36be07b80d49080d017b19acfa02a (diff)
parent15afa6a030ee6e1fc6c255f9567b54d78c530d25 (diff)
downloadkernel-9b8aa22868a510ac15463e7d4376a506df2db110.tar.xz
kernel-9b8aa22868a510ac15463e7d4376a506df2db110.zip
Merge branch 'ext2-sparse-files' into 'develop-BA-FS26'
Ext2 sparse files See merge request teachos/kernel!35
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/kernel/filesystem/ext2/filesystem.hpp18
-rw-r--r--kernel/include/kernel/filesystem/mount.hpp3
2 files changed, 20 insertions, 1 deletions
diff --git a/kernel/include/kernel/filesystem/ext2/filesystem.hpp b/kernel/include/kernel/filesystem/ext2/filesystem.hpp
index 18ef372..46be32f 100644
--- a/kernel/include/kernel/filesystem/ext2/filesystem.hpp
+++ b/kernel/include/kernel/filesystem/ext2/filesystem.hpp
@@ -13,6 +13,7 @@
#include <cstddef>
#include <cstdint>
#include <string_view>
+#include <unistd.h>
namespace kernel::filesystem::ext2
{
@@ -82,15 +83,30 @@ namespace kernel::filesystem::ext2
@return The global block number.
*/
[[nodiscard]] auto map_inode_block_index_to_global_block_number(uint32_t inode_block_index, inode_data data) const
- -> uint32_t;
+ -> ssize_t;
private:
[[nodiscard]] auto read_inode(uint32_t inode_number) const -> kstd::shared_ptr<kernel::filesystem::ext2::inode>;
[[nodiscard]] auto read_block_number_at_index(uint32_t block_number, uint32_t index) const -> uint32_t;
+ [[nodiscard]] auto read_singly_indirect_block_number(uint32_t singly_indirect_block_number,
+ uint32_t block_index_in_singly_indirect_block) const
+ -> uint32_t;
+ [[nodiscard]] auto read_doubly_indirect_block_number(uint32_t doubly_indirect_block_number,
+ uint32_t block_index_in_doubly_indirect_block) const
+ -> uint32_t;
+ [[nodiscard]] auto read_triply_indirect_block_number(uint32_t triply_indirect_block_number,
+ uint32_t block_index_in_triply_indirect_block) const
+ -> uint32_t;
+
[[nodiscard]] auto get_inode_size() const -> size_t;
[[nodiscard]] auto get_inode_block_count(inode_data const & data) const -> uint32_t;
+ [[nodiscard]] auto block_numbers_per_block() const -> uint32_t;
+ [[nodiscard]] auto block_numbers_per_singly_indirect_block() const -> uint32_t;
+ [[nodiscard]] auto block_numbers_per_doubly_indirect_block() const -> uint32_t;
+ [[nodiscard]] auto block_numbers_per_triply_indirect_block() const -> uint32_t;
+
superblock m_superblock{};
kstd::vector<block_group_descriptor> m_block_group_descriptors;
};
diff --git a/kernel/include/kernel/filesystem/mount.hpp b/kernel/include/kernel/filesystem/mount.hpp
index af5d08b..f920891 100644
--- a/kernel/include/kernel/filesystem/mount.hpp
+++ b/kernel/include/kernel/filesystem/mount.hpp
@@ -7,6 +7,8 @@
#include <kstd/memory>
#include <kstd/string>
+#include <atomic>
+
namespace kernel::filesystem
{
/**
@@ -57,6 +59,7 @@ namespace kernel::filesystem
kstd::shared_ptr<dentry> m_root_dentry;
kstd::shared_ptr<filesystem> m_filesystem{};
kstd::shared_ptr<mount> m_parent_mount{};
+ std::atomic_uint32_t m_ref_count{0}; // TODO BA-FS26
};
} // namespace kernel::filesystem