gzip: fdatasync output dir before unlinking
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 27 Feb 2016 22:12:46 +0000 (14:12 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 28 Feb 2016 08:02:57 +0000 (00:02 -0800)
commit5ef892a9248e02dac13840f0acefe0fe72605dfa
tree1d5658a8d1f0db3b997d8d06e6edece44ef0e658
parent22aac8f8a616a72dbbe0e4119db8ddda0f076c04
gzip: fdatasync output dir before unlinking

This follows up on the earlier patch to avoid data loss near
the system crashes.  See: http://bugs.gnu.org/22768
* bootstrap.conf (gnulib_modules): Add dirname-lgpl, fdatasync,
openat-safer, unistd-safer, unlinkat.
* gzip.c: Include stddef.h, dirname.h.
Include fcntl--.h instead of fcntl-safer.h.
(RW_USER): Remove; no longer needed.
(dfname, dfd): New static vars.
(dot): New static const.
(atdir_eq, atdir_set): New functions.
(treat_file): Also fdatasync the output directory, if !keep.
(treat_file, create_outfile, open_and_stat):
Use dir fd for unlinkat and openat, if possible.
(open_and_stat): Omit mode argument, since it was always the
same.  All callers changed.
* lib/.gitignore, m4/.gitignore: Add new gnulib files.
* tailor.h (PROTO, NO_STDIN_FSTAT, OPEN): Remove.  Remove MACOS
section, as this stuff would not work anyway now, and circa 2001
Apple stopped supporting Mac OS 9 and earlier.
* zip.c: Do not include unistd.h and fcntl.h, as this file does
not directly use any symbols defined by those headers.
bootstrap.conf
gzip.c
lib/.gitignore
m4/.gitignore
tailor.h
zip.c