TC cannot copy files to network shares under Wine

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
atakama
Junior Member
Junior Member
Posts: 6
Joined: 2015-01-01, 15:01 UTC

TC cannot copy files to network shares under Wine

Post by *atakama »

I'm running TC on Linux under Wine. When attempting to copy a local file to a network share, TC modifies the path that is entered in the dialog box and prepends a "UNC\" prefix. This causes the copy operation to fail.
The only way to copy files to a network share is via the Synchronize Directories function, because in that case the path is not modified by TC.

Steps to reproduce:
- select any file
- press F5
- enter a path like: \\Server\Share
- press Enter
- the copy dialog shows the destination path as: UNC\Server\Share
- copy fails using any copy method (standard copy method in this case)

This is the case since at least TC version 6.0

Here is a Wine debug log showing the sequence of system calls:

Code: Select all

0028:Call KERNEL32.CopyFileExW(0187c8e4 L"D:\\localfile",0187c0e4 L"UNC\\Server\\Share\\localfile",00697600,018753a0,018753ec,00000009) ret=006978ad
0028:Ret  KERNEL32.CopyFileExW() retval=00000000 ret=006978ad
0028:Call KERNEL32.GetLastError() ret=0069890f
0028:Ret  KERNEL32.GetLastError() retval=00000003 ret=0069890f
As you can see, CopyFileExW returns 0 and GetLastError returns 3.

Now watch what happens while copying the same file using the Synchronize Directories function:

Code: Select all

0031:Call KERNEL32.CopyFileExW(0033660c L"D:\\localfile",00335e0c L"\\\\Server\\Share\\localfile",00697600,0033217c,003321c8,00000009) ret=006978ad
0031:Ret  KERNEL32.CopyFileExW() retval=00000001 ret=006978ad
CopyFileExW returns 1 and the operation succeeds, because the path is \\Server\Share not UNC\Server\Share

The same issue occurs when copying whole directories. TC is unable to create the destination directories during normal copy, probably because of the same reason. Using Synchronize Directories works as expected.

Can this issue be fixed so that TC is fully usable under Wine?
Thank you!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48093
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Cannot confirm. Is the target longer than 259 characters? TC will then put "\\?\UNC\" in front of the name. But it doesn't put just "UNC" in front, this wouldn't work even with Windows shares...
Author of Total Commander
https://www.ghisler.com
atakama
Junior Member
Junior Member
Posts: 6
Joined: 2015-01-01, 15:01 UTC

Post by *atakama »

No, the target path is short, just \\server\share
It seems that before copying, TC calls SetCurrentDirectory to the destination path and then calls GetCurrentDirectory. Apparently it uses the result as the destination path and that's why the copy operation fails.
It doesn't do this when copying the file via Synchronize Directories.

In this example, I was trying to copy D:\localfile to \\server\share\

Code: Select all

0027:Call KERNEL32.SetCurrentDirectoryW(00334c08 L"\\\\server\\share\\localfile") ret=0041eeaf
0030:Ret  user32.MsgWaitForMultipleObjects() retval=00000102 ret=005679a2
0030:Call KERNEL32.Sleep(0000000a) ret=00567c16
0030:Ret  KERNEL32.Sleep() retval=00d4e910 ret=00567c16
0030:Call user32.MsgWaitForMultipleObjects(00000002,00d4e978,00000000,00000032,000000ff) ret=005679a2
0027:Ret  KERNEL32.SetCurrentDirectoryW() retval=00000000 ret=0041eeaf
0027:Call KERNEL32.GetLastError() ret=0041f150
0027:Ret  KERNEL32.GetLastError() retval=00000002 ret=0041f150
0027:Call KERNEL32.SetCurrentDirectoryW(003343fc L"\\\\server\\share") ret=0041eeaf
0030:Ret  user32.MsgWaitForMultipleObjects() retval=00000102 ret=005679a2
0030:Call KERNEL32.Sleep(0000000a) ret=00567c16
0030:Ret  KERNEL32.Sleep() retval=00d4e910 ret=00567c16
0027:Ret  KERNEL32.SetCurrentDirectoryW() retval=00000001 ret=0041eeaf
0027:Call KERNEL32.GetCurrentDirectoryW(000003ff,003379b8) ret=0041ede7
0027:Ret  KERNEL32.GetCurrentDirectoryW() retval=00000010 ret=0041ede7
0027:Call KERNEL32.GetVolumeInformationW(00334bf0 L"UNC\\server\\share\\",00000000,00000000,00000000,003353f4,003353f0,003343f0,000007ff) ret=0042368b
0027:Ret  KERNEL32.GetVolumeInformationW() retval=00000000 ret=0042368b
atakama
Junior Member
Junior Member
Posts: 6
Joined: 2015-01-01, 15:01 UTC

Post by *atakama »

I had a look at the wine source code and the UNC\ prefix is added in SetCurrentDirectory, so any subsequent calls to GetCurrentDirectory will return a modified path.
Is thre any chance for TC to ignore the GetCurrentDirectory result during copy and just use the path supplied by the user, or should I file a bug with the wine team?
User avatar
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hello, atakama.

I cannot comment on potential side effects if T.C. ignored GetCurrentDirectory when run on Wine.
But as you found out that it is Wine which misbehaves, it seems to be the right approach to let the Wine makers know.
By the way, which Wine version are we talking about?

Cheers,
Karl
atakama
Junior Member
Junior Member
Posts: 6
Joined: 2015-01-01, 15:01 UTC

Post by *atakama »

It's wine 1.6.2-0ubuntu6 on Ubuntu 14.10. This is the latest stable version, released a year ago, so the package might be updated faster if I submit a bug report to Ubuntu directly.
EDIT: same result with latest wine 1.7.33.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48093
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You mean GetCurrentDirectory returns UNC\ prefix? Ugly. This doesn't happen with my older Wine version here, but I will try to install a newer one and try to reproduce it.
Author of Total Commander
https://www.ghisler.com
atakama
Junior Member
Junior Member
Posts: 6
Joined: 2015-01-01, 15:01 UTC

Post by *atakama »

Yes, GetCurrentDirectory returns a path with the UNC\ prefix, because SetCurrentDirectory stores the path with that prefix. The code that does this was committed in 2003-2004, how old is your Wine version?
Also, would it be possible for TC to behave the same when copying as it does when synchronizing directories? It doesn't call GetCurrentDirectory when synchronizing and I'm currently using this to copy files to network shares, which is pretty cumbersome.

The Wine behavior is visible even with the included cmd.exe:

Code: Select all

user@host:~$ wine cmd
Wine CMD Version 5.1.2600 (1.6.2)

H:\>cd \\server\share\directory

UNC\server\share\directory>dir
Syntax error

UNC\server\share\directory>echo test > \\server\share\directory\file

UNC\server\share\directory>type \\server\share\directory\file
test 

UNC\server\share\directory>echo test > UNC\server\share\directory\file
Path not found.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

But why such a strange incompatible change was made to Wine?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48093
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Could anyone test this with TC 8.52 beta, please? I'm removing the UNC\ prefix now if it is returned by GetCurrentDirectory.
Author of Total Commander
https://www.ghisler.com
atakama
Junior Member
Junior Member
Posts: 6
Joined: 2015-01-01, 15:01 UTC

Post by *atakama »

Yes, I can confirm this is fixed in 8.52 beta 1.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48093
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Great, thanks very much!
Author of Total Commander
https://www.ghisler.com
Post Reply