aboutsummaryrefslogtreecommitdiff
path: root/kernel/kernel/filesystem/filesystem.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kernel/filesystem/filesystem.hpp')
-rw-r--r--kernel/kernel/filesystem/filesystem.hpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/kernel/kernel/filesystem/filesystem.hpp b/kernel/kernel/filesystem/filesystem.hpp
index b818d992..f9521d1f 100644
--- a/kernel/kernel/filesystem/filesystem.hpp
+++ b/kernel/kernel/filesystem/filesystem.hpp
@@ -4,8 +4,10 @@
#include <kernel/filesystem/inode.hpp>
#include <kstd/memory.hpp>
+#include <kstd/system_error.hpp>
#include <kstd/vector.hpp>
+#include <expected>
#include <string_view>
namespace kernel::filesystem
@@ -16,14 +18,6 @@ namespace kernel::filesystem
*/
struct filesystem
{
- enum class operation_result : int
- {
- success = 0,
- invalid_magic_number = -1,
- invalid_root_inode = -2,
- unmount_failed = -3
- };
-
/**
@brief Virtual destructor for the filesystem.
*/
@@ -34,19 +28,19 @@ namespace kernel::filesystem
and returns a pointer to the mounted filesystem instance. This method iterates through known filesystem types and
attempts to initialize it with the backing inode until the mount was successful or all types have been tried.
@param backing_inode The inode to probe and mount.
- @return A pointer to the mounted filesystem instance if successful, or a null pointer if no recognizable filesystem
- is found on the backing inode.
+ @return A pointer to the mounted filesystem instance if successful, an error otherwise.
@warning Panics if @p backing_inode is null.
*/
- auto static probe_and_mount(kstd::shared_ptr<inode> const & backing_inode) -> kstd::shared_ptr<filesystem>;
+ auto static probe_and_mount(kstd::shared_ptr<inode> const & backing_inode)
+ -> std::expected<kstd::shared_ptr<filesystem>, kstd::error_code>;
/**
@brief Initializes the filesystem with the given @p backing_inode.
@param backing_inode The inode to use as the backing inode for the filesystem. (This is typically the inode
representing the block device or another inode which contains the filesystem data.)
- @return The result of the mount operation.
+ @return Nothing on success, and error otherwise.
*/
- virtual auto mount(kstd::shared_ptr<inode> const & backing_inode) -> operation_result;
+ virtual auto mount(kstd::shared_ptr<inode> const & backing_inode) -> std::expected<void, kstd::error_code>;
/**
@brief Looks up a child inode within the given @p parent inode with the specified @p name. This method must be
@@ -54,10 +48,10 @@ namespace kernel::filesystem
finding the requested inode.
@param parent The parent inode.
@param name The name of the child inode to look up.
- @return A pointer to the requested child inode, or a null pointer if not found.
+ @return A pointer to the requested child inode, an error otherwise.
*/
[[nodiscard]] virtual auto lookup(kstd::shared_ptr<inode> const & parent, std::string_view name) const
- -> kstd::shared_ptr<inode> = 0;
+ -> std::expected<kstd::shared_ptr<inode>, kstd::error_code> = 0;
/**
@brief Returns a reference to the root inode of the filesystem.