Commit 91e442b0 authored by Joel Holdsworth's avatar Joel Holdsworth Committed by Alexandre Julliard

ntdll: Implement FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE.

Both the Msys2 and Cygwin runtimes make use of FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE in their implementations of the unlink() system call. This enables these routines to delete a read-only file without first modifying the attributes. https://github.com/msys2/msys2-runtime/blob/msys2-3.4.3/winsup/cygwin/syscalls.cc#L724 https://www.cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/syscalls.cc#l726 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50771Signed-off-by: 's avatarJoel Holdsworth <joel@airwebreathe.org.uk>
parent cbc1e442
......@@ -3098,14 +3098,12 @@ static void test_file_disposition_information(void)
ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
fdie.Flags = FILE_DISPOSITION_DELETE | FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE;
res = pNtSetInformationFile( handle, &io, &fdie, sizeof fdie, FileDispositionInformationEx );
todo_wine
ok( res == STATUS_SUCCESS || broken(res == STATUS_INVALID_INFO_CLASS),
"unexpected FileDispositionInformationEx result (expected STATUS_SUCCESS or SSTATUS_INVALID_INFO_CLASS, got %lx)\n", res );
CloseHandle( handle );
if ( res == STATUS_SUCCESS )
{
fileDeleted = GetFileAttributesA( buffer ) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND;
todo_wine
ok( fileDeleted, "File should have been deleted\n" );
}
SetFileAttributesA( buffer, FILE_ATTRIBUTE_NORMAL );
......
......@@ -4774,8 +4774,6 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io,
FIXME( "FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK not supported\n" );
if (info->Flags & FILE_DISPOSITION_ON_CLOSE)
FIXME( "FILE_DISPOSITION_ON_CLOSE not supported\n" );
if (info->Flags & FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE)
FIXME( "FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE not supported\n" );
SERVER_START_REQ( set_fd_disp_info )
{
......
......@@ -2499,7 +2499,8 @@ static void set_fd_disposition( struct fd *fd, unsigned int flags )
}
if (S_ISREG( st.st_mode )) /* can't unlink files we don't have permission to write */
{
if (!(st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
if (!(flags & FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE) &&
!(st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
{
set_error( STATUS_CANNOT_DELETE );
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment