diff options
| author | Marcel Braun <marcel.braun@ost.ch> | 2026-05-25 11:13:18 +0200 |
|---|---|---|
| committer | Marcel Braun <marcel.braun@ost.ch> | 2026-05-25 11:13:18 +0200 |
| commit | 61d29a288334960cd9f43df91e4fd632a7f6ad66 (patch) | |
| tree | 8ca81c4589ef2a2ca55a4a33527a6f12c34bd224 /kernel/include | |
| parent | 093074d5209f2d0062be79059f5881ee051c07d0 (diff) | |
| download | kernel-61d29a288334960cd9f43df91e4fd632a7f6ad66.tar.xz kernel-61d29a288334960cd9f43df91e4fd632a7f6ad66.zip | |
Increase reference count of source_mount when one of its files is mounted somewhere
Diffstat (limited to 'kernel/include')
| -rw-r--r-- | kernel/include/kernel/filesystem/mount.hpp | 13 | ||||
| -rw-r--r-- | kernel/include/kernel/filesystem/vfs.hpp | 7 |
2 files changed, 13 insertions, 7 deletions
diff --git a/kernel/include/kernel/filesystem/mount.hpp b/kernel/include/kernel/filesystem/mount.hpp index 4ce374f..6c0c5b9 100644 --- a/kernel/include/kernel/filesystem/mount.hpp +++ b/kernel/include/kernel/filesystem/mount.hpp @@ -28,7 +28,8 @@ namespace kernel::filesystem @param parent_mount The parent mount that this mount is attached beneath. */ mount(kstd::shared_ptr<dentry> const & mount_dentry, kstd::shared_ptr<dentry> const & root_dentry, - kstd::shared_ptr<filesystem> const & fs, kstd::shared_ptr<mount> const & parent_mount); + kstd::shared_ptr<filesystem> const & fs, kstd::shared_ptr<mount> const & parent_mount, + kstd::shared_ptr<mount> const & source_mount); /** @brief Get the dentry where the filesystem is mounted. @@ -56,15 +57,20 @@ namespace kernel::filesystem [[nodiscard]] auto parent_mount() const -> kstd::shared_ptr<mount> const &; /** + @brief Get the source mount where this mount originates from. + */ + [[nodiscard]] auto source_mount() const -> kstd::shared_ptr<mount>; + + /** @brief Increment the reference count for this mount. */ auto increment_ref_count() -> void; /** @brief Decrement the reference count for this mount. - @return True if the reference count reached zero, false otherwise. + @warning Throws if ref_count is zero. */ - [[nodiscard]] auto decrement_ref_count() -> bool; + auto decrement_ref_count() -> void; /** @brief Check if the mount is ready to be unmounted. @@ -83,6 +89,7 @@ namespace kernel::filesystem kstd::shared_ptr<dentry> m_root_dentry; kstd::shared_ptr<filesystem> m_filesystem{}; kstd::shared_ptr<mount> m_parent_mount{}; + kstd::weak_ptr<mount> m_source_mount{}; std::atomic_size_t m_ref_count; }; } // namespace kernel::filesystem diff --git a/kernel/include/kernel/filesystem/vfs.hpp b/kernel/include/kernel/filesystem/vfs.hpp index aec8bfe..e6f2327 100644 --- a/kernel/include/kernel/filesystem/vfs.hpp +++ b/kernel/include/kernel/filesystem/vfs.hpp @@ -32,8 +32,7 @@ namespace kernel::filesystem non_existent_path = -2, mount_point_not_found = -3, unmount_failed = -4, - invalid_filesystem = -5, - close_failed = -6 + invalid_filesystem = -5 }; /** @@ -103,8 +102,8 @@ namespace kernel::filesystem [[nodiscard]] auto find_mount(std::string_view path) const -> kstd::shared_ptr<mount>; auto do_mount_internal(kstd::shared_ptr<dentry> const & mount_point_dentry, - kstd::shared_ptr<mount> const & parent_mount, kstd::shared_ptr<filesystem> const & fs) - -> void; + kstd::shared_ptr<mount> const & parent_mount, kstd::shared_ptr<filesystem> const & fs, + kstd::shared_ptr<mount> const & source_mount = nullptr) -> void; auto graft_persistent_device_fs(kstd::shared_ptr<devfs::filesystem> const & device_fs) -> void; |
