utimecmp: fine-grained src to nearby coarse-grained dest
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 2 Dec 2010 05:25:56 +0000 (21:25 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 2 Dec 2010 05:26:17 +0000 (21:26 -0800)
* lib/utimecmp.c (utimecmp): When UTIMECMP_TRUNCATE_SOURCE is set,
and the source is on a file system with higher-resolution time
stamps, than the destination, and _PC_TIMESTAMP_RESOLUTION does
not work, and the time stamps are close together, the algorithm to
determine the exact resolution from the read-back mtime was buggy:
it had a "!=" where it should have had an "==".  This bug has been
in the code ever since it was introduced to gnulib.
Problem reported by Dan Jacobson in
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7529>.

ChangeLog
lib/utimecmp.c

index d4eb684fc2e347ff6adfd6c629035fdbb71f92cf..67e297736844de701a180bb7f213d4b5a6764c9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Paul Eggert  <eggert@cs.ucla.edu>
+
+       utimecmp: fine-grained src to nearby coarse-grained dest
+
+       * lib/utimecmp.c (utimecmp): When UTIMECMP_TRUNCATE_SOURCE is set,
+       and the source is on a file system with higher-resolution time
+       stamps, than the destination, and _PC_TIMESTAMP_RESOLUTION does
+       not work, and the time stamps are close together, the algorithm to
+       determine the exact resolution from the read-back mtime was buggy:
+       it had a "!=" where it should have had an "==".  This bug has been
+       in the code ever since it was introduced to gnulib.
+       Problem reported by Dan Jacobson in
+       <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7529>.
+
 2010-11-30  Bruno Haible  <bruno@clisp.org>
 
        strerror_r-posix: Fix autoconf test.
index 63a0c9a822000e0b36e92c7ab9c270f94a760b79..8c3ca65d957061cae516f2a4dce855665a886bb9 100644 (file)
@@ -325,7 +325,7 @@ utimecmp (char const *dst_name,
 
                 res = SYSCALL_RESOLUTION;
 
-                for (a /= res; a % 10 != 0; a /= 10)
+                for (a /= res; a % 10 == 0; a /= 10)
                   {
                     if (res == BILLION)
                       {