diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-15 15:53:29 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 16:43:04 +0100 |
| commit | ace2d2178315d4b4ff1d969feed562a53d7a66c1 (patch) | |
| tree | 989552b3818d22439efacefa5d0db6d447d7a1fe /kernel/filesystem/src | |
| parent | e87963115bcdc0f0534bc2194bf3f7e3d3f3e2b6 (diff) | |
| download | teachos-ace2d2178315d4b4ff1d969feed562a53d7a66c1.tar.xz teachos-ace2d2178315d4b4ff1d969feed562a53d7a66c1.zip | |
mount root filesystem
Diffstat (limited to 'kernel/filesystem/src')
| -rw-r--r-- | kernel/filesystem/src/vfs.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/kernel/filesystem/src/vfs.cpp b/kernel/filesystem/src/vfs.cpp index 27f1db9..3f2576f 100644 --- a/kernel/filesystem/src/vfs.cpp +++ b/kernel/filesystem/src/vfs.cpp @@ -2,6 +2,10 @@ #include "kapi/system.hpp" +#include "devices/storage/storage_management.hpp" +#include "filesystem/ext2/ext2_filesystem.hpp" +#include "filesystem/mount.hpp" + #include <optional> namespace filesystem @@ -9,7 +13,11 @@ namespace filesystem namespace { constinit auto static active_vfs = std::optional<vfs>{}; - } + + // TODO BA-FS26 @Felix better solution? while dynamic memory not available? + // TODO BA-FS26 remove when dynamic memory available; + constinit auto static root_fs = std::optional<ext2::ext2_filesystem>{}; + } // namespace auto vfs::init() -> void { @@ -19,6 +27,24 @@ namespace filesystem } active_vfs.emplace(vfs{}); + + auto storage_mgmt = devices::storage::storage_management::get(); + if (auto boot_device = storage_mgmt.determine_boot_device()) + { + root_fs.emplace(ext2::ext2_filesystem{}); + if (root_fs->mount(boot_device) != 0) + { + kapi::system::panic("[FILESYSTEM] Failed to mount root filesystem."); + } + + active_vfs->m_root_mount = mount{"/", &*root_fs}; + + // TODO BA-FS26 mount all the other devices to "/dev/ramxy" + } + else + { + // TODO BA-FS26 ?? what when no boot_device == no modules loaded?? + } } auto vfs::get() -> vfs & |
