mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +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
Notes:
sideshowbarker
2024-07-18 03:20:18 +09:00
Author: https://github.com/sin-ack 🔰
Commit: 3b03077abb
Pull-request: https://github.com/SerenityOS/serenity/pull/16040
18 changed files with 128 additions and 0 deletions
|
@ -652,6 +652,14 @@ ErrorOr<void> VirtualFileSystem::rename(Credentials const& credentials, StringVi
|
|||
|
||||
TRY(new_parent_inode.add_child(old_inode, new_basename, old_inode.mode()));
|
||||
TRY(old_parent_inode.remove_child(old_basename));
|
||||
|
||||
// If the inode that we moved is a directory and we changed parent
|
||||
// directories, then we also have to make .. point to the new parent inode,
|
||||
// because .. is its own inode.
|
||||
if (old_inode.is_directory() && old_parent_inode.index() != new_parent_inode.index()) {
|
||||
TRY(old_inode.replace_child(".."sv, new_parent_inode));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue