./configure (optional if already run)
make
-based-on: 1c82a1e1e54eb585cd37c875604193f5b977d24e
+based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -25,6 +25,7 @@
+@@ -24,6 +24,7 @@
+ #include "ifuncs.h"
#include <popt.h>
- #include <zlib.h>
+extern int direct_io;
extern int module_id;
extern int local_server;
extern int sanitize_paths;
-@@ -751,6 +752,7 @@ void usage(enum logcode F)
- rprintf(F," --partial keep partially transferred files\n");
- rprintf(F," --partial-dir=DIR put a partially transferred file into DIR\n");
- rprintf(F," --delay-updates put all updated files into place at transfer's end\n");
-+ rprintf(F," --direct-io don't use buffer cache for xfer file I/O\n");
- rprintf(F," -m, --prune-empty-dirs prune empty directory chains from the file-list\n");
- rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n");
- rprintf(F," --usermap=STRING custom username mapping\n");
-@@ -989,6 +991,8 @@ static struct poptOption long_options[] = {
+@@ -764,6 +765,8 @@ static struct poptOption long_options[] = {
{"partial-dir", 0, POPT_ARG_STRING, &partial_dir, 0, 0, 0 },
{"delay-updates", 0, POPT_ARG_VAL, &delay_updates, 1, 0, 0 },
{"no-delay-updates", 0, POPT_ARG_VAL, &delay_updates, 0, 0, 0 },
{"prune-empty-dirs",'m', POPT_ARG_VAL, &prune_empty_dirs, 1, 0, 0 },
{"no-prune-empty-dirs",0,POPT_ARG_VAL, &prune_empty_dirs, 0, 0, 0 },
{"no-m", 0, POPT_ARG_VAL, &prune_empty_dirs, 0, 0, 0 },
-diff --git a/rsync.yo b/rsync.yo
---- a/rsync.yo
-+++ b/rsync.yo
-@@ -412,6 +412,7 @@ to the detailed description below for a complete description. verb(
- --partial keep partially transferred files
- --partial-dir=DIR put a partially transferred file into DIR
- --delay-updates put all updated files into place at end
-+ --direct-io don't use buffer cache for xfer file I/O
- -m, --prune-empty-dirs prune empty directory chains from file-list
- --numeric-ids don't map uid/gid values by user/group name
- --usermap=STRING custom username mapping
-@@ -2498,6 +2499,14 @@ See also the "atomic-rsync" perl script in the "support" subdir for an
- update algorithm that is even more atomic (it uses bf(--link-dest) and a
- parallel hierarchy of files).
+diff --git a/rsync.1.md b/rsync.1.md
+--- a/rsync.1.md
++++ b/rsync.1.md
+@@ -495,6 +495,7 @@ has its own detailed description later in this manpage.
+ --partial keep partially transferred files
+ --partial-dir=DIR put a partially transferred file into DIR
+ --delay-updates put all updated files into place at end
++--direct-io don't use buffer cache for xfer file I/O
+ --prune-empty-dirs, -m prune empty directory chains from file-list
+ --numeric-ids don't map uid/gid values by user/group name
+ --usermap=STRING custom username mapping
+@@ -3433,6 +3434,17 @@ expand it.
+ update algorithm that is even more atomic (it uses [`--link-dest`](#opt)
+ and a parallel hierarchy of files).
-+dit(bf(--direct-io)) This option opens files with a direct-I/O flag that
-+makes the file I/O avoid the buffer cache. The option only affects one
-+side of the transfer (unless the transfer is local). If you want it to
-+affect both sides, use the bf(--remote-option) (bf(-M)) option to specify
-+it for the remote side. For instance, this specifies it for both sides:
++0. `--direct-io`
+
-+quote(tt( rsync -av {,-M}--direct-io /src/ host:/dest/))
++ This option opens files with a direct-I/O flag that makes the file I/O
++ avoid the buffer cache. The option only affects one side of the transfer
++ (unless the transfer is local). If you want it to affect both sides, use
++ the [`--remote-option`](#opt) (`-M`) option to specify it for the remote
++ side. For instance, this specifies it for both sides (via brace
++ expansion):
+
- dit(bf(-m, --prune-empty-dirs)) This option tells the receiving rsync to get
- rid of empty directories from the file-list, including nested directories
- that have no non-directory children. This is useful for avoiding the
++ > rsync -av {,-M}--direct-io /src/ host:/dest/
++
+ 0. `--prune-empty-dirs`, `-m`
+
+ This option tells the receiving rsync to get rid of empty directories from
diff --git a/syscall.c b/syscall.c
--- a/syscall.c
+++ b/syscall.c
-@@ -43,6 +43,8 @@ extern int preallocate_files;
- extern int preserve_perms;
+@@ -44,6 +44,8 @@ extern int preserve_perms;
extern int preserve_executability;
+ extern int open_noatime;
+int direct_io = 0;
+
#ifndef S_BLKSIZE
# if defined hpux || defined __hpux__ || defined __hpux
# define S_BLKSIZE 1024
-@@ -81,7 +83,12 @@ int do_symlink(const char *lnk, const char *fname)
+@@ -95,7 +97,12 @@ int do_symlink(const char *lnk, const char *path)
* and write the lnk into it. */
if (am_root < 0) {
int ok, len = strlen(lnk);
-- int fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
+- int fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
+ int flags = O_WRONLY|O_CREAT|O_TRUNC;
+
+ if (direct_io)
+ flags |= O_DIRECT;
+
-+ int fd = open(fname, flags, S_IWUSR|S_IRUSR);
++ int fd = open(path, flags, S_IWUSR|S_IRUSR);
if (fd < 0)
return -1;
ok = write(fd, lnk, len) == len;
-@@ -202,6 +209,9 @@ int do_open(const char *pathname, int flags, mode_t mode)
- RETURN_ERROR_IF_RO_OR_LO;
- }
-
+@@ -224,6 +231,8 @@ int do_open(const char *pathname, int flags, mode_t mode)
+ if (open_noatime)
+ flags |= O_NOATIME;
+ #endif
+ if (direct_io)
+ flags |= O_DIRECT;
-+
+
return open(pathname, flags | O_BINARY, mode);
}
-
-@@ -545,6 +555,9 @@ int do_open_nofollow(const char *pathname, int flags)
+@@ -684,6 +693,9 @@ int do_open_nofollow(const char *pathname, int flags)
#endif
}