Bug 30083 - io-layer only has 1s resolution for file time information.
Summary: io-layer only has 1s resolution for file time information.
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-14 12:37 UTC by Jonathan Pryor
Modified: 2015-05-15 12:38 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Jonathan Pryor 2015-05-14 12:37:58 UTC
io-layer only has 1s resolution for file time information.

This is (somewhat) problematic because e.g. the Microsoft/msbuild unit tests sleep for 100ms between creating files, expecting the file times to differ. Under mono, the file times don't differ, because io-layer uses the 1s-resolution `struct stat` members, not the 1ns members:

https://github.com/mono/mono/blob/mono-3.12.0-branch/mono/io-layer/io.c#L907
	write_ticks=((guint64)statbuf.st_mtime*10000000)+116444736000000000ULL;

In order to get 1ns resolution, the `struct stat::st_mtimespec` and other `struct stat::st_*timespec` fields should be used instead of the `struct stat::st_*time` members.

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat.2.html
http://pubs.opengroup.org/onlinepubs/9699919799//basedefs/sys_stat.h.html
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html
Comment 1 Zoltan Varga 2015-05-15 10:46:27 UTC
The st_mtimespec.tv_nsec field seems to be 0 under osx, so it still cannot give sub second accuracy.
Comment 2 Jonathan Pryor 2015-05-15 12:38:32 UTC
Indeed, wikipedia mentions that HFS+ only supports 1s date resolution:

http://en.wikipedia.org/wiki/HFS%5FPlus

At least this should work on Linux...

Note You need to log in before you can comment on or make changes to this bug.