aboutsummaryrefslogtreecommitdiff
path: root/kernel/kernel/filesystem/ext2/inode.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kernel/filesystem/ext2/inode.hpp')
-rw-r--r--kernel/kernel/filesystem/ext2/inode.hpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/kernel/kernel/filesystem/ext2/inode.hpp b/kernel/kernel/filesystem/ext2/inode.hpp
index 16cb04e0..61542ef8 100644
--- a/kernel/kernel/filesystem/ext2/inode.hpp
+++ b/kernel/kernel/filesystem/ext2/inode.hpp
@@ -44,9 +44,10 @@ namespace kernel::filesystem::ext2
/**
@brief Create an ext2 inode associated with the given filesystem.
@param fs The ext2 filesystem that this inode belongs to.
+ @param inode_number The inode number on disk.
@param data The data associated with this inode, read from the disk.
*/
- explicit inode(filesystem const * fs, inode_data const & data);
+ explicit inode(filesystem * fs, uint32_t inode_number, inode_data const & data);
/**
@brief Reads from the ext2 inode into a @p buffer, starting at the specified @p offset and for a given @p size.
@@ -59,7 +60,6 @@ namespace kernel::filesystem::ext2
/**
@brief Writes to the ext2 inode into a @p buffer, starting at the specified @p offset and for a given @p size.
- @warning This method is not implemented yet and will panic if called.
@param buffer Source buffer.
@param offset Write offset in bytes.
@param size Number of bytes requested.
@@ -68,12 +68,25 @@ namespace kernel::filesystem::ext2
auto write(void const * buffer, size_t offset, size_t size) -> kstd::result<size_t> override;
/**
+ @brief Appends the specified number of blocks to the inode.
+ @param count The number of blocks to append.
+ @return true if the blocks were successfully appended, false otherwise.
+ */
+ auto append_blocks(size_t count) -> bool;
+
+ /**
@brief Get the data associated with this inode.
- @return A reference to the inode data.
+ @return A const reference to the inode data.
*/
[[nodiscard]] auto data() const -> inode_data const &;
/**
+ @brief Get the data associated with this inode.
+ @return A reference to the inode data.
+ */
+ [[nodiscard]] auto data_mutable() -> inode_data &;
+
+ /**
@brief Check if this inode represents a directory.
@return returns true if this inode represents a directory, false otherwise.
*/
@@ -97,8 +110,21 @@ 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;
+
+ /**
+ @brief Get the inode number of this inode.
+ @return The inode number.
+ */
+ [[nodiscard]] auto number() const -> uint32_t;
+
private:
- filesystem const * m_filesystem;
+ filesystem * m_filesystem;
+ uint32_t m_inode_number{};
inode_data m_data{};
};
} // namespace kernel::filesystem::ext2