From e1ed1d91766781324da903a583fd6f5b8a5e1a50 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 10 Aug 2021 13:39:44 +0200 Subject: [PATCH] VirtualFileSystem: Return early in rename() when old_path==new_path This change fixes disappearing symlink after trying to do the following thing: cp /res/icons/16x16/add-event.png . ln -s add-event.png a mv a a --- Kernel/FileSystem/VirtualFileSystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 6e2d1acaf4..4a0152918e 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -549,6 +549,9 @@ KResult VirtualFileSystem::rename(StringView old_path, StringView new_path, Cust if (new_basename.is_empty() || new_basename == "."sv || new_basename == ".."sv) return EINVAL; + if (old_basename == new_basename && old_parent_inode.index() == new_parent_inode.index()) + return KSuccess; + if (!new_custody_or_error.is_error()) { auto& new_custody = *new_custody_or_error.value(); auto& new_inode = new_custody.inode();