X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/fe6407b5a9f04c88f74ea95e959aaa38334e41a6..f264662f71d65a8addc50d3ee0372d82c903bf2a:/fsync.diff diff --git a/fsync.diff b/fsync.diff index d0ec598..7d53eda 100644 --- a/fsync.diff +++ b/fsync.diff @@ -1,85 +1,102 @@ This patch from Sami Farin lets you specify --fsync if you want fsync() to be called on every file we write. ---- options.c 6 May 2004 21:08:01 -0000 1.148 -+++ options.c 15 May 2004 20:20:27 -0000 -@@ -37,6 +37,7 @@ int make_backups = 0; - **/ - int whole_file = -1; - -+int do_fsync = 0; - int archive_mode = 0; +To use this patch, run these commands for a successful build: + + patch -p1 0 && sparse_end(fd) != 0) { - rsyserr(FERROR, errno, "write failed on %s", ++ if (do_fsync && fd != -1 && fsync(fd) != 0) { ++ rsyserr(FERROR, errno, "fsync failed on %s", + full_fname(fname)); + exit_cleanup(RERR_FILEIO); + } + -+ if (do_fsync && (fd != -1) && (fsync(fd) != 0)) { -+ rsyserr(FERROR, errno, "fsync failed on %s", - full_fname(fname)); - exit_cleanup(RERR_FILEIO); - } ---- util.c 15 May 2004 19:31:10 -0000 1.143 -+++ util.c 15 May 2004 20:20:28 -0000 -@@ -29,6 +29,7 @@ + sum_len = sum_end(file_sum1); - extern int verbose; - extern struct exclude_list_struct server_exclude_list; -+extern int do_fsync; + if (mapbuf) +--- old/t_stub.c ++++ new/t_stub.c +@@ -21,6 +21,7 @@ - int sanitize_paths = 0; + #include "rsync.h" -@@ -291,6 +292,12 @@ int copy_file(char *source, char *dest, ++int do_fsync = 0; + int modify_window = 0; + int module_id = -1; + int relative_paths = 0; +--- old/util.c ++++ new/util.c +@@ -25,6 +25,7 @@ + extern int verbose; + extern int dry_run; + extern int module_id; ++extern int do_fsync; + extern int modify_window; + extern int relative_paths; + extern int human_readable; +@@ -310,6 +311,13 @@ int copy_file(const char *source, const + full_fname(source)); + } - if (close(ofd) < 0) { - rsyserr(FERROR, errno, "close failed on %s", ++ if (do_fsync && fsync(ofd) < 0) { ++ rsyserr(FERROR, errno, "fsync failed on %s", + full_fname(dest)); ++ close(ofd); + return -1; + } + -+ if (do_fsync && fsync(ofd) < 0) { -+ rsyserr(FERROR, errno, "fsync failed on %s", + if (close(ofd) < 0) { + rsyserr(FERROR, errno, "close failed on %s", full_fname(dest)); - return -1; - }