dokan-dev / dokan-dotnet

Dokan DotNet Wrapper
http://dokan-dev.github.io
MIT License
462 stars 116 forks source link

Unsafe mirror yields wrong file content using .net6 #299

Closed TrabacchinLuigi closed 2 years ago

TrabacchinLuigi commented 2 years ago

During investigation of the wrong file size output #294 I've noticed that the unsafe version of the mirror is not seeking to the correct destination, leading to wrong output. The same code can be used to reproduce the problem but mounting mirror with the unsafe switch.

The expected output should be a list of incrementing repeated bytes inter-spaced by zero bytes, using usafe we get all the bytes wrote on the start of the the file

TrabacchinLuigi commented 2 years ago

seems that the unsafe seek isn't working, but using the FileStream.Seek resolve the problem

TrabacchinLuigi commented 2 years ago

i'll write some tests, because i think that the unsafe seek isn't working just because the handle is owned by the filestream, then i'll do a pr

TrabacchinLuigi commented 2 years ago

https://github.com/dotnet/docs/blob/12473973716efbf21470ecbc96de0bd5e1f65e3b/docs/core/compatibility/core-libraries/6.0/filestream-doesnt-sync-offset-with-os.md

seems this is due to the fact i was testing with .net6, still there is no reason to seek using the native code in mirror