Kernel: Start work on writable ext2 filesystem
This commit is contained in:
parent
a7bfc1c2ec
commit
d810644018
|
@ -123,7 +123,7 @@ namespace Kernel
|
||||||
class Ext2Inode final : public Inode
|
class Ext2Inode final : public Inode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ino_t ino() const override { return m_index; };
|
virtual ino_t ino() const override { return m_ino; };
|
||||||
virtual Mode mode() const override { return { m_inode.mode }; }
|
virtual Mode mode() const override { return { m_inode.mode }; }
|
||||||
virtual nlink_t nlink() const override { return m_inode.links_count; }
|
virtual nlink_t nlink() const override { return m_inode.links_count; }
|
||||||
virtual uid_t uid() const override { return m_inode.uid; }
|
virtual uid_t uid() const override { return m_inode.uid; }
|
||||||
|
@ -144,28 +144,31 @@ namespace Kernel
|
||||||
|
|
||||||
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) override;
|
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) override;
|
||||||
virtual BAN::ErrorOr<size_t> write(size_t, const void*, size_t) override;
|
virtual BAN::ErrorOr<size_t> write(size_t, const void*, size_t) override;
|
||||||
|
virtual BAN::ErrorOr<void> truncate(size_t) override;
|
||||||
|
|
||||||
virtual BAN::ErrorOr<void> create_file(BAN::StringView, mode_t, uid_t, gid_t) override;
|
virtual BAN::ErrorOr<void> create_file(BAN::StringView, mode_t, uid_t, gid_t) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BAN::ErrorOr<uint32_t> data_block_index(uint32_t);
|
BAN::ErrorOr<void> for_data_block_index(uint32_t, const BAN::Function<void(uint32_t&)>&, bool allocate);
|
||||||
|
|
||||||
uint32_t index() const { return m_index; }
|
BAN::ErrorOr<uint32_t> data_block_index(uint32_t);
|
||||||
|
BAN::ErrorOr<uint32_t> allocate_new_block();
|
||||||
|
BAN::ErrorOr<void> sync();
|
||||||
|
|
||||||
|
uint32_t block_group() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ext2Inode(Ext2FS& fs, Ext2::Inode inode, uint32_t index, BAN::StringView name)
|
Ext2Inode(Ext2FS& fs, Ext2::Inode inode, uint32_t ino)
|
||||||
: m_fs(fs)
|
: m_fs(fs)
|
||||||
, m_inode(inode)
|
, m_inode(inode)
|
||||||
, m_name(name)
|
, m_ino(ino)
|
||||||
, m_index(index)
|
|
||||||
{}
|
{}
|
||||||
static BAN::ErrorOr<BAN::RefPtr<Inode>> create(Ext2FS&, uint32_t, BAN::StringView);
|
static BAN::ErrorOr<BAN::RefPtr<Inode>> create(Ext2FS&, uint32_t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ext2FS& m_fs;
|
Ext2FS& m_fs;
|
||||||
Ext2::Inode m_inode;
|
Ext2::Inode m_inode;
|
||||||
BAN::String m_name;
|
const uint32_t m_ino;
|
||||||
uint32_t m_index;
|
|
||||||
|
|
||||||
friend class Ext2FS;
|
friend class Ext2FS;
|
||||||
friend class BAN::RefPtr<Ext2Inode>;
|
friend class BAN::RefPtr<Ext2Inode>;
|
||||||
|
@ -192,6 +195,9 @@ namespace Kernel
|
||||||
|
|
||||||
void read_block(uint32_t, BAN::Span<uint8_t>);
|
void read_block(uint32_t, BAN::Span<uint8_t>);
|
||||||
void write_block(uint32_t, BAN::Span<const uint8_t>);
|
void write_block(uint32_t, BAN::Span<const uint8_t>);
|
||||||
|
void sync_superblock();
|
||||||
|
|
||||||
|
BAN::ErrorOr<uint32_t> reserve_free_block(uint32_t primary_bgd);
|
||||||
|
|
||||||
const Ext2::Superblock& superblock() const { return m_superblock; }
|
const Ext2::Superblock& superblock() const { return m_superblock; }
|
||||||
|
|
||||||
|
@ -209,6 +215,7 @@ namespace Kernel
|
||||||
Partition& m_partition;
|
Partition& m_partition;
|
||||||
|
|
||||||
BAN::RefPtr<Inode> m_root_inode;
|
BAN::RefPtr<Inode> m_root_inode;
|
||||||
|
BAN::Vector<uint32_t> m_superblock_backups;
|
||||||
|
|
||||||
Ext2::Superblock m_superblock;
|
Ext2::Superblock m_superblock;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue