* fileio.c (Fwrite_region): When neither O_EXCL nor O_TRUNC is used,
the file's time stamp doesn't change if Emacs happens to write nothing
to the file, and on a buggy file system this could cause Emacs to
incorrectly infer that the file system doesn't have the bug.
Avoid this problem by inhibiting the inference in this case.
Fixes: debbugs:13149
+2013-02-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ Fix timestamp bug when write-region appends nothing (Bug#13149).
+ * fileio.c (Fwrite_region): When neither O_EXCL nor O_TRUNC is used,
+ the file's time stamp doesn't change if Emacs happens to write nothing
+ to the file, and on a buggy file system this could cause Emacs to
+ incorrectly infer that the file system doesn't have the bug.
+ Avoid this problem by inhibiting the inference in this case.
+
2013-02-01 Dmitry Antipov <dmantipov@yandex.ru>
* window.h (struct window): Convert base_line_number, base_line_pos
&& st.st_dev == st1.st_dev && st.st_ino == st1.st_ino)
{
EMACS_TIME modtime1 = get_stat_mtime (&st1);
- if (EMACS_TIME_EQ (modtime, modtime1)
+ /* If neither O_EXCL nor O_TRUNC is used, and Emacs happened to
+ write nothing to the file, the file's time stamp won't change
+ so it should not be used in this heuristic. */
+ if ((open_flags & (O_EXCL | O_TRUNC)) != 0
+ && EMACS_TIME_EQ (modtime, modtime1)
&& st.st_size == st1.st_size)
{
timestamp_file_system = st.st_dev;