dokan-dev / dokany

User mode file system library for windows with FUSE Wrapper
http://dokan-dev.github.io
5.2k stars 661 forks source link

[Mirror] Use prefix \\?\UNC\ for long file paths over network (or for all /r paths over network) #1130

Open snullp opened 1 year ago

snullp commented 1 year ago

In latest Windows 10 there is a peculiar behavior over network path relating to long file path. This is not associated with the long file path flag in mirror.c (thanks for enabling it by default), and I already enabled long file path support in Win10 registry (long path in local drive works).

For the network share paths with a long path name, instead of using \\server_name\long\path\to\file, Win 10 uses \\?\UNC\server_name\long\path\to\file. Windows Explorer does this conversion automatically: When navigating into a long path folder, the location bar converts to the \\?\UNC\ format.

mirror.exe does not to this automatically and when invoked in this form:

mirror.exe /l \\server_name\share /l D

Files with short file path can be retrieved successfully, but upon long file path files the mounted fs throws File Not Found error (I did not take screenshot or copy the log when this occurs, and now I'm running the fixed cmd below so unable to reproduce).

Manually changing cmd to the following fixes the problem:

mirror.exe /l \\?\UNC\server_name\share /l D

It would be better if mirror.exe uses the prefix automatically to avoid future user spend hours debugging like I did.

Liryna commented 1 year ago

Hi @snullp ,

That seems to be a good and quick idea to implement. Thanks for the suggestion! Would need to populate the \\?\UNC prefix in gRootDirectory when the arg starts with \ (UNC). https://github.com/dokan-dev/dokany/blob/master/samples/dokan_mirror/mirror.c#L1596-L1603

snullp commented 1 year ago

Thank you @Liryna . I also found out that rclone does the same: https://rclone.org/local/#long-paths