[PATCH v2 4/6] ntdll: Allow renaming a file to the same name.
Alexandre Julliard
julliard at winehq.org
Mon Mar 9 05:01:32 CDT 2020
Zebediah Figura <z.figura12 at gmail.com> writes:
> @@ -2780,8 +2780,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 );
I feel it would be cleaner to do that on the server side.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list