Kernel: Shell can now mount partitions
This commit is contained in:
@@ -16,7 +16,8 @@ namespace Kernel
|
||||
{
|
||||
BlockDevice,
|
||||
CharacterDevice,
|
||||
DeviceController
|
||||
DeviceController,
|
||||
Partition,
|
||||
};
|
||||
|
||||
Device();
|
||||
@@ -24,6 +25,8 @@ namespace Kernel
|
||||
virtual DeviceType device_type() const = 0;
|
||||
virtual void update() {}
|
||||
|
||||
virtual InodeType inode_type() const override { return InodeType::Device; }
|
||||
|
||||
virtual timespec atime() const override { return m_create_time; }
|
||||
virtual timespec mtime() const override { return m_create_time; }
|
||||
virtual timespec ctime() const override { return m_create_time; }
|
||||
@@ -58,6 +61,8 @@ namespace Kernel
|
||||
|
||||
virtual BAN::RefPtr<Inode> root_inode() override { return this; }
|
||||
|
||||
virtual InodeType inode_type() const override { return InodeType::Device; }
|
||||
|
||||
virtual BAN::StringView name() const override { return "device-manager"; }
|
||||
|
||||
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> read_directory_inode(BAN::StringView) override;
|
||||
|
||||
@@ -137,6 +137,8 @@ namespace Kernel
|
||||
virtual dev_t dev() const override { return 0; }
|
||||
virtual dev_t rdev() const override { return 0; }
|
||||
|
||||
virtual InodeType inode_type() const override { return InodeType::Ext2; }
|
||||
|
||||
virtual BAN::StringView name() const override { return m_name; }
|
||||
|
||||
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) override;
|
||||
|
||||
@@ -48,6 +48,12 @@ namespace Kernel
|
||||
mode_t mode;
|
||||
};
|
||||
|
||||
enum class InodeType
|
||||
{
|
||||
Device,
|
||||
Ext2,
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~Inode() {}
|
||||
|
||||
@@ -67,6 +73,8 @@ namespace Kernel
|
||||
virtual dev_t dev() const = 0;
|
||||
virtual dev_t rdev() const = 0;
|
||||
|
||||
virtual InodeType inode_type() const = 0;
|
||||
|
||||
virtual BAN::StringView name() const = 0;
|
||||
|
||||
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> read_directory_inode(BAN::StringView) { if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); ASSERT_NOT_REACHED(); }
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Kernel
|
||||
|
||||
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_fs->root_inode(); }
|
||||
|
||||
BAN::ErrorOr<void> mount(FileSystem*, BAN::StringView);
|
||||
BAN::ErrorOr<void> mount(BAN::StringView, BAN::StringView);
|
||||
|
||||
struct File
|
||||
{
|
||||
@@ -27,6 +27,10 @@ namespace Kernel
|
||||
};
|
||||
BAN::ErrorOr<File> file_from_absolute_path(BAN::StringView);
|
||||
|
||||
private:
|
||||
VirtualFileSystem() = default;
|
||||
BAN::ErrorOr<void> mount(FileSystem*, BAN::StringView);
|
||||
|
||||
struct MountPoint
|
||||
{
|
||||
File host;
|
||||
@@ -34,9 +38,6 @@ namespace Kernel
|
||||
};
|
||||
MountPoint* mount_point_for_inode(BAN::RefPtr<Inode>);
|
||||
|
||||
private:
|
||||
VirtualFileSystem() = default;
|
||||
|
||||
private:
|
||||
FileSystem* m_root_fs = nullptr;
|
||||
BAN::Vector<MountPoint> m_mount_points;
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace Kernel
|
||||
BAN::ErrorOr<void> fstat(int, stat*);
|
||||
BAN::ErrorOr<void> stat(BAN::StringView, stat*);
|
||||
|
||||
BAN::ErrorOr<void> mount(BAN::StringView, BAN::StringView);
|
||||
|
||||
BAN::ErrorOr<BAN::Vector<BAN::String>> read_directory_entries(int);
|
||||
|
||||
BAN::String working_directory() const;
|
||||
|
||||
@@ -42,6 +42,8 @@ namespace Kernel
|
||||
char m_label[36 * 4 + 1];
|
||||
|
||||
public:
|
||||
virtual DeviceType device_type() const override { return DeviceType::Partition; }
|
||||
|
||||
virtual ino_t ino() const override { return m_index; }
|
||||
virtual Mode mode() const override { return { Mode::IFBLK | Mode::IRUSR | Mode::IRGRP }; }
|
||||
virtual nlink_t nlink() const override { return 1; }
|
||||
|
||||
Reference in New Issue
Block a user