aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-05-31 14:37:20 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-07-14 20:24:43 +0200
commit10792616c5087fb781ad907c7edab9bfd6eb3d1a (patch)
treeadd659ef287b63fcd10bf40858789ba85dd9a825 /kernel
parent6d3f75685368c62037006e426c89a932072fc0e9 (diff)
downloadkernel-10792616c5087fb781ad907c7edab9bfd6eb3d1a.tar.xz
kernel-10792616c5087fb781ad907c7edab9bfd6eb3d1a.zip
add comments
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kernel/filesystem/ext2/filesystem.hpp45
-rw-r--r--kernel/kernel/filesystem/ext2/inode.hpp4
2 files changed, 48 insertions, 1 deletions
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<size_t>;
+ /**
+ @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<size_t>;
+ /**
+ @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<kstd::vector<uint32_t>>;
+ /**
+ @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<void>;
- [[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<std::size_t>;
+ /**
+ @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<void>;
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: