Kernel: Add basic mounting to VFS.
This commit is contained in:
@@ -132,12 +132,14 @@ namespace Kernel
|
||||
virtual BAN::StringView name() const override { return m_name; }
|
||||
|
||||
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) override;
|
||||
virtual BAN::ErrorOr<BAN::Vector<BAN::RefPtr<Inode>>> directory_inodes() override;
|
||||
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find(BAN::StringView) override;
|
||||
|
||||
virtual Type type() const override { return Type::Ext2; }
|
||||
virtual bool operator==(const Inode& other) const override;
|
||||
|
||||
protected:
|
||||
virtual BAN::ErrorOr<BAN::Vector<BAN::RefPtr<Inode>>> directory_inodes_impl() override;
|
||||
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find_impl(BAN::StringView) override;
|
||||
|
||||
private:
|
||||
BAN::ErrorOr<uint32_t> data_block_index(uint32_t);
|
||||
|
||||
@@ -170,7 +172,7 @@ namespace Kernel
|
||||
public:
|
||||
static BAN::ErrorOr<Ext2FS*> create(StorageDevice::Partition&);
|
||||
|
||||
virtual const BAN::RefPtr<Inode> root_inode() const override { return m_root_inode; }
|
||||
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_inode; }
|
||||
|
||||
private:
|
||||
Ext2FS(StorageDevice::Partition& partition)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Kernel
|
||||
class FileSystem
|
||||
{
|
||||
public:
|
||||
virtual const BAN::RefPtr<Inode> root_inode() const = 0;
|
||||
virtual BAN::RefPtr<Inode> root_inode() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/ForwardList.h>
|
||||
#include <BAN/Memory.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <BAN/String.h>
|
||||
#include <BAN/Vector.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
@@ -37,7 +36,6 @@ namespace Kernel
|
||||
|
||||
enum class Type
|
||||
{
|
||||
General,
|
||||
Ext2,
|
||||
};
|
||||
|
||||
@@ -55,12 +53,17 @@ namespace Kernel
|
||||
|
||||
virtual BAN::StringView name() const = 0;
|
||||
|
||||
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) = 0;
|
||||
virtual BAN::ErrorOr<BAN::Vector<BAN::RefPtr<Inode>>> directory_inodes() = 0;
|
||||
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find(BAN::StringView) = 0;
|
||||
BAN::ErrorOr<BAN::Vector<BAN::RefPtr<Inode>>> directory_inodes();
|
||||
BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find(BAN::StringView);
|
||||
|
||||
virtual Type type() const { return Type::General; }
|
||||
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) = 0;
|
||||
|
||||
virtual Type type() const = 0;
|
||||
virtual bool operator==(const Inode&) const = 0;
|
||||
|
||||
protected:
|
||||
virtual BAN::ErrorOr<BAN::Vector<BAN::RefPtr<Inode>>> directory_inodes_impl() = 0;
|
||||
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> directory_find_impl(BAN::StringView) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <BAN/HashMap.h>
|
||||
#include <BAN/String.h>
|
||||
#include <BAN/StringView.h>
|
||||
#include <kernel/FS/FileSystem.h>
|
||||
#include <kernel/Storage/StorageController.h>
|
||||
|
||||
@@ -15,7 +16,9 @@ namespace Kernel
|
||||
static VirtualFileSystem& get();
|
||||
virtual ~VirtualFileSystem() {};
|
||||
|
||||
virtual const BAN::RefPtr<Inode> root_inode() const override { return m_root_inode; }
|
||||
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_inode; }
|
||||
|
||||
BAN::ErrorOr<void> mount_test();
|
||||
|
||||
struct File
|
||||
{
|
||||
@@ -24,12 +27,20 @@ namespace Kernel
|
||||
};
|
||||
BAN::ErrorOr<File> file_from_absolute_path(BAN::StringView);
|
||||
|
||||
struct MountPoint
|
||||
{
|
||||
BAN::RefPtr<Inode> inode;
|
||||
FileSystem* target;
|
||||
};
|
||||
const BAN::Vector<MountPoint>& mount_points() const { return m_mount_points; }
|
||||
|
||||
private:
|
||||
VirtualFileSystem() = default;
|
||||
BAN::ErrorOr<void> initialize_impl();
|
||||
|
||||
private:
|
||||
BAN::RefPtr<Inode> m_root_inode;
|
||||
BAN::Vector<MountPoint> m_mount_points;
|
||||
BAN::Vector<StorageController*> m_storage_controllers;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user