
On Wed, 11 Apr 2012, Trent W. Buck wrote:
Russell Coker wrote:
On Tue, 10 Apr 2012, Jason White <jason@jasonjgw.net> wrote:
It is my (perhaps faulty) understanding that most editors omit the fsync() and that the file will only be on your memory stick when you unmount it in the typical case.
open("test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4 write(4, "test\n\n", 6) = 6 fsync(4) = 0 stat("test", {st_mode=S_IFREG|0644, st_size=6, ...}) = 0 close(4)
I've just run strace on vim and it calls fsync.
If most editors omit the fsync() as you claim then please run strace and find us an example of one - and file a bug report while you are at it. ;)
FYI,
execve("/usr/bin/emacs", ["emacs", "-Q", "/tmp/y"], [/* 46 vars */]) = 0 [...] access("/tmp/", W_OK) = 0 lstat64("/tmp/.#y", {st_mode=S_IFLNK|0777, st_size=25, ...}) = 0 stat64("/tmp/y", 0xbe9b7c48) = -1 ENOENT (No such file or directory) symlink("twb@elba.12820:1333989873", "/tmp/.#y") = -1 EEXIST (File exists) readlink("/tmp/.#y", "twb@elba.12820:1333989873"..., 100) = 25 open("/tmp/y", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 4 write(4, "fnord.", 6) = 6 fsync(4) = 0 close(4) = 0
Gah! When did they fix that "bug"?
Maybe I have managed to turn that mode off with one of the many possible backup behaviours of emacs. Or maybe it explains why emacs has been so slow at autosaving lately.
You're not the first one to have this thought:
From http://www.gnu.org/software/emacs/manual/html_node/emacs/Customize-Save.html
" When Emacs saves a file, it invokes the fsync system call to force the data immediately out to disk. This is important for safety if the system crashes or in case of power outage. However, it can be disruptive on laptops using power saving, because it requires the disk to spin up each time you save a file. Setting write-region-inhibit-fsync to a non-nil value disables this synchronization. Be careful-this means increased risk of data loss. " James