Kernel: Start work on adding support for new filesystems

Old code tried to create ext2 filesystem from all devices.
This commit is contained in:
2024-06-11 10:50:26 +03:00
parent d4903caafa
commit 766439db6d
7 changed files with 62 additions and 23 deletions

View File

@@ -45,7 +45,8 @@ namespace Kernel
};
public:
static BAN::ErrorOr<Ext2FS*> create(BAN::RefPtr<BlockDevice>);
static BAN::ErrorOr<bool> probe(BAN::RefPtr<BlockDevice>);
static BAN::ErrorOr<BAN::RefPtr<Ext2FS>> create(BAN::RefPtr<BlockDevice>);
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_inode; }
@@ -120,6 +121,7 @@ namespace Kernel
Ext2::Superblock m_superblock;
friend class Ext2Inode;
friend class BAN::RefPtr<Ext2FS>;
};
}

View File

@@ -1,14 +1,18 @@
#pragma once
#include <kernel/Device/Device.h>
#include <kernel/FS/Inode.h>
namespace Kernel
{
class FileSystem
class FileSystem : public BAN::RefCounted<FileSystem>
{
public:
virtual ~FileSystem() {}
static BAN::ErrorOr<BAN::RefPtr<FileSystem>> from_block_device(BAN::RefPtr<BlockDevice>);
virtual BAN::RefPtr<Inode> root_inode() = 0;
virtual dev_t dev() const = 0;

View File

@@ -13,7 +13,6 @@ namespace Kernel
public:
static void initialize(BAN::StringView);
static VirtualFileSystem& get();
virtual ~VirtualFileSystem() {};
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_fs->root_inode(); }
@@ -21,7 +20,7 @@ namespace Kernel
virtual dev_t dev() const override { return 0; }
BAN::ErrorOr<void> mount(const Credentials&, BAN::StringView, BAN::StringView);
BAN::ErrorOr<void> mount(const Credentials&, FileSystem*, BAN::StringView);
BAN::ErrorOr<void> mount(const Credentials&, BAN::RefPtr<FileSystem>, BAN::StringView);
struct File
{
@@ -35,16 +34,18 @@ namespace Kernel
struct MountPoint
{
BAN::RefPtr<FileSystem> target;
File host;
FileSystem* target;
};
MountPoint* mount_from_host_inode(BAN::RefPtr<Inode>);
MountPoint* mount_from_root_inode(BAN::RefPtr<Inode>);
private:
Mutex m_mutex;
FileSystem* m_root_fs = nullptr;
BAN::RefPtr<FileSystem> m_root_fs;
BAN::Vector<MountPoint> m_mount_points;
friend class BAN::RefPtr<VirtualFileSystem>;
};
}