Commit 35e85499 authored by Paul Eggert's avatar Paul Eggert

Fix timestamp bug when write-region appends nothing.

* 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
parent af314ba0
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> 2013-02-01 Dmitry Antipov <dmantipov@yandex.ru>
* window.h (struct window): Convert base_line_number, base_line_pos * window.h (struct window): Convert base_line_number, base_line_pos
......
...@@ -5036,7 +5036,11 @@ This calls `write-region-annotate-functions' at the start, and ...@@ -5036,7 +5036,11 @@ This calls `write-region-annotate-functions' at the start, and
&& st.st_dev == st1.st_dev && st.st_ino == st1.st_ino) && st.st_dev == st1.st_dev && st.st_ino == st1.st_ino)
{ {
EMACS_TIME modtime1 = get_stat_mtime (&st1); 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) && st.st_size == st1.st_size)
{ {
timestamp_file_system = st.st_dev; timestamp_file_system = st.st_dev;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment