mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
Kernel: Fix rename() sometimes failing to move within the same directory.
It was wrong to do a reverse name lookup on the old inode after adding a new name for it, since we might very well get the new inode instead of the old one, depending on hash table layouts.
This commit is contained in:
parent
95ddca8a52
commit
d32d85e133
Notes:
sideshowbarker
2024-07-19 14:34:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d32d85e1332
1 changed files with 3 additions and 4 deletions
|
@ -333,7 +333,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Inode& base)
|
|||
return KSuccess;
|
||||
if (new_inode->is_directory() && !old_inode->is_directory())
|
||||
return KResult(-EISDIR);
|
||||
auto result = new_parent_inode->remove_child(new_parent_inode->reverse_lookup(new_inode->identifier()));
|
||||
auto result = new_parent_inode->remove_child(FileSystemPath(new_path).basename());
|
||||
if (result.is_error())
|
||||
return result;
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Inode& base)
|
|||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
result = old_parent_inode->remove_child(old_parent_inode->reverse_lookup(old_inode->identifier()));
|
||||
result = old_parent_inode->remove_child(FileSystemPath(old_path).basename());
|
||||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
|
@ -495,8 +495,7 @@ KResult VFS::rmdir(StringView path, Inode& base)
|
|||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
// FIXME: The reverse_lookup here can definitely be avoided.
|
||||
return parent_inode->remove_child(parent_inode->reverse_lookup(inode->identifier()));
|
||||
return parent_inode->remove_child(FileSystemPath(path).basename());
|
||||
}
|
||||
|
||||
KResultOr<InodeIdentifier> VFS::resolve_symbolic_link(InodeIdentifier base, Inode& symlink_inode)
|
||||
|
|
Loading…
Reference in a new issue