aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/filesystem/vfs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/filesystem/vfs.cpp')
-rw-r--r--kernel/src/filesystem/vfs.cpp19
1 files changed, 9 insertions, 10 deletions
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<vfs>{};
+
+ // 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<dentry> const & mount_point_dentry,