X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/fe6407b5a9f04c88f74ea95e959aaa38334e41a6..refs/heads/master:/fsync.diff diff --git a/fsync.diff b/fsync.diff index d0ec598..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 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 @@ + 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" -@@ -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; +diff --git a/util.c b/util.c +--- a/util.c ++++ b/util.c +@@ -27,6 +27,7 @@ - if (close(ofd) < 0) { - rsyserr(FERROR, errno, "close failed on %s", + 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) { -+ rsyserr(FERROR, errno, "fsync failed on %s", - full_fname(dest)); - return -1; - } + if (close(ofd) < 0) { + int save_errno = errno; + rsyserr(FERROR_XFER, errno, "close failed on %s",