GNU bug report logs - #13149
24.3.50; Emacs thinks file was changed outside Emacs, but it was not

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Tue, 11 Dec 2012 21:53:02 UTC

Severity: normal

Tags: moreinfo, unreproducible

Found in version 24.3.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Dmitry Gutov <raaahh <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 13149 <at> debbugs.gnu.org
Subject: bug#13149: 24.3.50; Emacs thinks file was changed outside Emacs, but it was not
Date: Thu, 17 Jan 2013 13:33:06 -0800
On 01/17/13 02:32, Dmitry Gutov wrote:
> dired.c:958: stat_mtime=1358412092.606214085
> modify again
> fileio.c:5414: stat_mtime=1358412092.606214000

The first time stamp comes from lstat, the second
from stat.  If the file is actually on an NTFS file
system from the underlying host, the first time stamp
cannot possibly be right, since these file systems
have a time stamp resolution of 100 nanoseconds.
The second time stamp would be the correct one.

So it does seem to be a file system bug.  Is this something
that you can reproduce with a little C program, that
creates a file, and invoke lstat and stat on it?
What happens when you run the following program
in your file system?  It should output time stamps
that are identical.  You may need to substitute
something else (like sleep (10)) for "sync ()"
to trigger the bug.

#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>

int
main (void)
{
  char const *file = "foo";
  struct stat lst, st;
  int fd;
  unlink (file);
  fd = open (file, O_CREAT | O_WRONLY, -1);
  if (fd < 0)
    return perror ("open"), 1;
  if (lstat (file, &lst) != 0)
    return perror ("lstat"), 1;
  sync ();
  if (stat (file, &st) != 0)
    return perror ("stat"), 1;
  printf ("%ld.%09ld\n", (long) lst.st_mtim.tv_sec, lst.st_mtim.tv_nsec);
  printf ("%ld.%09ld\n", (long) st.st_mtim.tv_sec, st.st_mtim.tv_nsec);
  return 0;
}





This bug report was last modified 11 years and 103 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.