From 10792616c5087fb781ad907c7edab9bfd6eb3d1a Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Sun, 31 May 2026 14:37:20 +0200 Subject: add comments --- kernel/kernel/filesystem/ext2/filesystem.hpp | 45 +++++++++++++++++++++++++++- kernel/kernel/filesystem/ext2/inode.hpp | 4 +++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/kernel/kernel/filesystem/ext2/filesystem.hpp b/kernel/kernel/filesystem/ext2/filesystem.hpp index c6320ee2..b514938c 100644 --- a/kernel/kernel/filesystem/ext2/filesystem.hpp +++ b/kernel/kernel/filesystem/ext2/filesystem.hpp @@ -79,19 +79,56 @@ namespace kernel::filesystem::ext2 */ [[nodiscard]] auto revision_level() const -> uint32_t; + /** + @brief Reads a block from the backing device into the provided buffer. + @param block_number The number of the block to read. + @param buffer The buffer to read the block data into. + @return The number of bytes read. + */ auto read_block(uint32_t block_number, void * buffer) const -> kstd::result; + /** + @brief Writes a block of data from the provided buffer to the backing device. + @param block_number The number of the block to write. + @param buffer The buffer containing the data to write. + @return The number of bytes written. + */ auto write_block(uint32_t block_number, void const * buffer) -> kstd::result; + /** + @brief Allocates a specified number of blocks. + @param count The number of blocks to allocate. + @return An optional vector of the allocated block numbers, or a nullopt if allocation fails. + */ auto allocate_blocks(size_t count) -> kstd::result>; + /** + @brief Gets the size of an inode in the filesystem. + @return The size of an inode in bytes. + */ + [[nodiscard]] auto inode_size() const -> uint16_t; + + /** + @brief Gets the number of blocks allocated to an inode. + @param data The inode data. + @return The number of blocks allocated to the inode. + */ [[nodiscard]] auto inode_block_count(inode_data const & data) const -> uint32_t; + /** + @brief Updates the number of blocks allocated to an inode. + @param data The inode data. + @param delta The change in the number of blocks. + */ auto update_inode_block_count(inode_data & data, uint32_t delta) -> void; + /** + @brief Writes an inode to the backing device. + @param inode_number The number of the inode to write. + @param data The inode data to write. + */ auto write_inode(uint32_t inode_number, inode_data const & data) -> kstd::result; - [[nodiscard]] auto inode_size() const -> uint16_t; /** @brief Maps an inode block index to a global block number. @param inode_block_index The index of the block within the inode. @@ -101,6 +138,12 @@ namespace kernel::filesystem::ext2 [[nodiscard]] auto map_inode_block_index_to_global_block_number(size_t inode_block_index, inode_data data) const -> kstd::result; + /** + @brief Writes a global block number to an inode block index. + @param block_index The index of the block within the inode. + @param data The inode data. + @param global_block_number The global block number to write. + */ auto write_global_block_number_to_inode_block_index(size_t block_index, inode_data & data, uint32_t global_block_number) -> kstd::result; diff --git a/kernel/kernel/filesystem/ext2/inode.hpp b/kernel/kernel/filesystem/ext2/inode.hpp index 9c5f9beb..f01b9f1e 100644 --- a/kernel/kernel/filesystem/ext2/inode.hpp +++ b/kernel/kernel/filesystem/ext2/inode.hpp @@ -97,6 +97,10 @@ namespace kernel::filesystem::ext2 */ [[nodiscard]] auto size() const -> uint64_t; + /** + @brief Set the size of the file represented by this inode. + @param new_size The new size of the file in bytes. + */ auto set_size(uint64_t new_size) -> void; private: -- cgit v1.2.3