aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-03-15 15:53:29 +0100
committerLukas Oesch <lukasoesch20@gmail.com>2026-03-17 16:43:04 +0100
commitace2d2178315d4b4ff1d969feed562a53d7a66c1 (patch)
tree989552b3818d22439efacefa5d0db6d447d7a1fe
parente87963115bcdc0f0534bc2194bf3f7e3d3f3e2b6 (diff)
downloadteachos-ace2d2178315d4b4ff1d969feed562a53d7a66c1.tar.xz
teachos-ace2d2178315d4b4ff1d969feed562a53d7a66c1.zip
mount root filesystem
-rw-r--r--kernel/filesystem/include/filesystem/vfs.hpp8
-rw-r--r--kernel/filesystem/src/vfs.cpp28
2 files changed, 35 insertions, 1 deletions
diff --git a/kernel/filesystem/include/filesystem/vfs.hpp b/kernel/filesystem/include/filesystem/vfs.hpp
index 671128e..5998137 100644
--- a/kernel/filesystem/include/filesystem/vfs.hpp
+++ b/kernel/filesystem/include/filesystem/vfs.hpp
@@ -1,7 +1,12 @@
#ifndef TEACH_OS_KERNEL_FILESYSTEM_VFS_HPP
#define TEACH_OS_KERNEL_FILESYSTEM_VFS_HPP
+#include "filesystem/mount.hpp"
+
+#include <array>
+#include <optional>
#include <string_view>
+
namespace filesystem
{
struct vfs
@@ -15,6 +20,9 @@ namespace filesystem
private:
vfs() = default;
+
+ std::optional<mount> m_root_mount;
+ std::array<mount, 10> m_mounts; // TODO BA-FS26 remove when kstd::vector is available and used
};
} // namespace filesystem
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 &