aboutsummaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/kernel/filesystem/mount.hpp19
-rw-r--r--kernel/include/kernel/filesystem/mount_table.hpp3
-rw-r--r--kernel/include/kernel/filesystem/open_file_descriptor.hpp8
-rw-r--r--kernel/include/kernel/filesystem/vfs.hpp8
4 files changed, 35 insertions, 3 deletions
diff --git a/kernel/include/kernel/filesystem/mount.hpp b/kernel/include/kernel/filesystem/mount.hpp
index f920891..fb5a627 100644
--- a/kernel/include/kernel/filesystem/mount.hpp
+++ b/kernel/include/kernel/filesystem/mount.hpp
@@ -54,12 +54,29 @@ namespace kernel::filesystem
*/
[[nodiscard]] auto get_parent_mount() const -> kstd::shared_ptr<mount> const &;
+ /**
+ @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.
+ */
+ auto decrement_ref_count() -> bool;
+
+ /**
+ @brief Check if the mount is ready to be unmounted.
+ @return True if the mount is ready to be unmounted, false otherwise.
+ */
+ [[nodiscard]] auto is_ready_to_unmount() const -> bool;
+
private:
kstd::shared_ptr<dentry> m_mount_dentry;
kstd::shared_ptr<dentry> m_root_dentry;
kstd::shared_ptr<filesystem> m_filesystem{};
kstd::shared_ptr<mount> m_parent_mount{};
- std::atomic_uint32_t m_ref_count{0}; // TODO BA-FS26
+ std::atomic_size_t m_ref_count;
};
} // namespace kernel::filesystem
diff --git a/kernel/include/kernel/filesystem/mount_table.hpp b/kernel/include/kernel/filesystem/mount_table.hpp
index 742c928..4f2d1b7 100644
--- a/kernel/include/kernel/filesystem/mount_table.hpp
+++ b/kernel/include/kernel/filesystem/mount_table.hpp
@@ -22,7 +22,8 @@ namespace kernel::filesystem
{
removed = 0,
has_child_mounts = -1,
- mount_not_found = -2
+ mount_not_found = -2,
+ cannot_be_unmounted = -3
};
/**
diff --git a/kernel/include/kernel/filesystem/open_file_descriptor.hpp b/kernel/include/kernel/filesystem/open_file_descriptor.hpp
index 823fe13..7ca7350 100644
--- a/kernel/include/kernel/filesystem/open_file_descriptor.hpp
+++ b/kernel/include/kernel/filesystem/open_file_descriptor.hpp
@@ -50,7 +50,13 @@ namespace kernel::filesystem
@brief Returns the current file offset for this open file descriptor.
@return The current file offset in bytes.
*/
- [[nodiscard]] auto offset() const -> size_t;
+ [[nodiscard]] auto get_offset() const -> size_t;
+
+ /**
+ @brief Return a reference to the dentry associated with this open file descriptor.
+ @return A reference to the associated dentry.
+ */
+ [[nodiscard]] auto get_dentry() const -> kstd::shared_ptr<dentry> const &;
private:
kstd::shared_ptr<dentry> m_dentry;
diff --git a/kernel/include/kernel/filesystem/vfs.hpp b/kernel/include/kernel/filesystem/vfs.hpp
index 7e2eae7..48b99b2 100644
--- a/kernel/include/kernel/filesystem/vfs.hpp
+++ b/kernel/include/kernel/filesystem/vfs.hpp
@@ -33,6 +33,7 @@ namespace kernel::filesystem
mount_point_not_found = -3,
unmount_failed = -4,
invalid_filesystem = -5,
+ close_failed = -6
};
/**
@@ -61,6 +62,13 @@ namespace kernel::filesystem
auto open(std::string_view path) -> kstd::shared_ptr<dentry>;
/**
+ @brief Close a file by its associated @p dentry.
+ @param dentry The dentry of the file to close.
+ @return The result of the close operation.
+ */
+ auto close(kstd::shared_ptr<dentry> const & dentry) -> operation_result;
+
+ /**
@brief Mount a @p source path to a specific @p target path.
@param source The source of the filesystem to mount.
@param target The path where the filesystem should be mounted.