aboutsummaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorMarcel Braun <marcel.braun@ost.ch>2026-04-28 09:32:53 +0200
committerMarcel Braun <marcel.braun@ost.ch>2026-04-28 09:32:53 +0200
commit9d2ec7c3999a550a5c5cdbc2bd952452cd4b7fc0 (patch)
treeb1e9347c3f03302afb1d0851eefba25dbf0f1c82 /kernel/include
parentf6f10575f75ac23d06e1d94f7861611503daa7af (diff)
parentd349812c2e1e6a7d62f53d1c959137794e8a648d (diff)
downloadteachos-9d2ec7c3999a550a5c5cdbc2bd952452cd4b7fc0.tar.xz
teachos-9d2ec7c3999a550a5c5cdbc2bd952452cd4b7fc0.zip
Merge branch 'refactoring' into 'develop-BA-FS26'
Refactoring See merge request teachos/kernel!27
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/kernel/filesystem/file_descriptor_table.hpp64
-rw-r--r--kernel/include/kernel/filesystem/open_file_descriptor.hpp (renamed from kernel/include/kernel/filesystem/open_file_description.hpp)24
-rw-r--r--kernel/include/kernel/filesystem/open_file_table.hpp63
-rw-r--r--kernel/include/kernel/filesystem/vfs.hpp1
-rw-r--r--kernel/include/kernel/test_support/filesystem/file_descriptor_table.hpp10
-rw-r--r--kernel/include/kernel/test_support/filesystem/open_file_table.hpp10
6 files changed, 85 insertions, 87 deletions
diff --git a/kernel/include/kernel/filesystem/file_descriptor_table.hpp b/kernel/include/kernel/filesystem/file_descriptor_table.hpp
deleted file mode 100644
index 293dc36..0000000
--- a/kernel/include/kernel/filesystem/file_descriptor_table.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef TEACH_OS_KERNEL_FILESYSTEM_FILE_DESCRIPTOR_TABLE_HPP
-#define TEACH_OS_KERNEL_FILESYSTEM_FILE_DESCRIPTOR_TABLE_HPP
-
-#include <kernel/filesystem/open_file_description.hpp>
-
-#include <kstd/memory>
-#include <kstd/vector>
-
-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.
- */
- struct file_descriptor_table
- {
- /**
- @brief Initialize the global file descriptor table. This method creates the singleton instance of the file
- descriptor table.
- @warning Panics if called more than once.
- */
- auto static init() -> void;
-
- /**
- @brief Get the global file descriptor table instance.
- @return A reference to the global file descriptor table.
- @warning Panics if the file descriptor table has not been initialized.
- */
- auto static get() -> file_descriptor_table &;
-
- /**
- @brief Destructor for the file descriptor table.
- */
- ~file_descriptor_table() = default;
-
- /**
- @brief Add a file to the descriptor table.
- @param f The file description to add.
- @return The file descriptor index assigned to the file, or -1 on failure.
- */
- auto add_file(kstd::shared_ptr<open_file_description> 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.
- */
- [[nodiscard]] auto get_file(int fd) const -> kstd::shared_ptr<open_file_description>;
-
- /**
- @brief Remove a file from the descriptor table.
- @param fd The file descriptor index to remove.
- @return 0 on success, or -1 on failure.
- */
- auto remove_file(int fd) -> int;
-
- private:
- file_descriptor_table() = default;
-
- kstd::vector<kstd::shared_ptr<open_file_description>> m_open_files{};
- };
-} // namespace kernel::filesystem
-
-#endif \ No newline at end of file
diff --git a/kernel/include/kernel/filesystem/open_file_description.hpp b/kernel/include/kernel/filesystem/open_file_descriptor.hpp
index fad41e4..036dcf0 100644
--- a/kernel/include/kernel/filesystem/open_file_description.hpp
+++ b/kernel/include/kernel/filesystem/open_file_descriptor.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTION_HPP
-#define TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTION_HPP
+#ifndef TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTOR_HPP
+#define TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTOR_HPP
#include <kernel/filesystem/inode.hpp>
@@ -10,24 +10,24 @@
namespace kernel::filesystem
{
/**
- @brief Represents an open file description in the filesystem. This class encapsulates the state of an open file,
+ @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_description
+ struct open_file_descriptor
{
/**
- @brief Constructs an open file description for the given @p inode.
- @param inode The inode to associate with the open file description.
+ @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_description(kstd::shared_ptr<inode> const & inode);
+ explicit open_file_descriptor(kstd::shared_ptr<inode> const & inode);
/**
- @brief Destructor for the open file description.
+ @brief Destructor for the open file descriptor.
*/
- ~open_file_description() = default;
+ ~open_file_descriptor() = default;
/**
- @brief Reads data from the open file description into a @p buffer, starting at the current file offset and for a
+ @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.
@@ -37,7 +37,7 @@ namespace kernel::filesystem
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
+ @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.
@@ -47,7 +47,7 @@ namespace kernel::filesystem
auto write(void const * buffer, size_t size) -> size_t;
/**
- @brief Returns the current file offset for this open file description.
+ @brief Returns the current file offset for this open file descriptor.
@return The current file offset in bytes.
*/
[[nodiscard]] auto offset() const -> size_t;
diff --git a/kernel/include/kernel/filesystem/open_file_table.hpp b/kernel/include/kernel/filesystem/open_file_table.hpp
new file mode 100644
index 0000000..2f9a421
--- /dev/null
+++ b/kernel/include/kernel/filesystem/open_file_table.hpp
@@ -0,0 +1,63 @@
+#ifndef TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_TABLE_HPP
+#define TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_TABLE_HPP
+
+#include <kernel/filesystem/open_file_descriptor.hpp>
+
+#include <kstd/memory>
+#include <kstd/vector>
+
+namespace kernel::filesystem
+{
+ /**
+ @brief A table for managing file descriptors in the filesystem. This class provides methods for adding, retrieving,
+ and removing open file descriptors.
+ */
+ struct open_file_table
+ {
+ /**
+ @brief Initialize the global open file table. This method creates the singleton instance of the open file table.
+ @warning Panics if called more than once.
+ */
+ auto static init() -> void;
+
+ /**
+ @brief Get the global open file table instance.
+ @return A reference to the global open file table.
+ @warning Panics if the open file table has not been initialized.
+ */
+ auto static get() -> open_file_table &;
+
+ /**
+ @brief Destructor for the open file table.
+ */
+ ~open_file_table() = default;
+
+ /**
+ @brief Add a file to the open file table.
+ @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<open_file_descriptor> const & f) -> int;
+
+ /**
+ @brief Get a file from the open file table.
+ @param fd The file descriptor index to retrieve.
+ @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<open_file_descriptor>;
+
+ /**
+ @brief Remove a file from the open file table.
+ @param fd The file descriptor index to remove.
+ @return 0 on success, or -1 on failure.
+ */
+ auto remove_file(int fd) -> int;
+
+ private:
+ open_file_table() = default;
+
+ kstd::vector<kstd::shared_ptr<open_file_descriptor>> m_open_files{};
+ };
+} // namespace kernel::filesystem
+
+#endif \ No newline at end of file
diff --git a/kernel/include/kernel/filesystem/vfs.hpp b/kernel/include/kernel/filesystem/vfs.hpp
index 5b5c868..881f458 100644
--- a/kernel/include/kernel/filesystem/vfs.hpp
+++ b/kernel/include/kernel/filesystem/vfs.hpp
@@ -4,7 +4,6 @@
#include <kernel/filesystem/dentry.hpp>
#include <kernel/filesystem/filesystem.hpp>
#include <kernel/filesystem/mount_table.hpp>
-#include <kernel/filesystem/open_file_description.hpp>
#include <kstd/memory>
diff --git a/kernel/include/kernel/test_support/filesystem/file_descriptor_table.hpp b/kernel/include/kernel/test_support/filesystem/file_descriptor_table.hpp
deleted file mode 100644
index bbc0f4a..0000000
--- a/kernel/include/kernel/test_support/filesystem/file_descriptor_table.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef TEACHOS_KERNEL_TEST_SUPPORT_FILESYSTEM_FILE_DESCRIPTOR_TABLE_HPP
-#define TEACHOS_KERNEL_TEST_SUPPORT_FILESYSTEM_FILE_DESCRIPTOR_TABLE_HPP
-
-namespace kernel::tests::filesystem::file_descriptor_table
-{
- //! Deinitialize the file descriptor table singleton.
- auto deinit() -> void;
-} // namespace kernel::tests::filesystem::file_descriptor_table
-
-#endif \ No newline at end of file
diff --git a/kernel/include/kernel/test_support/filesystem/open_file_table.hpp b/kernel/include/kernel/test_support/filesystem/open_file_table.hpp
new file mode 100644
index 0000000..46b0334
--- /dev/null
+++ b/kernel/include/kernel/test_support/filesystem/open_file_table.hpp
@@ -0,0 +1,10 @@
+#ifndef TEACHOS_KERNEL_TEST_SUPPORT_FILESYSTEM_OPEN_FILE_TABLE_HPP
+#define TEACHOS_KERNEL_TEST_SUPPORT_FILESYSTEM_OPEN_FILE_TABLE_HPP
+
+namespace kernel::tests::filesystem::open_file_table
+{
+ //! Deinitialize the open file table singleton.
+ auto deinit() -> void;
+} // namespace kernel::tests::filesystem::open_file_table
+
+#endif \ No newline at end of file