aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/filesystem/vfs.cpp
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-03-24 18:52:41 +0100
committerLukas Oesch <lukasoesch20@gmail.com>2026-03-26 21:19:03 +0100
commit7351349f296f100f10db62b5a834a971fbe51473 (patch)
tree297c9cd647c36fad6909ce71ce714a8d737498da /kernel/src/filesystem/vfs.cpp
parenta2ac8770937a28d0d4c674e25c9b3c77802a5c9e (diff)
downloadteachos-7351349f296f100f10db62b5a834a971fbe51473.tar.xz
teachos-7351349f296f100f10db62b5a834a971fbe51473.zip
small refactoring
Diffstat (limited to 'kernel/src/filesystem/vfs.cpp')
-rw-r--r--kernel/src/filesystem/vfs.cpp36
1 files changed, 10 insertions, 26 deletions
diff --git a/kernel/src/filesystem/vfs.cpp b/kernel/src/filesystem/vfs.cpp
index c77736a..78dec77 100644
--- a/kernel/src/filesystem/vfs.cpp
+++ b/kernel/src/filesystem/vfs.cpp
@@ -39,7 +39,6 @@ namespace filesystem
auto vfs::init_internal() -> void
{
auto storage_mgmt = devices::storage::storage_management::get();
- // TODO BA-FS26 fix mounting boot_device
if (auto boot_device = storage_mgmt.determine_boot_device())
{
m_root_fs = kstd::make_shared<ext2::ext2_filesystem>();
@@ -82,9 +81,9 @@ namespace filesystem
return nullptr;
}
- auto vfs::do_mount(std::string_view path, kstd::shared_ptr<filesystem> const & new_filesystem) -> int
+ auto vfs::do_mount(std::string_view path, kstd::shared_ptr<filesystem> const & filesystem) -> int
{
- if (!new_filesystem)
+ if (!filesystem)
{
return -1; // TODO BA-FS26 panic or errorcode?
}
@@ -100,22 +99,19 @@ namespace filesystem
return -1; // TODO BA-FS26 panic or errorcode?
}
- auto mount_dentry = resolve_path(path);
-
- if (!mount_dentry)
+ if (auto mount_dentry = resolve_path(path))
{
- return -1; // mount point path doesn't exist
- }
+ // TODO BA-FS26 check if mount point is already mounted and handle it (unmount old fs, fail, etc.)
- // TODO BA-FS26 check if mount point is already mounted and handle it (unmount old fs, fail, etc.)
+ mount_dentry->set_flag(dentry::dentry_flags::dcache_mounted);
+ m_mount_table.add_mount(kstd::make_shared<mount>(mount_dentry, filesystem));
- mount_dentry->set_flag(dentry::dentry_flags::dcache_mounted);
- m_mount_table.add_mount(kstd::make_shared<mount>(mount_dentry, new_filesystem));
+ filesystem->set_root_dentry(kstd::make_shared<dentry>(mount_dentry->get_parent(), filesystem->root_inode()));
- new_filesystem->set_root_dentry(
- kstd::make_shared<dentry>(mount_dentry->get_parent(), new_filesystem->root_inode()));
+ return 0;
+ }
- return 0;
+ return -1;
}
auto vfs::make_device_node(kstd::shared_ptr<devices::device> const & device) -> void
@@ -183,18 +179,6 @@ namespace filesystem
return nullptr;
}
}
- // | std::views::transform([this](auto const & part) {
- // // TODO BA-FS26 implement real path resolution with mounts and directories etc.
- // // For now, just return null for any non-device-node path.
- // return std::optional<kstd::shared_ptr<dentry>>{};
- // })
- // | std::views::filter([](auto const & opt) { return opt.has_value(); })
- // | std::views::transform([](auto const & opt) { return opt.value(); })
- // | std::ranges::find_if(m_mount_table, [&](auto const & mount) {
- // // TODO BA-FS26 implement real path resolution with mounts and directories etc.
- // // For now, just check if the first path component matches a mount point.
- // return part == mount.path();
- // });
}
return nullptr;