kernelbase: Workaround for linux-side redirection.

Patch from @bernhardu

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51813

1016195.340:0114:0118:Call KERNEL32.GetFileType(00000014) ret=1022e621
1016195.340:0114:0118:Call ntdll.NtQueryVolumeInformationFile(00000014,0060f598,0060f590,00000008,00000004) ret=7b01f4a5
1016195.340:0114:0118:Ret  ntdll.NtQueryVolumeInformationFile() retval=00000000 ret=7b01f4a5
1016195.340:0114:0118:Ret  KERNEL32.GetFileType() retval=00000001 ret=1022e621
1016195.340:0114:0118:Call KERNEL32.GetFileInformationByHandle(00000014,0060f608) ret=1022e6ac
1016195.340:0114:0118:Call ntdll.NtQueryInformationFile(00000014,0060f508,0060f528,00000068,00000012) ret=7b01eacc
1016195.340:0114:0118:trace:file:NtQueryInformationFile (0x14,0x60f508,0x60f528,0x00000068,0x00000012)
1016195.340:0114:0118:Ret  ntdll.NtQueryInformationFile() retval=c0000024 ret=7b01eacc
1016195.340:0114:0118:Call ntdll.RtlNtStatusToDosError(c0000024) ret=7b01eae3
1016195.340:0114:0118:Ret  ntdll.RtlNtStatusToDosError() retval=00000006 ret=7b01eae3
1016195.340:0114:0118:Ret  KERNEL32.GetFileInformationByHandle() retval=00000000 ret=1022e6ac

Allocation of the fd structure, fd->unix_name is set to NULL:

1697        fd->unix_name  = NULL;
#0  alloc_fd_object () at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/fd.c:1697
#1  0x000056259dd386d8 in create_anonymous_fd (fd_user_ops=fd_user_ops@entry=0x56259dda4900 <file_fd_ops>, unix_fd=unix_fd@entry=28, user=user@entry=0x56259f42db70, options=options@entry=32) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/fd.c:2074
#2  0x000056259dd3b477 in create_file_for_fd (fd=28, access=1074790400, sharing=sharing@entry=3) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/file.c:152
#3  0x000056259dd3b874 in req_alloc_file_handle (req=0x56259f27b768, reply=0x7ffc518872e0) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/file.c:730
#4  0x000056259dd594b3 in call_req_handler (thread=thread@entry=0x56259f27b620) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/request.c:309

Because unix_name is not set no file information get returned:

2780            if (fd->unix_name)
#0  req_get_handle_unix_name (req=<optimized out>, reply=0x7ffc518872e0) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/fd.c:2780
#1  0x000056259dd594b3 in call_req_handler (thread=thread@entry=0x56259f432020) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/server/request.c:309
...
#0  wine_server_call (req_ptr=0x62fac0) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/server.c:286
#1  0xf7b98514 in server_get_unix_name (handle=handle@entry=0x14, unix_name=unix_name@entry=0x62fb94) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/file.c:1776
#2  0xf7ba3b1f in NtQueryInformationFile (handle=0x14, io=0x60f568, ptr=0x60f588, len=104, class=FileAllInformation) at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/file.c:4177
#3  0xf7bbd679 in __wine_syscall_dispatcher () at /home/bernhard/data/entwicklung/2021/wine/wine-git/wine-git/dlls/ntdll/unix/signal_i386.c:153
...

https://github.com/python/cpython/blob/99fcf1505218464c489d419d4500f126b6d6dc28/Python/pylifecycle.c#L2352

https://github.com/python/cpython/blob/99fcf1505218464c489d419d4500f126b6d6dc28/Python/fileutils.c#L1149

Edited by Michel Zou

Merge request reports

Loading