From dd330e7a05905713acfa87ec109956bfe78f78c4 Mon Sep 17 00:00:00 2001 From: Lukas Oesch Date: Wed, 8 Apr 2026 09:31:32 +0200 Subject: add descriptions, some refactoring --- kernel/src/filesystem/vfs.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'kernel/src/filesystem/vfs.cpp') diff --git a/kernel/src/filesystem/vfs.cpp b/kernel/src/filesystem/vfs.cpp index f9a051a..2578036 100644 --- a/kernel/src/filesystem/vfs.cpp +++ b/kernel/src/filesystem/vfs.cpp @@ -21,6 +21,11 @@ namespace kernel::filesystem namespace { constinit auto static active_vfs = std::optional{}; + + // Error codes + constexpr int INVALID_PATH = -1; + constexpr int MOUNT_POINT_NOT_FOUND = -2; + constexpr int FILESYSTEM_NULL = -3; } // namespace auto vfs::init() -> void @@ -79,18 +84,12 @@ namespace kernel::filesystem { if (!filesystem) { - return -1; // TODO BA-FS26 panic or errorcode? - } - - if (path.empty() || path.front() != '/') - { - return -1; // TODO BA-FS26 panic or errorcode? + return FILESYSTEM_NULL; } - // TODO BA-FS26 better path validation - if ((path.size() > 1 && path.back() == '/')) + if (path.empty() || path.front() != '/' || (path.size() > 1 && path.back() == '/')) { - return -1; // TODO BA-FS26 panic or errorcode? + return INVALID_PATH; } if (auto mount_point_dentry = resolve_path(path)) @@ -99,7 +98,7 @@ namespace kernel::filesystem return 0; } - return -1; + return MOUNT_POINT_NOT_FOUND; } auto vfs::do_mount_internal(std::string_view path, kstd::shared_ptr const & mount_point_dentry, -- cgit v1.2.3