]> git.eshelyaron.com Git - emacs.git/commitdiff
Properly record mtime after insert-file-contents on Android
authorPo Lu <luangruo@yahoo.com>
Sat, 17 Feb 2024 02:27:26 +0000 (10:27 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sat, 17 Feb 2024 13:02:22 +0000 (14:02 +0100)
* src/fileio.c (write_region): Do not verify file identity after
retreiving file status for the second time if st_ino is 0.

(cherry picked from commit 5b65c2ad7526ec081ac37d32c87e9b58e787d66a)

src/fileio.c

index a92da93ae4804d06c927cf5ce306d75aec212517..483498fd879523ea796d2063241e7b03a9e9aaa4 100644 (file)
@@ -5628,7 +5628,15 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
          changed to a call to `stat'.  */
 
       if (emacs_fstatat (AT_FDCWD, fn, &st1, 0) == 0
-         && st.st_dev == st1.st_dev && st.st_ino == st1.st_ino)
+         && st.st_dev == st1.st_dev
+         && (st.st_ino == st1.st_ino
+#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
+             /* `st1.st_ino' == 0 indicates that the inode number
+                cannot be extracted from this document file, despite
+                `st' potentially being backed by a real file.  */
+             || st1.st_ino == 0
+#endif /* defined HAVE_ANDROID && !defined ANDROID_STUBIFY */
+             ))
        {
          /* Use the heuristic if it appears to be valid.  With neither
             O_EXCL nor O_TRUNC, if Emacs happened to write nothing to the