From: Qian Hong qhong@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This patch had a corresponding entry in the old wine-staging bug tracker (bug 228), but unfortunately I could not find the contents of the bug. However, since it fixes existing functionality rather than introducing new functionality, I think it's worth submitting.
dlls/ntdll/tests/file.c | 8 ++++---- server/fd.c | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 5d234114fd5..19ae5f2ac21 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -3329,14 +3329,14 @@ todo_wine
fdi.DoDeleteFile = TRUE; res = pNtSetInformationFile( handle, &io, &fdi, sizeof(fdi), FileDispositionInformation ); - todo_wine ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res ); + ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res ); res = GetFileAttributesA( buffer ); ok( res != INVALID_FILE_ATTRIBUTES, "expected file to exist\n" );
CloseHandle( mapping ); CloseHandle( handle ); res = DeleteFileA( buffer ); - todo_wine ok( res, "got error %u\n", GetLastError() ); + ok( res, "got error %u\n", GetLastError() );
GetTempFileNameA( tmp_path, "dis", 0, buffer ); handle = CreateFileA( buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 ); @@ -3373,14 +3373,14 @@ todo_wine
fdi.DoDeleteFile = TRUE; res = pNtSetInformationFile( handle, &io, &fdi, sizeof(fdi), FileDispositionInformation ); - todo_wine ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res ); + ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res ); res = GetFileAttributesA( buffer ); ok( res != INVALID_FILE_ATTRIBUTES, "expected file to exist\n" );
UnmapViewOfFile( view ); CloseHandle( handle ); res = DeleteFileA( buffer ); - todo_wine ok( res, "got error %u\n", GetLastError() ); + ok( res, "got error %u\n", GetLastError() );
GetTempFileNameA( tmp_path, "dis", 0, buffer ); handle = CreateFileA( buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 ); diff --git a/server/fd.c b/server/fd.c index bfa2805d82b..e326354d127 100644 --- a/server/fd.c +++ b/server/fd.c @@ -2452,6 +2452,17 @@ static void set_fd_disposition( struct fd *fd, int unlink )
if (unlink) { + struct fd *fd_ptr; + + LIST_FOR_EACH_ENTRY( fd_ptr, &fd->inode->open, struct fd, inode_entry ) + { + if (fd_ptr->access & FILE_MAPPING_ACCESS) + { + set_error( STATUS_CANNOT_DELETE ); + return; + } + } + if (fstat( fd->unix_fd, &st ) == -1) { file_set_error();