From 4e2624b63236fa309c9ecf53a694b6ac9babf4e6 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Sun, 26 Apr 2026 10:11:24 +0200 Subject: rename open_file_description to open_file_descriptor --- .../kernel/filesystem/file_descriptor_table.hpp | 14 ++--- .../kernel/filesystem/open_file_description.hpp | 62 ---------------------- .../kernel/filesystem/open_file_descriptor.hpp | 62 ++++++++++++++++++++++ 3 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 kernel/include/kernel/filesystem/open_file_description.hpp create mode 100644 kernel/include/kernel/filesystem/open_file_descriptor.hpp (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/file_descriptor_table.hpp b/kernel/include/kernel/filesystem/file_descriptor_table.hpp index 293dc36..b0e699b 100644 --- a/kernel/include/kernel/filesystem/file_descriptor_table.hpp +++ b/kernel/include/kernel/filesystem/file_descriptor_table.hpp @@ -1,7 +1,7 @@ #ifndef TEACH_OS_KERNEL_FILESYSTEM_FILE_DESCRIPTOR_TABLE_HPP #define TEACH_OS_KERNEL_FILESYSTEM_FILE_DESCRIPTOR_TABLE_HPP -#include +#include #include #include @@ -10,7 +10,7 @@ namespace kernel::filesystem { /** @brief A table for managing file descriptors in the filesystem. This class provides methods for adding, retrieving, - and removing open file descriptions. + and removing open file descriptors. */ struct file_descriptor_table { @@ -35,17 +35,17 @@ namespace kernel::filesystem /** @brief Add a file to the descriptor table. - @param f The file description to add. + @param f The file descriptor to add. @return The file descriptor index assigned to the file, or -1 on failure. */ - auto add_file(kstd::shared_ptr const & f) -> int; + auto add_file(kstd::shared_ptr const & f) -> int; /** @brief Get a file from the descriptor table. @param fd The file descriptor index to retrieve. - @return A pointer to the requested file description, or a null pointer if not found. + @return A pointer to the requested file descriptor, or a null pointer if not found. */ - [[nodiscard]] auto get_file(int fd) const -> kstd::shared_ptr; + [[nodiscard]] auto get_file(int fd) const -> kstd::shared_ptr; /** @brief Remove a file from the descriptor table. @@ -57,7 +57,7 @@ namespace kernel::filesystem private: file_descriptor_table() = default; - kstd::vector> m_open_files{}; + kstd::vector> m_open_files{}; }; } // namespace kernel::filesystem diff --git a/kernel/include/kernel/filesystem/open_file_description.hpp b/kernel/include/kernel/filesystem/open_file_description.hpp deleted file mode 100644 index fad41e4..0000000 --- a/kernel/include/kernel/filesystem/open_file_description.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTION_HPP -#define TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTION_HPP - -#include - -#include - -#include - -namespace kernel::filesystem -{ - /** - @brief Represents an open file description in the filesystem. This class encapsulates the state of an open file, - including a reference to the associated inode and the current file offset. - */ - struct open_file_description - { - /** - @brief Constructs an open file description for the given @p inode. - @param inode The inode to associate with the open file description. - */ - explicit open_file_description(kstd::shared_ptr const & inode); - - /** - @brief Destructor for the open file description. - */ - ~open_file_description() = default; - - /** - @brief Reads data from the open file description into a @p buffer, starting at the current file offset and for a - given - @p size. The file offset is advanced by the number of bytes read. - @param buffer The buffer to read data into. - @param size The number of bytes to read. - @return The number of bytes read. - */ - auto read(void * buffer, size_t size) -> size_t; - - /** - @brief Writes data to the open file description from a @p buffer, starting at the current file offset and for a - given - @p size. The file offset is advanced by the number of bytes written. - @param buffer The buffer to write data from. - @param size The number of bytes to write. - @return The number of bytes written. - */ - auto write(void const * buffer, size_t size) -> size_t; - - /** - @brief Returns the current file offset for this open file description. - @return The current file offset in bytes. - */ - [[nodiscard]] auto offset() const -> size_t; - - private: - kstd::shared_ptr m_inode; - size_t m_offset; - }; - -} // namespace kernel::filesystem - -#endif \ No newline at end of file diff --git a/kernel/include/kernel/filesystem/open_file_descriptor.hpp b/kernel/include/kernel/filesystem/open_file_descriptor.hpp new file mode 100644 index 0000000..036dcf0 --- /dev/null +++ b/kernel/include/kernel/filesystem/open_file_descriptor.hpp @@ -0,0 +1,62 @@ +#ifndef TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTOR_HPP +#define TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTOR_HPP + +#include + +#include + +#include + +namespace kernel::filesystem +{ + /** + @brief Represents an open file descriptor in the filesystem. This class encapsulates the state of an open file, + including a reference to the associated inode and the current file offset. + */ + struct open_file_descriptor + { + /** + @brief Constructs an open file descriptor for the given @p inode. + @param inode The inode to associate with the open file descriptor. + */ + explicit open_file_descriptor(kstd::shared_ptr const & inode); + + /** + @brief Destructor for the open file descriptor. + */ + ~open_file_descriptor() = default; + + /** + @brief Reads data from the open file descriptor into a @p buffer, starting at the current file offset and for a + given + @p size. The file offset is advanced by the number of bytes read. + @param buffer The buffer to read data into. + @param size The number of bytes to read. + @return The number of bytes read. + */ + auto read(void * buffer, size_t size) -> size_t; + + /** + @brief Writes data to the open file descriptor from a @p buffer, starting at the current file offset and for a + given + @p size. The file offset is advanced by the number of bytes written. + @param buffer The buffer to write data from. + @param size The number of bytes to write. + @return The number of bytes written. + */ + auto write(void const * buffer, size_t size) -> size_t; + + /** + @brief Returns the current file offset for this open file descriptor. + @return The current file offset in bytes. + */ + [[nodiscard]] auto offset() const -> size_t; + + private: + kstd::shared_ptr m_inode; + size_t m_offset; + }; + +} // namespace kernel::filesystem + +#endif \ No newline at end of file -- cgit v1.2.3