Kernel: Add API for RamDirectoryInodes to delete containing inodes
This commit is contained in:
@@ -84,6 +84,15 @@ namespace Kernel
|
||||
return create_file_impl(name, mode, uid, gid);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Inode::delete_inode(BAN::StringView name)
|
||||
{
|
||||
LockGuard _(m_lock);
|
||||
Thread::TerminateBlocker blocker(Thread::current());
|
||||
if (!mode().ifdir())
|
||||
return BAN::Error::from_errno(ENOTDIR);
|
||||
return delete_inode_impl(name);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<BAN::String> Inode::link_target()
|
||||
{
|
||||
LockGuard _(m_lock);
|
||||
|
||||
@@ -227,6 +227,19 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> RamDirectoryInode::delete_inode_impl(BAN::StringView name)
|
||||
{
|
||||
for (size_t i = 0; i < m_entries.size(); i++)
|
||||
{
|
||||
if (name == m_entries[i].name)
|
||||
{
|
||||
m_entries.remove(i);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
return BAN::Error::from_errno(ENOENT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
RAM SYMLINK INODE
|
||||
|
||||
Reference in New Issue
Block a user