summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-02-27 14:12:46 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-02-28 00:02:57 -0800
commit5ef892a9248e02dac13840f0acefe0fe72605dfa (patch)
tree1d5658a8d1f0db3b997d8d06e6edece44ef0e658 /lib
parent22aac8f8a616a72dbbe0e4119db8ddda0f076c04 (diff)
downloadgzip-5ef892a9248e02dac13840f0acefe0fe72605dfa.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/.gitignore10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/.gitignore b/lib/.gitignore
index a368a26..b26889f 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -5,6 +5,7 @@
/alloca.in.h
/asnprintf.c
/assure.h
+/at-func.c
/basename-lgpl.c
/c-ctype.c
/c-ctype.h
@@ -59,6 +60,7 @@
/fd-hook.c
/fd-hook.h
/fd-safer.c
+/fdatasync.c
/fdopendir.c
/fflush.c
/filename.h
@@ -84,6 +86,8 @@
/fseterr.c
/fseterr.h
/fstat.c
+/fstatat.c
+/fsync.c
/ftell.c
/ftello.c
/getcwd-lgpl.c
@@ -132,6 +136,7 @@
/openat-die.c
/openat-priv.h
/openat-proc.c
+/openat-safer.c
/openat.c
/openat.h
/opendir-safer.c
@@ -157,6 +162,7 @@
/ref-add.sin
/ref-del.sed
/ref-del.sin
+/rmdir.c
/save-cwd.c
/save-cwd.h
/savedir.c
@@ -169,6 +175,7 @@
/stat-time.c
/stat-time.h
/stat.c
+/statat.c
/stdbool.h
/stdbool.in.h
/stddef.h
@@ -205,6 +212,8 @@
/unistd.c
/unistd.h
/unistd.in.h
+/unlink.c
+/unlinkat.c
/unused-parameter.h
/utimens.c
/utimens.h
@@ -225,4 +234,3 @@
/xsize.h
/yesno.c
/yesno.h
-/fsync.c