Wrong timestamp on files written over cifs
We have a ZFS volume shared over CIFS, accessed by clients on windows computers.
When a user unrar a .rar file with winrar, all files will have the current
time as timestamp, not the timestamp from within the archive.
When unzipping the timestamps are correct.
Attached pcap files:
Bge0.rar.pcap is activity when unraring.
Bge0.zip.pcap is activity when unziping.
File from rar archive gets current date as timestamp. File from zip keeps original timestamp.
I used winrar to extract from both rar and zip.
I have contacted winrar about this, and they use the same "logic" for both zip and rar.
The difference is the API-calls for writing files.
Here is the info from winrar support:
If you mean WinRAR, not Unix RAR version, then it uses the standard
CreateFile call to create a file, writes data to file with WriteFile,
sets the file time with SetFileTime, closes the file with
CloseHandle, sets file attributes with SetFileAttributes.
All this API calls are typical.
Now I looked at WinRAR unzip code more carefully. Unlike unrar
code, it opens a file with fopen, writes data, closes the file with
fclose, then re-opens the file with CreateFile, sets the file time
with SetFileTime and closes it with CloseHandle. So unlike unrar
code, it does not write any data to file after CreateFile and before SetFileTime.
But it has its price, time wasted to re-open a file.
On windows servers the timestamps are correct in both cases...