Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror : File corruption when copying from mounted drive #1244

Closed
4 of 5 tasks
michelgre opened this issue Aug 23, 2024 · 4 comments
Closed
4 of 5 tasks

Mirror : File corruption when copying from mounted drive #1244

michelgre opened this issue Aug 23, 2024 · 4 comments

Comments

@michelgre
Copy link

Hello

I noticed a problem when using mirror.exe to mount and copy files.

Environment

  • Windows version: 11
  • Processor architecture: AMD
  • Dokany version: 2.2.0.1000 (and previous)
  • Library type (Dokany/FUSE): Dokany

Check List

  • I checked my issue doesn't exist yet
  • My issue is valid with mirror default sample and not specific to my user-mode driver implementation
  • I can always reproduce the issue with the provided description below.
  • I have updated Dokany to the latest version and have reboot my computer after.
  • I tested one of the last snapshot from appveyor CI

Description

I use mirror.exe to mount a SMB share to a drive of my PC.
For some files, but not all, the data is corrupted when I copy the file from the mounted drive. The file length is OK and there is no error popup, but the content is partially messed up and replaced with nulls. The actual content varies from one copy to another for the same file. I noticed that for PDF files and for images files, because the viewer complains that the file is corrupt.

If I open the file directly from the mounted drive, there is no error, the content is correct. The corruption occurs only if I copy the file using Windows explorer or CMD copy.

If I copy the file using the UNC path of the shared folder, there is no error.

If I copy the file with Cygwin cp from the mounted drive, there is no error.

I noticed this problem while I was using an older version of Dokan so I upgraded to the latest version but it did not solve it.

Command to mount the disk : "c:\Program Files\Dokan\mirror.exe" /r \QNAP2\Public\Dokan /l Q:\ /s
(as administrator).

Attached:

  • mirror log
  • dbgview log
  • original file
  • copied file (corrupt)

Logs

mirror.log
DbgView.log
30141_50_2.pdf
Copied.pdf

Thank you.

@Liryna
Copy link
Member

Liryna commented Aug 24, 2024

Hi @michelgre,

Explorer and copy are working the same for all files but since the issue only happens for some type of files, I would tend to believe it is due to a third party software.

  • I wonder if "c:\Program Files\Dokan\mirror.exe" /r \QNAP2\Public\Dokan /l Q:\ /o could help here (mount manager option) ?
  • Could you share the output of fltmc filters ?

@michelgre
Copy link
Author

michelgre commented Aug 25, 2024

Hello

Thank you Liryna.

I tried but it didn't help.

About the file types, I am not sure that it is the reason. I renamed the example pdf file to .txt to make sure that nothing specific happens and I got the same issue. The copied file is corrupt. It's less about file types than about the content, which is strange.

If I open the (actually pdf) txt file directly in a text editor, from the mounted drive, I get the
%PDF-1.3
header at the top.

image

If I copy this file locally and then open it, the file is messed, the beginning is actually the middle data, and somewhere in the middle there are nulls to fill the file to its original size. Very strange.

image

This part can be found inside the original file :
image

If I delete the copy and copy again, I have a different content:
image

I suspected my NAS (QNAP / QTS 5.1) at first but if I copy the same file using the UNC path, there is no problem so the SMB share works.

I also disabled the antivirus program during the test.

It's more like some data inside the file would trigged the incorrect behavior of mirror, like retrieving the wrong data block, and only during a windows copy.

Here is the result of the command:

C:\Windows\System32>fltmc filters

Nom de filtre                   Nom. d’instn.  Altitude      Cadre
------------------------------  -------------  ------------  -----
bindflt                                 1       409800         0
aswSP                                  16       388401         0
aswMonFlt                              16       320700         0
storqosflt                              0       244000         0
wcifs                                   0       189900         0
CldFlt                                  2       180451         0
bfs                                    18       150000         0
FileCrypt                               0       141100         0
aswSnx                                 15       137600         0
luafv                                   1       135000         0
npsvctrig                               1        46000         0
Wof                                     8        40700         0
FileInfo                               16        40500         0

C:\Windows\System32>

@Liryna
Copy link
Member

Liryna commented Aug 26, 2024

I also disabled the antivirus program during the test.

That often not enough to fully disable them. Do you have the possibility to do the test on a clean environment ?

Read and write are well tested and the description of the issue really makes me believe there is a third party corrupting the data.
You might be lucky to find which one by using procmon and inspect the read callstack. It could show one of those present in your fltmc filters output

@Liryna
Copy link
Member

Liryna commented Sep 13, 2024

Please do not hesitate to reopen if you have new information

@Liryna Liryna closed this as completed Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants