arter97 / exfat-linux

EOL exFAT filesystem module for Linux kernel. Everyone should be using https://github.com/namjaejeon/linux-exfat-oot instead.
Other
262 stars 59 forks source link

3 UtcOffset fields missing from FILE_DENTRY_T and access_time_ms does not actually exist #6

Closed JimTheKiwi closed 4 years ago

JimTheKiwi commented 4 years ago

As described in the exFAT Spec a File Directory Entry includes UtcOffsets for the three timestamps (and 7 bytes reserved). This implementation incorrectly says access_time_ms (and 9 bytes reserved) which does not actually exist, that byte is actually CreateUtcOffset.

The 3 UtcOffset fields currently always being set to 0x00 indicates the timestamps are local time in an unknown timezone, which is awkwardly misinterpreted when filesystems written with exfat linux are remounted on macOS and Windows etc. Conversely, exfat filesystems written by other OSs include timezone information on every timestamp that is being ignored when mounted in Linux so the UTC time is incorrectly offset, differently for each file if they were written from different timezones.

To correctly support timestamps when remounting from Linux to other OSs: Minimal support would be to always set these three bytes to 0x80 to indicate that the timestamps are valid UTC times which should then be interpreted correctly by other exfat drivers.

To correctly support timestamps when remounting from other OSs to Linux: when reading timestamps the non-UTC UtcOffsets should offset timestamps to calculate the UTC timestamp as per the spec.

The complicated effects of this missing support (and an odd quirk of the macOS exfat timezone support) is described in detail here by Adam Harrison: https://blog.1234n6.com/2018/06/exfat-timestamp-behavior-associated_30.html https://blog.1234n6.com/2018/07/exfat-timestamps-exfat-primer-and-my.html

arter97 commented 4 years ago

The master branch is now rebased to a different base, and all existing previous issues need to be re-evaluated.

https://github.com/arter97/exfat-linux/releases/tag/5.8-1arter97

Please re-open this if you believe the new base is still susceptible to this issue.

JimTheKiwi commented 4 years ago

Confirming this appears to be fixed by https://github.com/namjaejeon/old_linux-exfat_work/commit/e4a6824089db1b6ff4014c5ba19157a84bf75b7b which was later indirectly committed to the new base.