[PATCH 4/6] ntdll: Allow renaming a file to the same name.
Zebediah Figura
z.figura12 at gmail.com
Thu Mar 5 19:03:23 CST 2020
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/ntdll/file.c | 23 ++++++++++++++++++++++-
dlls/ntdll/tests/file.c | 4 ++--
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index dc9a67fcffa..7dfb0a4800e 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -2807,8 +2807,29 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
if (!info->ReplaceIfExists && io->u.Status == STATUS_SUCCESS)
{
+ struct stat st, st2;
+ int fd;
+
+ if ((io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
+ {
+ RtlFreeAnsiString( &unix_name );
+ break;
+ }
+
+ if (fstat( fd, &st ) < 0 || stat( unix_name.Buffer, &st2 ) < 0)
+ {
+ RtlFreeAnsiString( &unix_name );
+ io->u.Status = FILE_GetNtStatus();
+ break;
+ }
+
+ if (st.st_dev == st2.st_dev && st.st_ino == st2.st_ino)
+ io->u.Status = STATUS_SUCCESS;
+ else
+ io->u.Status = STATUS_OBJECT_NAME_COLLISION;
+
RtlFreeAnsiString( &unix_name );
- io->u.Status = STATUS_OBJECT_NAME_COLLISION;
+ if (needs_close) close( fd );
break;
}
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index e0d4580ae04..bb4bf9df8ad 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -2123,8 +2123,8 @@ static void test_file_rename_information(void)
U(io).Status = 0xdeadbeef;
res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
- todo_wine ok( U(io).Status == STATUS_SUCCESS, "got io status %#x\n", U(io).Status );
- todo_wine ok( res == STATUS_SUCCESS, "got status %x\n", res );
+ ok( U(io).Status == STATUS_SUCCESS, "got io status %#x\n", U(io).Status );
+ ok( res == STATUS_SUCCESS, "got status %x\n", res );
ok( GetFileAttributesW( oldpath ) != INVALID_FILE_ATTRIBUTES, "file should exist\n" );
CloseHandle( handle );
--
2.25.1
More information about the wine-devel
mailing list