Problem reported by Yanyan Jiang 蒋炎岩 in: http://bugs.gnu.org/22768
* NEWS: Document this.
* bootstrap.conf (gnulib_modules): Add fsync.
* gzip.c (treat_file): Call fsync just before closing the output.
* lib/.gitignore, m4/.gitignore: Add fsync-related gnulib files.
** Changes in behavior
+ When acting in-place, gzip now fsyncs the output before closing it.
+ This is slower, but on many file systems it is safer if the system
+ is about to crash.
+
The GZIP environment variable is now obsolescent; gzip now warns if
it is used, and rejects attempts to use dangerous options or operands.
You can use an alias or script instead.
fdl
fdopendir
fprintf-posix
+fsync
getopt-gnu
git-version-gen
gitlog-to-changelog
if (!to_stdout)
{
-
copy_stat (&istat);
+
+ /* Transfer output data to the output file's storage device.
+ Otherwise, if the system crashed now the user might lose
+ both input and output data. See: Pillai TS et al. All
+ file systems are not created equal: on the complexity of
+ crafting crash-consistent applications. OSDI'14. 2014:433-48.
+ https://www.usenix.org/conference/osdi14/technical-sessions/presentation/pillai */
+ if (!keep && fsync (ofd) != 0 && errno != EINVAL)
+ write_error ();
+
if (close (ofd) != 0)
write_error ();
/xsize.h
/yesno.c
/yesno.h
+/fsync.c
/xalloc.m4
/xsize.m4
/yesno.m4
+/fsync.m4