diff --git a/src/sys/fileinfo.c b/src/sys/fileinfo.c index 11dc3fec..b9309eea 100644 --- a/src/sys/fileinfo.c +++ b/src/sys/fileinfo.c @@ -1189,7 +1189,6 @@ static NTSTATUS FspFsvolSetRenameInformation( * - A directory cannot be renamed if it or any of its subdirectories contains a file * that has open handles (except in the batch-oplock case described earlier). */ - Result = STATUS_SUCCESS; FspFsvolDeviceLockContextTable(FsvolDeviceObject); if (1 < FileNode->HandleCount || @@ -1201,6 +1200,17 @@ static NTSTATUS FspFsvolSetRenameInformation( if (!NT_SUCCESS(Result)) return Result; + /* + * If the new file name is *exactly* the same (including case) as the old one, + * there is no need to go to the user mode file system. Just return STATUS_SUCCESS. + * Our RequestFini will do any cleanup necessary. + * + * This check needs to be done *after* the open handle test above. This is what FASTFAT + * and NTFS do. + */ + if (0 == FspFileNameCompare(&FileNode->FileName, &NewFileName, FALSE, 0)) + return STATUS_SUCCESS; + return FSP_STATUS_IOQ_POST; unlock_exit: diff --git a/tst/winfsp-tests/info-test.c b/tst/winfsp-tests/info-test.c index e04913eb..1ef9d4f4 100644 --- a/tst/winfsp-tests/info-test.c +++ b/tst/winfsp-tests/info-test.c @@ -568,6 +568,9 @@ static void rename_caseins_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeo Success = CreateDirectoryW(Dir1Path, 0); ASSERT(Success); + Success = MoveFileExW(Dir1Path, Dir1Path, 0); + ASSERT(Success); + Success = MoveFileExW(Dir1Path, Dir2Path, 0); ASSERT(Success); @@ -580,6 +583,9 @@ static void rename_caseins_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeo ASSERT(INVALID_HANDLE_VALUE != Handle); CloseHandle(Handle); + Success = MoveFileExW(File1Path, File1Path, 0); + ASSERT(Success); + Success = MoveFileExW(File1Path, File2Path, 0); ASSERT(Success);