From b3209ac2564f21f3b78ecf5e0c05ca346a4a4276 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Tue, 28 Apr 2026 10:49:34 +0200 Subject: refactor inode kind --- kernel/include/kernel/filesystem/devfs/inode.hpp | 10 ++++----- kernel/include/kernel/filesystem/device_inode.hpp | 5 +++++ kernel/include/kernel/filesystem/ext2/inode.hpp | 21 ++++++++++++++---- kernel/include/kernel/filesystem/inode.hpp | 25 +++++----------------- .../include/kernel/filesystem/open_file_table.hpp | 4 ++-- kernel/include/kernel/filesystem/rootfs/inode.hpp | 10 ++++----- .../kernel/test_support/filesystem/inode.hpp | 4 ++-- 7 files changed, 41 insertions(+), 38 deletions(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/devfs/inode.hpp b/kernel/include/kernel/filesystem/devfs/inode.hpp index 0fab280..5589730 100644 --- a/kernel/include/kernel/filesystem/devfs/inode.hpp +++ b/kernel/include/kernel/filesystem/devfs/inode.hpp @@ -13,11 +13,6 @@ namespace kernel::filesystem::devfs */ struct inode : kernel::filesystem::inode { - /** - @brief Create a devfs inode. The inode is initialized with the appropriate kind (directory). - */ - inode(); - /** @brief Reads from the devfs directory inode. @param buffer Destination buffer. @@ -35,6 +30,11 @@ namespace kernel::filesystem::devfs @return Number of bytes written (always 0 because writes are not supported for this inode). */ auto write(void const * buffer, size_t offset, size_t size) -> size_t override; + + /** + // % TODO BA-FS26 + */ + [[nodiscard]] auto is_directory() const -> bool override; }; } // namespace kernel::filesystem::devfs diff --git a/kernel/include/kernel/filesystem/device_inode.hpp b/kernel/include/kernel/filesystem/device_inode.hpp index 2f79fca..fb60524 100644 --- a/kernel/include/kernel/filesystem/device_inode.hpp +++ b/kernel/include/kernel/filesystem/device_inode.hpp @@ -50,6 +50,11 @@ namespace kernel::filesystem */ [[nodiscard]] auto device() const -> kstd::shared_ptr const &; + /** + // TODO BA-FS26 + */ + [[nodiscard]] auto is_device() const -> bool override; + private: kstd::shared_ptr m_device; }; diff --git a/kernel/include/kernel/filesystem/ext2/inode.hpp b/kernel/include/kernel/filesystem/ext2/inode.hpp index 9291eea..64cdb06 100644 --- a/kernel/include/kernel/filesystem/ext2/inode.hpp +++ b/kernel/include/kernel/filesystem/ext2/inode.hpp @@ -42,8 +42,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 data The data associated with this inode, read from the disk. */ - explicit inode(filesystem * fs); + explicit inode(filesystem * fs, 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. @@ -65,12 +67,23 @@ namespace kernel::filesystem::ext2 auto write(void const * buffer, size_t offset, size_t size) -> size_t override; /** - @brief The raw inode data as read from the disk. - */ - inode_data m_data{}; + // TODO BA-FS26 + */ + [[nodiscard]] auto data() const -> inode_data const &; + + /** + // TODO BA-FS26 + */ + [[nodiscard]] auto is_directory() const -> bool override; + + /** + // TODO BA-FS26 + */ + [[nodiscard]] auto is_regular() const -> bool override; private: filesystem * m_filesystem; + inode_data m_data{}; }; } // namespace kernel::filesystem::ext2 diff --git a/kernel/include/kernel/filesystem/inode.hpp b/kernel/include/kernel/filesystem/inode.hpp index 5208be2..d071a6b 100644 --- a/kernel/include/kernel/filesystem/inode.hpp +++ b/kernel/include/kernel/filesystem/inode.hpp @@ -11,20 +11,9 @@ namespace kernel::filesystem struct inode { /** - @brief Represents the kind of an inode. + @brief Create an inode. */ - enum class inode_kind - { - regular, - directory, - device - }; - - /** - @brief Create an inode with the given @p kind. - @param kind The kind of the inode. - */ - explicit inode(inode_kind kind); + inode() = default; /** @brief Virtual destructor for the inode. @@ -55,23 +44,19 @@ namespace kernel::filesystem @brief Returns whether the inode is a directory. @return true if the inode is a directory, false otherwise. */ - [[nodiscard]] auto is_directory() const -> bool; + [[nodiscard]] virtual auto is_directory() const -> bool; /** @brief Returns whether the inode is a regular file. @return true if the inode is a regular file, false otherwise. */ - [[nodiscard]] auto is_regular() const -> bool; + [[nodiscard]] virtual auto is_regular() const -> bool; /** @brief Returns whether the inode is a device. @return true if the inode is a device, false otherwise. */ - [[nodiscard]] auto is_device() const -> bool; - - // TODO BA-FS26 avoid public member - public: - inode_kind m_kind{inode_kind::regular}; + [[nodiscard]] virtual auto is_device() const -> bool; }; } // namespace kernel::filesystem diff --git a/kernel/include/kernel/filesystem/open_file_table.hpp b/kernel/include/kernel/filesystem/open_file_table.hpp index 2f9a421..694f3b6 100644 --- a/kernel/include/kernel/filesystem/open_file_table.hpp +++ b/kernel/include/kernel/filesystem/open_file_table.hpp @@ -34,10 +34,10 @@ namespace kernel::filesystem /** @brief Add a file to the open file table. - @param f The file descriptor to add. + @param fd 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 & fd) -> int; /** @brief Get a file from the open file table. diff --git a/kernel/include/kernel/filesystem/rootfs/inode.hpp b/kernel/include/kernel/filesystem/rootfs/inode.hpp index 37d0a30..e7c7eff 100644 --- a/kernel/include/kernel/filesystem/rootfs/inode.hpp +++ b/kernel/include/kernel/filesystem/rootfs/inode.hpp @@ -21,11 +21,6 @@ namespace kernel::filesystem::rootfs */ struct inode : kernel::filesystem::inode { - /** - @brief Create a rootfs inode. The inode is initialized with the appropriate kind (directory). - */ - inode(); - /** @brief Reads from the rootfs directory inode. @param buffer Destination buffer. @@ -57,6 +52,11 @@ namespace kernel::filesystem::rootfs */ auto lookup_child(std::string_view name) -> kstd::shared_ptr; + /** + // TODO BA-FS26 + */ + [[nodiscard]] auto is_directory() const -> bool override; + private: kstd::vector>> m_children; }; diff --git a/kernel/include/kernel/test_support/filesystem/inode.hpp b/kernel/include/kernel/test_support/filesystem/inode.hpp index 9d17917..8a76437 100644 --- a/kernel/include/kernel/test_support/filesystem/inode.hpp +++ b/kernel/include/kernel/test_support/filesystem/inode.hpp @@ -9,10 +9,10 @@ namespace kernel::tests::filesystem { struct inode : kernel::filesystem::inode { - inode(); - auto read(void * buffer, size_t offset, size_t size) const -> size_t override; auto write(void const * buffer, size_t offset, size_t size) -> size_t override; + + [[nodiscard]] auto is_regular() const -> bool override; }; } // namespace kernel::tests::filesystem -- cgit v1.2.3 From 6790ab170578594f26e8e84a3e57b80cb6094e21 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Tue, 28 Apr 2026 10:55:37 +0200 Subject: add is_symbolic_link method in ext2 inode --- kernel/include/kernel/filesystem/ext2/filesystem.hpp | 1 + kernel/include/kernel/filesystem/ext2/inode.hpp | 5 +++++ kernel/include/kernel/filesystem/inode.hpp | 6 ++++++ 3 files changed, 12 insertions(+) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/ext2/filesystem.hpp b/kernel/include/kernel/filesystem/ext2/filesystem.hpp index 516e71d..d22433f 100644 --- a/kernel/include/kernel/filesystem/ext2/filesystem.hpp +++ b/kernel/include/kernel/filesystem/ext2/filesystem.hpp @@ -35,6 +35,7 @@ namespace kernel::filesystem::ext2 constexpr uint16_t inline mode_mask = 0xF000; constexpr uint16_t inline mode_regular = 0x8000; constexpr uint16_t inline mode_directory = 0x4000; + constexpr uint16_t inline mode_symbolic_link = 0xA000; } // namespace constants /** diff --git a/kernel/include/kernel/filesystem/ext2/inode.hpp b/kernel/include/kernel/filesystem/ext2/inode.hpp index 64cdb06..688a1d8 100644 --- a/kernel/include/kernel/filesystem/ext2/inode.hpp +++ b/kernel/include/kernel/filesystem/ext2/inode.hpp @@ -81,6 +81,11 @@ namespace kernel::filesystem::ext2 */ [[nodiscard]] auto is_regular() const -> bool override; + /** + // TODO BA-FS26 + */ + [[nodiscard]] auto is_symbolic_link() const -> bool override; + private: filesystem * m_filesystem; inode_data m_data{}; diff --git a/kernel/include/kernel/filesystem/inode.hpp b/kernel/include/kernel/filesystem/inode.hpp index d071a6b..b34b921 100644 --- a/kernel/include/kernel/filesystem/inode.hpp +++ b/kernel/include/kernel/filesystem/inode.hpp @@ -57,6 +57,12 @@ namespace kernel::filesystem @return true if the inode is a device, false otherwise. */ [[nodiscard]] virtual auto is_device() const -> bool; + + /** + @brief Returns whether the inode is a symbolic link. + @return true if the inode is a symbolic link, false otherwise. + */ + [[nodiscard]] virtual auto is_symbolic_link() const -> bool; }; } // namespace kernel::filesystem -- cgit v1.2.3 From 62da1b8c8d1c59abc7ca33c144591839f126937e Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Thu, 30 Apr 2026 21:32:49 +0200 Subject: resolve todos --- kernel/include/kernel/filesystem/devfs/inode.hpp | 3 ++- kernel/include/kernel/filesystem/device_inode.hpp | 3 ++- kernel/include/kernel/filesystem/ext2/inode.hpp | 12 ++++++++---- kernel/include/kernel/filesystem/rootfs/inode.hpp | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/devfs/inode.hpp b/kernel/include/kernel/filesystem/devfs/inode.hpp index 5589730..e428891 100644 --- a/kernel/include/kernel/filesystem/devfs/inode.hpp +++ b/kernel/include/kernel/filesystem/devfs/inode.hpp @@ -32,7 +32,8 @@ namespace kernel::filesystem::devfs auto write(void const * buffer, size_t offset, size_t size) -> size_t override; /** - // % TODO BA-FS26 + @brief Check if this inode represents a directory. + @return returns true, since this inode represents the /dev directory in the devfs filesystem. */ [[nodiscard]] auto is_directory() const -> bool override; }; diff --git a/kernel/include/kernel/filesystem/device_inode.hpp b/kernel/include/kernel/filesystem/device_inode.hpp index fb60524..f4aa2d1 100644 --- a/kernel/include/kernel/filesystem/device_inode.hpp +++ b/kernel/include/kernel/filesystem/device_inode.hpp @@ -51,7 +51,8 @@ namespace kernel::filesystem [[nodiscard]] auto device() const -> kstd::shared_ptr const &; /** - // TODO BA-FS26 + @brief Check if this inode represents a device. + @return returns true, since this indoe is a device inode and represents a device. */ [[nodiscard]] auto is_device() const -> bool override; diff --git a/kernel/include/kernel/filesystem/ext2/inode.hpp b/kernel/include/kernel/filesystem/ext2/inode.hpp index 688a1d8..b4a3cc4 100644 --- a/kernel/include/kernel/filesystem/ext2/inode.hpp +++ b/kernel/include/kernel/filesystem/ext2/inode.hpp @@ -67,22 +67,26 @@ namespace kernel::filesystem::ext2 auto write(void const * buffer, size_t offset, size_t size) -> size_t override; /** - // TODO BA-FS26 + @brief Get the data associated with this inode. + @return A reference to the inode data. */ [[nodiscard]] auto data() const -> inode_data const &; /** - // TODO BA-FS26 + @brief Check if this inode represents a directory. + @return returns true if this inode represents a directory, false otherwise. */ [[nodiscard]] auto is_directory() const -> bool override; /** - // TODO BA-FS26 + @brief Check if this inode represents a regular file. + @return returns true if this inode represents a regular file, false otherwise. */ [[nodiscard]] auto is_regular() const -> bool override; /** - // TODO BA-FS26 + @brief Check if this inode represents a symbolic link. + @return returns true if this inode represents a symbolic link, false otherwise. */ [[nodiscard]] auto is_symbolic_link() const -> bool override; diff --git a/kernel/include/kernel/filesystem/rootfs/inode.hpp b/kernel/include/kernel/filesystem/rootfs/inode.hpp index e7c7eff..58035ea 100644 --- a/kernel/include/kernel/filesystem/rootfs/inode.hpp +++ b/kernel/include/kernel/filesystem/rootfs/inode.hpp @@ -53,7 +53,8 @@ namespace kernel::filesystem::rootfs auto lookup_child(std::string_view name) -> kstd::shared_ptr; /** - // TODO BA-FS26 + @brief Check if this inode represents a directory. + @return returns true, since this inode represents the root directory in the rootfs filesystem. */ [[nodiscard]] auto is_directory() const -> bool override; -- cgit v1.2.3 From 8550b6a1aacc2bfce733dcac7a44065b7e9116a1 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Sat, 2 May 2026 14:14:24 +0200 Subject: relative path support --- kernel/include/kernel/filesystem/dentry.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/dentry.hpp b/kernel/include/kernel/filesystem/dentry.hpp index 94fa39a..45d2ca2 100644 --- a/kernel/include/kernel/filesystem/dentry.hpp +++ b/kernel/include/kernel/filesystem/dentry.hpp @@ -24,7 +24,7 @@ namespace kernel::filesystem */ enum class dentry_flags : uint32_t { - dcache_mounted = 1 << 15 + mounted = 1 << 15 }; /** -- cgit v1.2.3 From d3c8b74020bfeee554394b7e41c58d5ddda6f396 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Sat, 2 May 2026 14:23:19 +0200 Subject: refactoring --- kernel/include/kernel/filesystem/dentry.hpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/dentry.hpp b/kernel/include/kernel/filesystem/dentry.hpp index 45d2ca2..bd62735 100644 --- a/kernel/include/kernel/filesystem/dentry.hpp +++ b/kernel/include/kernel/filesystem/dentry.hpp @@ -54,6 +54,12 @@ namespace kernel::filesystem */ [[nodiscard]] auto get_name() const -> std::string_view; + /** + @brief Get the full path of the dentry by traversing up to the root. + @return The full path of the dentry. + */ + [[nodiscard]] auto get_full_path() const -> kstd::string; + /** @brief Add a @p child dentry. @param child The child dentry to add. -- cgit v1.2.3 From 72d686961a26789b7659f17fb090511ee28604ec Mon Sep 17 00:00:00 2001 From: Marcel Braun Date: Mon, 4 May 2026 19:47:15 +0200 Subject: Add helper functions for path validation and splitting --- kernel/include/kernel/filesystem/path.hpp | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 kernel/include/kernel/filesystem/path.hpp (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/path.hpp b/kernel/include/kernel/filesystem/path.hpp new file mode 100644 index 0000000..976926f --- /dev/null +++ b/kernel/include/kernel/filesystem/path.hpp @@ -0,0 +1,56 @@ +#ifndef TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP +#define TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP + +#include +#include + +namespace kernel::filesystem::path +{ + /** + @brief Provides utilities for handling filesystem paths, including validation and splitting into components. + */ + + /** + @brief Checks if the given path is a valid absolute path (starts with '/'). + @param path The path to check. + @return true if the path is a valid absolute path, false otherwise. + */ + auto inline is_valid_absolute_path(std::string_view path) -> bool + { + return !path.empty() && path.front() == '/'; + } + + /** + @brief Checks if the given path is a valid relative path (doesn't start with '/'). + @param path The path to check. + @return true if the path is a valid relative path, false otherwise. + */ + auto inline is_valid_relative_path(std::string_view path) -> bool + { + return !path.empty() && path.front() != '/'; + } + + /** + @brief Checks if the given path is a valid path (either absolute or relative). + @param path The path to check. + @return true if the path is a valid path, false otherwise. + */ + auto inline is_valid_path(std::string_view path) -> bool + { + return is_valid_absolute_path(path) || is_valid_relative_path(path); + } + + /** + @brief Splits the given path into its components. + @param path The path to split. + @return A range of string views representing the components of the path. + */ + auto inline split(std::string_view path) + { + return std::views::split(path, '/') | std::views::filter([](auto const & part) { return !part.empty(); }) | + std::views::transform([](auto const & part) { return std::string_view(part.begin(), part.end()); }); + } + +} // namespace kernel::filesystem::path + +#endif // TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP \ No newline at end of file -- cgit v1.2.3 From d90d6bb4b4820df6cb4b0747439293bb85b8cbec Mon Sep 17 00:00:00 2001 From: Marcel Braun Date: Mon, 4 May 2026 20:17:43 +0200 Subject: Implement symlink read in inode, fix max amount of bytes to read --- kernel/include/kernel/filesystem/ext2/inode.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/ext2/inode.hpp b/kernel/include/kernel/filesystem/ext2/inode.hpp index b4a3cc4..b8f892a 100644 --- a/kernel/include/kernel/filesystem/ext2/inode.hpp +++ b/kernel/include/kernel/filesystem/ext2/inode.hpp @@ -20,7 +20,7 @@ namespace kernel::filesystem::ext2 { uint16_t mode; uint16_t uid; - uint32_t size; + uint32_t size; // TODO BA-FS26 signed? uint32_t atime; uint32_t ctime; uint32_t mtime; -- cgit v1.2.3 From 2ab9d6ffbc4aad8ab3a393bd32191e3c07103c0a Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Tue, 5 May 2026 14:37:47 +0200 Subject: fix problem with string_view lifetime --- kernel/include/kernel/filesystem/path.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/path.hpp b/kernel/include/kernel/filesystem/path.hpp index 976926f..298ac5f 100644 --- a/kernel/include/kernel/filesystem/path.hpp +++ b/kernel/include/kernel/filesystem/path.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace kernel::filesystem::path { @@ -43,12 +44,12 @@ namespace kernel::filesystem::path /** @brief Splits the given path into its components. @param path The path to split. - @return A range of string views representing the components of the path. + @return A range of strings representing the components of the path. */ auto inline split(std::string_view path) { return std::views::split(path, '/') | std::views::filter([](auto const & part) { return !part.empty(); }) | - std::views::transform([](auto const & part) { return std::string_view(part.begin(), part.end()); }); + std::views::transform([](auto const & part) { return kstd::string(std::string_view(part.begin(), part.end())); }); } } // namespace kernel::filesystem::path -- cgit v1.2.3 From 156925495d7bc8bd684a346e2ab9eea12f8187cc Mon Sep 17 00:00:00 2001 From: Marcel Braun Date: Tue, 5 May 2026 15:59:08 +0200 Subject: Add constants --- kernel/include/kernel/filesystem/constants.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 kernel/include/kernel/filesystem/constants.hpp (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/constants.hpp b/kernel/include/kernel/filesystem/constants.hpp new file mode 100644 index 0000000..aff512a --- /dev/null +++ b/kernel/include/kernel/filesystem/constants.hpp @@ -0,0 +1,13 @@ +#ifndef TEACH_OS_KERNEL_FILESYSTEM_CONSTANTS_HPP +#define TEACH_OS_KERNEL_FILESYSTEM_CONSTANTS_HPP + +#include +namespace kernel::filesystem::constants +{ + constexpr size_t inline max_path_length = 4096; + + constexpr size_t inline symlink_max_path_length = 4096; + constexpr size_t inline symloop_max = 40; +} // namespace kernel::filesystem::constants + +#endif \ No newline at end of file -- cgit v1.2.3 From 9f6353679f4052b2f685ad74994bfb6d54678d44 Mon Sep 17 00:00:00 2001 From: Marcel Braun Date: Tue, 5 May 2026 16:00:11 +0200 Subject: Add check for valid path length --- kernel/include/kernel/filesystem/path.hpp | 32 ++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/path.hpp b/kernel/include/kernel/filesystem/path.hpp index 298ac5f..4845bf1 100644 --- a/kernel/include/kernel/filesystem/path.hpp +++ b/kernel/include/kernel/filesystem/path.hpp @@ -1,41 +1,54 @@ #ifndef TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP #define TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP +#include + +#include + #include #include -#include namespace kernel::filesystem::path { /** @brief Provides utilities for handling filesystem paths, including validation and splitting into components. - */ + */ + + /** + @brief Checks if the given path is within the maximum allowed length. + @param path The path to check. + @return true if the path length is valid, false otherwise. + */ + auto inline is_valid_path_length(std::string_view path) -> bool + { + return path.length() < kernel::filesystem::constants::max_path_length; + } /** @brief Checks if the given path is a valid absolute path (starts with '/'). @param path The path to check. @return true if the path is a valid absolute path, false otherwise. - */ + */ auto inline is_valid_absolute_path(std::string_view path) -> bool { - return !path.empty() && path.front() == '/'; + return !path.empty() && path.front() == '/' && is_valid_path_length(path); } /** @brief Checks if the given path is a valid relative path (doesn't start with '/'). @param path The path to check. @return true if the path is a valid relative path, false otherwise. - */ + */ auto inline is_valid_relative_path(std::string_view path) -> bool { - return !path.empty() && path.front() != '/'; + return !path.empty() && path.front() != '/' && is_valid_path_length(path); } /** @brief Checks if the given path is a valid path (either absolute or relative). @param path The path to check. @return true if the path is a valid path, false otherwise. - */ + */ auto inline is_valid_path(std::string_view path) -> bool { return is_valid_absolute_path(path) || is_valid_relative_path(path); @@ -45,11 +58,12 @@ namespace kernel::filesystem::path @brief Splits the given path into its components. @param path The path to split. @return A range of strings representing the components of the path. - */ + */ auto inline split(std::string_view path) { return std::views::split(path, '/') | std::views::filter([](auto const & part) { return !part.empty(); }) | - std::views::transform([](auto const & part) { return kstd::string(std::string_view(part.begin(), part.end())); }); + std::views::transform( + [](auto const & part) { return kstd::string(std::string_view(part.begin(), part.end())); }); } } // namespace kernel::filesystem::path -- cgit v1.2.3 From 265ac82029665921bd95d74411682968ee0d4ada Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Tue, 5 May 2026 19:41:50 +0200 Subject: refactoring do_mount_internal (retrieve path from dentry), handle .. correctly in relative path --- kernel/include/kernel/filesystem/vfs.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/vfs.hpp b/kernel/include/kernel/filesystem/vfs.hpp index 881f458..7e66fb7 100644 --- a/kernel/include/kernel/filesystem/vfs.hpp +++ b/kernel/include/kernel/filesystem/vfs.hpp @@ -77,8 +77,8 @@ namespace kernel::filesystem auto init_internal() -> void; [[nodiscard]] auto resolve_path(std::string_view path) -> kstd::shared_ptr; - auto do_mount_internal(std::string_view path, kstd::shared_ptr const & mount_point_dentry, - kstd::shared_ptr const & fs) -> void; + auto do_mount_internal(kstd::shared_ptr const & mount_point_dentry, kstd::shared_ptr const & fs) + -> void; mount_table m_mount_table; }; -- cgit v1.2.3 From 7414148b662a33cf6c69f89b7b0c3162f6880d6c Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Tue, 5 May 2026 20:33:28 +0200 Subject: refactoring mount_table lookup --- kernel/include/kernel/filesystem/mount_table.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'kernel/include') diff --git a/kernel/include/kernel/filesystem/mount_table.hpp b/kernel/include/kernel/filesystem/mount_table.hpp index 00277ea..8e57d9e 100644 --- a/kernel/include/kernel/filesystem/mount_table.hpp +++ b/kernel/include/kernel/filesystem/mount_table.hpp @@ -39,13 +39,19 @@ namespace kernel::filesystem [[nodiscard]] auto remove_mount(std::string_view path) -> operation_result; /** - @brief Finds the mount with the longest prefix matching the given @p path. This method is used to determine which - mounted filesystem should handle a given path lookup. + @brief Finds the mount with the longest prefix matching the given @p path. @param path The path to match against the mount paths in the table. @return A pointer to the mount with the longest matching prefix, or a null pointer if no mount matches the path. */ [[nodiscard]] auto find_longest_prefix_mount(std::string_view path) const -> kstd::shared_ptr; + /** + @brief Finds the mount with the exact mount path matching the given @p path. + @param path The path to match against the mount paths in the table. + @return A pointer to the mount with the exact matching path, or a null pointer if no mount matches the path. + */ + [[nodiscard]] auto find_exact_mount(std::string_view path) const -> kstd::shared_ptr; + private: [[nodiscard]] auto has_child_mounts(kstd::shared_ptr const & parent_mount) const -> bool; -- cgit v1.2.3