forked from Bananymous/banan-os
Kernel: Rework filesystem reading
We now read from a filesystem to user provided buffer. Read sizes are determined by read call. You should now get file descriptors and do reading through Process::current()
This commit is contained in:
@@ -131,12 +131,13 @@ namespace Kernel
|
||||
|
||||
virtual BAN::StringView name() const override { return m_name; }
|
||||
|
||||
virtual BAN::ErrorOr<BAN::Vector<uint8_t>> read_all() override;
|
||||
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;
|
||||
|
||||
private:
|
||||
BAN::ErrorOr<void> for_each_block(BAN::Function<BAN::ErrorOr<bool>(const BAN::Vector<uint8_t>&)>&);
|
||||
using block_callback_t = BAN::ErrorOr<bool>(*)(const BAN::Vector<uint8_t>&, void*);
|
||||
BAN::ErrorOr<void> for_each_block(block_callback_t, void*);
|
||||
|
||||
private:
|
||||
Ext2Inode() {}
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace Kernel
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~Inode() {}
|
||||
|
||||
bool ifdir() const { return mode().IFDIR; }
|
||||
bool ifreg() const { return mode().IFREG; }
|
||||
|
||||
@@ -47,7 +49,7 @@ namespace Kernel
|
||||
|
||||
virtual BAN::StringView name() const = 0;
|
||||
|
||||
virtual BAN::ErrorOr<BAN::Vector<uint8_t>> read_all() = 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;
|
||||
};
|
||||
|
||||
@@ -15,19 +15,22 @@ namespace Kernel
|
||||
static VirtualFileSystem& get();
|
||||
virtual ~VirtualFileSystem() {};
|
||||
|
||||
virtual const BAN::RefPtr<Inode> root_inode() const override;
|
||||
virtual const BAN::RefPtr<Inode> root_inode() const override { return m_root_inode; }
|
||||
|
||||
void close_inode(BAN::StringView);
|
||||
|
||||
BAN::ErrorOr<BAN::RefPtr<Inode>> from_absolute_path(BAN::StringView);
|
||||
struct File
|
||||
{
|
||||
BAN::RefPtr<Inode> inode;
|
||||
BAN::String canonical_path;
|
||||
};
|
||||
BAN::ErrorOr<File> file_from_absolute_path(BAN::StringView);
|
||||
|
||||
private:
|
||||
VirtualFileSystem() = default;
|
||||
BAN::ErrorOr<void> initialize_impl();
|
||||
|
||||
private:
|
||||
BAN::HashMap<BAN::String, BAN::RefPtr<Inode>> m_open_inodes;
|
||||
BAN::Vector<StorageController*> m_storage_controllers;
|
||||
BAN::RefPtr<Inode> m_root_inode;
|
||||
BAN::Vector<StorageController*> m_storage_controllers;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user