diff options
Diffstat (limited to 'kernel/kernel/filesystem/inode.hpp')
| -rw-r--r-- | kernel/kernel/filesystem/inode.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/kernel/kernel/filesystem/inode.hpp b/kernel/kernel/filesystem/inode.hpp index afe15e7d..e7de9276 100644 --- a/kernel/kernel/filesystem/inode.hpp +++ b/kernel/kernel/filesystem/inode.hpp @@ -1,17 +1,24 @@ #ifndef TEACHOS_KERNEL_FILESYSTEM_INODE_HPP #define TEACHOS_KERNEL_FILESYSTEM_INODE_HPP +#include <kernel/filesystem/directory_listing_cursor.hpp> +#include <kernel/filesystem/directory_listing_entry.hpp> + #include <kapi/filesystem.hpp> +#include <kstd/memory.hpp> #include <kstd/result.hpp> #include <kstd/units.hpp> #include <cstddef> #include <optional> #include <span> +#include <utility> namespace kernel::filesystem { + struct mount; + //! An inode in the filesystem. //! //! Specific filesystems, or other subsystems, may provide their own implementation of this abstract base class. For @@ -101,7 +108,34 @@ namespace kernel::filesystem //! @return a device number if this inode refers to a device, an empty optional otherwise. [[nodiscard]] virtual auto raw_device() const -> std::optional<kapi::filesystem::device_number>; + //! List the contents of a directory. + //! + //! @param position The current directory listing position. + //! @param entries An output span to store directory entries. + //! @return A pair of the number or read entries and the next listing position on success, an error otherwise. + [[nodiscard]] virtual auto read_directory(directory_listing_cursor position, + std::span<directory_listing_entry> entries) const + -> kstd::result<std::pair<std::size_t, directory_listing_cursor>>; + //! @} + + //! @name Mount Resolution + //! @{ + + //! Get the mount this inode belongs to. + //! + //! @return The mount this inode belongs to. + [[nodiscard]] auto owning_mount() const noexcept -> kstd::weak_ptr<mount>; + + //! Define which mount this inode belongs to. + //! + //! @param source The mount this inode belongs to. + auto set_owning_mount(kstd::shared_ptr<mount> const & source) noexcept -> void; + + //! @} + + private: + kstd::weak_ptr<mount> m_owning_mount{}; }; } // namespace kernel::filesystem |
