Bug 30083 - io-layer only has 1s resolution for file time information.
Summary: io-layer only has 1s resolution for file time information.
Status: RESOLVED FIXED
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: 2018-04-05 20:03 UTC (History)
4 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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...
Comment 3 Ludovic Henry 2018-04-05 20:03:12 UTC
3 years later, your wish has been granted! https://github.com/mono/mono/commit/a5c6f5c5ca246f688942a128b41010fd66301dc1