mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 01:55:00 +00:00
Kernel: Update the ".." inode for directories after a rename
Because the ".." entry in a directory is a separate inode, if a directory is renamed to a new location, then we should update this entry the point to the new parent directory as well. Co-authored-by: Liav A <liavalb@gmail.com>
This commit is contained in:
parent
2b246d980a
commit
3b03077abb
18 changed files with 128 additions and 0 deletions
|
@ -60,6 +60,26 @@ ErrorOr<void> TmpFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSyste
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> TmpFSInode::replace_child(StringView name, Inode& new_child)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(is_directory());
|
||||
VERIFY(new_child.fsid() == fsid());
|
||||
|
||||
auto* child = find_child_by_name(name);
|
||||
if (!child)
|
||||
return ENOENT;
|
||||
|
||||
auto old_child = child->inode;
|
||||
child->inode = static_cast<TmpFSInode&>(new_child);
|
||||
|
||||
old_child->did_delete_self();
|
||||
|
||||
// TODO: Emit a did_replace_child event.
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<TmpFSInode::DataBlock>> TmpFSInode::DataBlock::create()
|
||||
{
|
||||
auto data_block_buffer_vmobject = TRY(Memory::AnonymousVMObject::try_create_with_size(DataBlock::block_size, AllocationStrategy::AllocateNow));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue