To: vim-dev@vim.org Subject: Patch 6.2.499 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.499 Problem: When writing a file and halting the system, the file might be lost when using a journalling file system. Solution: Use fsync() to flush the file data to disk after writing a file. (Radim Kolar) Files: src/fileio.c *** ../vim-6.2.498/src/fileio.c Sun Apr 25 14:47:56 2004 --- src/fileio.c Sun Apr 25 14:47:52 2004 *************** *** 3802,3807 **** --- 3802,3820 ---- nchars += len; } + #if defined(UNIX) && defined(HAVE_FSYNC) + /* On many journalling file systems there is a bug that causes both the + * original and the backup file to be lost when halting the system right + * after writing the file. That's because only the meta-data is + * journalled. Syncing the file slows down the system, but assures it has + * been written to disk and we don't lose it. */ + if (fsync(fd) != 0) + { + errmsg = (char_u *)_("E667: Fsync failed"); + end = 0; + } + #endif + if (close(fd) != 0) { errmsg = (char_u *)_("E512: Close failed"); *** ../vim-6.2.498/src/version.c Sun Apr 25 14:47:56 2004 --- src/version.c Sun Apr 25 16:25:39 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 499, /**/ -- Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy lies a small unregarded yellow sun. Orbiting this at a distance of roughly ninety-eight million miles is an utterly insignificant little blue-green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea ... -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///