delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/08/16:28:28

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SARE_SUB_ENC_UTF8,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Eric Blake <ebb9 AT byu DOT net>
Subject: utimensat =?utf-8?b?VVRJTUVfTk9X?= granularity bug
Date: Thu, 8 Oct 2009 20:27:42 +0000 (UTC)
Lines: 34
Message-ID: <loom.20091008T221131-292@post.gmane.org>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

The gnulib test for utimensat found a bug in utimensat: it truncates time too 
much, and has the result of making time appear to flow backwards.

This sample code sequence shows the problem (when run at speed; of course 
single stepping this introduces delays and masks the problem):

close (creat ("file", 0600));
stat ("file", &st1);
utimensat (AT_FDCWD, "file", NULL, 0);
stat ("file", &st1);

(gdb) p st1.st_mtim 
$3 = {tv_sec = 1255024956, tv_nsec = 526817600}
(gdb) p st2.st_mtim
$4 = {tv_sec = 1255024956, tv_nsec = 526817000}

Windows expresses time as a fraction, rounded to a quanta with significant 
digits out to a 10th of a microsecond (even though the quanta at which time 
observably advances is much larger than that), but utimensat is currently 
rounding to the nearest microsecond.  The result is that the timestamp set 
during Windows events (such as close) is recorded with more resolution than 
what happens for utimensat, such that consecutive instructions appear to run 
out of order.

I think we need to implement a companion to systime(), which returns the system 
time without any truncation, so that the function clock_gettime(CLOCK_REALTIME) 
can report time with resolution to the 10th of a microsecond rather than to 
plain microseconds.  Then utimensat needs to use clock_gettime rather than 
gettimeofday, so that it is not needlessly truncating the 10th of microsecond 
resolution available from Windows.

-- 
Eric Blake



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019