fix(kernel/vfs): fully implement ustar driver implementation + mounting system

This commit is contained in:
2025-05-18 11:38:42 +00:00
parent 70a08e46bd
commit f06c0b19fa
7 changed files with 1209 additions and 120 deletions

View File

@ -18,7 +18,6 @@
#include <fs/ramfs.hpp>
#include "../../kernel.h"
#include <fs/ustar.hpp>
#include <ini.h>
namespace Subsystem::Linux
@ -78,13 +77,21 @@ namespace Subsystem::Linux
debug("path=%s", uPath);
ini_destroy(ini);
if (fs->Lookup(root, uPath) != false)
eNode ret = fs->Lookup(root, uPath);
if (ret != false)
{
root = fs->Lookup(root, uPath);
// if (TestAndInitializeUSTAR(moduleAddress, moduleSize, 0))
// {
// }
Node tar = ret;
FileSystemInfo *fsi = fs->Probe(tar);
if (fsi == nullptr)
{
warn("Couldn't probe rootfs %s", uPath);
__CreateStubRoot();
}
else
{
Node mnt = fs->Lookup(root, "/mnt");
auto node = fs->Mount(mnt, "linux", fsi, tar);
}
}
else
{

View File

@ -18,6 +18,7 @@
#include <fs/ramfs.hpp>
#include "../../kernel.h"
#include <ini.h>
namespace Subsystem::Windows
{
@ -47,6 +48,50 @@ namespace Subsystem::Windows
{
if (fs->RootExists(2) == false)
{
Node root = fs->GetRoot(0);
Node cfg = fs->Lookup(root, "/sys/cfg/subsystem/windows");
if (cfg)
{
struct kstat st;
fs->Stat(cfg, &st);
std::unique_ptr<char[]> buf(new char[st.Size]);
fs->Read(cfg, buf.get(), st.Size, 0);
ini_t *ini = ini_load(buf.get(), NULL);
int section = ini_find_section(ini, "rootfs", NULL);
int pathIdx = ini_find_property(ini, section, "path", NULL);
const char *uPath = ini_property_value(ini, section, pathIdx);
debug("path=%s", uPath);
ini_destroy(ini);
eNode ret = fs->Lookup(root, uPath);
if (ret != false)
{
Node tar = ret;
FileSystemInfo *fsi = fs->Probe(tar);
if (fsi == nullptr)
{
warn("Couldn't probe rootfs %s", uPath);
__CreateStubRoot();
}
else
{
Node mnt = fs->Lookup(root, "/mnt");
auto node = fs->Mount(mnt, "windows", fsi, tar);
}
}
else
{
warn("Couldn't find rootfs path %s", uPath);
__CreateStubRoot();
}
}
else
{
warn("Couldn't open /sys/cfg/subsystem/windows");
__CreateStubRoot();
}
}
}
}