X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/edd5f785d2ab6f389ac735538c3d771956bbaae7..refs/heads/master:/fsync.diff diff --git a/fsync.diff b/fsync.diff index f48325d..4e1b545 100644 --- a/fsync.diff +++ b/fsync.diff @@ -1,85 +1,107 @@ This patch from Sami Farin lets you specify --fsync if you want fsync() to be called on every file we write. ---- options.c 17 Apr 2004 17:07:23 -0000 1.147 -+++ options.c 27 Apr 2004 20:05:03 -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) { - rprintf(FERROR, "write failed on %s: %s\n", -+ full_fname(fname), strerror(errno)); ++ 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)) { -+ rprintf(FERROR, "fsync failed on %s: %s\n", - full_fname(fname), strerror(errno)); - exit_cleanup(RERR_FILEIO); - } ---- util.c 27 Apr 2004 19:59:37 -0000 1.141 -+++ util.c 27 Apr 2004 20:05:04 -0000 -@@ -29,6 +29,7 @@ + if (mapbuf) + unmap_file(mapbuf); - extern int verbose; - extern struct exclude_list_struct server_exclude_list; -+extern int do_fsync; +diff --git a/t_stub.c b/t_stub.c +--- a/t_stub.c ++++ b/t_stub.c +@@ -21,6 +21,7 @@ - int sanitize_paths = 0; + #include "rsync.h" -@@ -296,6 +297,12 @@ int copy_file(char *source, char *dest, ++int do_fsync = 0; + int modify_window = 0; + int module_id = -1; + int relative_paths = 0; +diff --git a/util.c b/util.c +--- a/util.c ++++ b/util.c +@@ -27,6 +27,7 @@ - if (close(ofd) < 0) { - rprintf(FERROR, "close failed on %s: %s\n", -+ full_fname(dest), strerror(errno)); + extern int dry_run; + extern int module_id; ++extern int do_fsync; + extern int modify_window; + extern int relative_paths; + extern int preserve_xattrs; +@@ -382,6 +383,13 @@ int copy_file(const char *source, const char *dest, int ofd, mode_t mode) + full_fname(source)); + } + ++ 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) { -+ rprintf(FERROR, "fsync failed on %s: %s\n", - full_fname(dest), strerror(errno)); - return -1; - } + if (close(ofd) < 0) { + int save_errno = errno; + rsyserr(FERROR_XFER, errno, "close failed on %s",