encfs icon indicating copy to clipboard operation
encfs copied to clipboard

Inaccurate nanoseconds in timestamp for fstat when backed by CIFS file system

Open eggert opened this issue 10 years ago • 2 comments

An GNU Emacs user is reporting that when using Emacs to edit a file in an encfs file system (where the encrypted version is stored via CIFS in a Microsoft server), Emacs complains that the file has changed even though it has not. We can reproduce the bug without using Emacs. Please see http://bugs.gnu.org/19607 for the Emacs bug report, in particular Message#38 (which gives a small C test program) and Message#41 (which confirms that the bug is present. The C program can be found at http://debbugs.gnu.org/cgi/bugreport.cgi?msg=38;filename=test.c;att=1;bug=19607.

The problem appears to be that encfs and/or CIFS is marking a file for update, then the program calls fstat to get the time stamp, and then afterwards encfs and/or CIFS actually updates st_mtime. POSIX does not allow this behavior; fstat should get the updated st_mtime.

eggert avatar Jan 26 '15 19:01 eggert

This can also be reproduced on CIFS (without EncFS). Forwarded to https://bugzilla.samba.org/show_bug.cgi?id=11078

rfjakob avatar Jan 27 '15 21:01 rfjakob

A new test case shows that EncFS does do something wrong. Code at https://gist.github.com/rfjakob/a956df2edcb69b486938 , results:

CIFS:

   Emacs should work around this POSIX-conformance bug.
   stat #1: 1422398418.561215369
   stat #2: 1422398418.561215300
   stat #3: 1422398418.561215300

CIFS + encfs:

   Emacs does not work around this POSIX-conformance bug.
   stat #1: 1422398433.735274107
   stat #2: 1422398433.735274107
   stat #3: 1422398433.735274100

CIFS + "encfs -o attr_timeout=0":

   Emacs should work around this POSIX-conformance bug.
   stat #1: 1422398527.607547169
   stat #2: 1422398527.607547100
   stat #3: 1422398527.607547100

rfjakob avatar Jan 28 '15 08:01 rfjakob