From: Dmitry Timoshkov dmitry@baikal.ru
Looks like this behaviour depends on FILE_FLAG_POSIX_SEMANTICS and activated when a file is being created.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58636 Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/kernel32/tests/file.c | 1 - dlls/kernelbase/file.c | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 5fb15c8b01f..47b8307aeda 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -6849,7 +6849,6 @@ static void test_posix_semantics(void) ret = GetFileInformationByHandle(hFile, &info); ok(ret, "GetFileInformationByHandle error %lu\n", GetLastError()); if (td[i].disposition == CREATE_NEW && flags[j] == (FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_POSIX_SEMANTICS | FILE_ATTRIBUTE_DIRECTORY)) - todo_wine ok(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY, "created file is not a directory\n"); else ok(!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY), "created file is a directory\n"); diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index b34a3bb25b8..b3ebbe2321c 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -758,12 +758,16 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileA( LPCSTR name, DWORD access, DWORD sh return CreateFileW( nameW, access, sharing, sa, creation, attributes, template ); }
-static UINT get_nt_file_options( DWORD attributes ) +static UINT get_nt_file_options( DWORD attributes, BOOL create ) { UINT options = 0;
if (attributes & FILE_FLAG_BACKUP_SEMANTICS) + { options |= FILE_OPEN_FOR_BACKUP_INTENT; + if ((attributes & FILE_FLAG_POSIX_SEMANTICS) && create) + options |= (attributes & FILE_ATTRIBUTE_DIRECTORY) ? FILE_DIRECTORY_FILE : 0; + } else options |= FILE_NON_DIRECTORY_FILE; if (attributes & FILE_FLAG_DELETE_ON_CLOSE) @@ -864,7 +868,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileW( LPCWSTR filename, DWORD access, DWO status = NtCreateFile( &ret, access | SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attr, &io, NULL, attributes & FILE_ATTRIBUTE_VALID_FLAGS, sharing, nt_disposition[creation - CREATE_NEW], - get_nt_file_options( attributes ), NULL, 0 ); + get_nt_file_options( attributes, creation == CREATE_NEW ), NULL, 0 ); if (status) { if (vxd_name && vxd_name[0]) @@ -3423,7 +3427,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH ReOpenFile( HANDLE handle, DWORD access, DWORD s }
status = NtCreateFile( &file, access | SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attr, &io, NULL, - 0, sharing, FILE_OPEN, FILE_NON_DIRECTORY_FILE | get_nt_file_options( attributes ), NULL, 0 ); + 0, sharing, FILE_OPEN, FILE_NON_DIRECTORY_FILE | get_nt_file_options( attributes, FALSE ), NULL, 0 ); if (!set_ntstatus( status )) return INVALID_HANDLE_VALUE; return file;