diff options
| -rw-r--r-- | kernel/filesystem/include/filesystem/vfs.hpp | 8 | ||||
| -rw-r--r-- | kernel/filesystem/src/vfs.cpp | 28 |
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 & |
