Kernel: Implement directory creation for RamFS
This commit is contained in:
parent
e85f9ac6a1
commit
1f794e4ac0
|
@ -96,6 +96,7 @@ namespace Kernel
|
||||||
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> find_inode_impl(BAN::StringView) override;
|
virtual BAN::ErrorOr<BAN::RefPtr<Inode>> find_inode_impl(BAN::StringView) override;
|
||||||
virtual BAN::ErrorOr<void> list_next_inodes_impl(off_t, DirectoryEntryList*, size_t) override;
|
virtual BAN::ErrorOr<void> list_next_inodes_impl(off_t, DirectoryEntryList*, size_t) override;
|
||||||
virtual BAN::ErrorOr<void> create_file_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
|
virtual BAN::ErrorOr<void> create_file_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
|
||||||
|
virtual BAN::ErrorOr<void> create_directory_impl(BAN::StringView, mode_t, uid_t, gid_t) override;
|
||||||
virtual BAN::ErrorOr<void> delete_inode_impl(BAN::StringView) override;
|
virtual BAN::ErrorOr<void> delete_inode_impl(BAN::StringView) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -202,16 +202,23 @@ namespace Kernel
|
||||||
BAN::RefPtr<RamInode> inode;
|
BAN::RefPtr<RamInode> inode;
|
||||||
if (Mode(mode).ifreg())
|
if (Mode(mode).ifreg())
|
||||||
inode = TRY(RamFileInode::create(m_fs, mode & ~Inode::Mode::TYPE_MASK, uid, gid));
|
inode = TRY(RamFileInode::create(m_fs, mode & ~Inode::Mode::TYPE_MASK, uid, gid));
|
||||||
else if (Mode(mode).ifdir())
|
|
||||||
inode = TRY(RamDirectoryInode::create(m_fs, ino(), mode & ~Inode::Mode::TYPE_MASK, uid, gid));
|
|
||||||
else
|
else
|
||||||
ASSERT_NOT_REACHED();
|
return BAN::Error::from_errno(ENOTSUP);
|
||||||
|
|
||||||
TRY(add_inode(name, inode));
|
TRY(add_inode(name, inode));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BAN::ErrorOr<void> RamDirectoryInode::create_directory_impl(BAN::StringView name, mode_t mode, uid_t uid, gid_t gid)
|
||||||
|
{
|
||||||
|
if (!Mode(mode).ifdir())
|
||||||
|
return BAN::Error::from_errno(EINVAL);
|
||||||
|
auto inode = TRY(RamDirectoryInode::create(m_fs, ino(), mode & ~Inode::Mode::TYPE_MASK, uid, gid));
|
||||||
|
TRY(add_inode(name, inode));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t get_type(Inode::Mode mode)
|
static uint8_t get_type(Inode::Mode mode)
|
||||||
{
|
{
|
||||||
if (mode.ifreg())
|
if (mode.ifreg())
|
||||||
|
|
Loading…
Reference in New Issue