Description: Optionally preserve atimes Origin: https://bugzilla.samba.org/show_bug.cgi?id=7249 Last-Update: 2019-10-09 Index: rsync/options.c =================================================================== --- rsync.orig/options.c +++ rsync/options.c @@ -128,6 +128,7 @@ int delay_updates = 0; long block_size = 0; /* "long" because popt can't set an int32. */ char *skip_compress = NULL; item_list dparam_list = EMPTY_ITEM_LIST; +int noatime = 0; /** Network address family. **/ int default_af_hint @@ -806,6 +807,7 @@ void usage(enum logcode F) rprintf(F," --iconv=CONVERT_SPEC request charset conversion of filenames\n"); #endif rprintf(F," --checksum-seed=NUM set block/file checksum seed (advanced)\n"); + rprintf(F," --noatime do not alter atime when opening source files\n"); rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); rprintf(F," --version print version number\n"); @@ -1027,6 +1029,7 @@ static struct poptOption long_options[] {"iconv", 0, POPT_ARG_STRING, &iconv_opt, 0, 0, 0 }, {"no-iconv", 0, POPT_ARG_NONE, 0, OPT_NO_ICONV, 0, 0 }, #endif + {"noatime", 0, POPT_ARG_VAL, &noatime, 1, 0, 0 }, {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, {"8-bit-output", '8', POPT_ARG_VAL, &allow_8bit_chars, 1, 0, 0 }, @@ -2807,6 +2810,12 @@ void server_options(char **args, int *ar if (preallocate_files && am_sender) args[ac++] = "--preallocate"; + /* + * Do we want remote atime preservation when we preserve local ones? + if (noatime) + args[ac++] = "--noatime"; + */ + if (ac > MAX_SERVER_ARGS) { /* Not possible... */ rprintf(FERROR, "argc overflow in server_options().\n"); exit_cleanup(RERR_MALLOC); Index: rsync/rsync.yo =================================================================== --- rsync.orig/rsync.yo +++ rsync/rsync.yo @@ -458,6 +458,7 @@ to the detailed description below for a --protocol=NUM force an older protocol version to be used --iconv=CONVERT_SPEC request charset conversion of filenames --checksum-seed=NUM set block/file checksum seed (advanced) + --noatime do not alter atime when opening source files -4, --ipv4 prefer IPv4 -6, --ipv6 prefer IPv6 --version print version number @@ -2659,6 +2660,13 @@ daemon uses the charset specified in its regardless of the remote charset you actually pass. Thus, you may feel free to specify just the local charset for a daemon transfer (e.g. bf(--iconv=utf8)). +dit(bf(--noatime)) Use the O_NOATIME open flag on systems that support it. +The effect of this flag is to avoid altering the access time (atime) of the +opened files. +If the system does not support the O_NOATIME flag, this option does nothing. +Currently, systems known to support O_NOATIME are Linux >= 2.6.8 with glibc +>= 2.3.4. + dit(bf(-4, --ipv4) or bf(-6, --ipv6)) Tells rsync to prefer IPv4/IPv6 when creating sockets. This only affects sockets that rsync has direct control over, such as the outgoing socket when directly contacting an Index: rsync/syscall.c =================================================================== --- rsync.orig/syscall.c +++ rsync/syscall.c @@ -42,6 +42,7 @@ extern int inplace; extern int preallocate_files; extern int preserve_perms; extern int preserve_executability; +extern int noatime; #ifndef S_BLKSIZE # if defined hpux || defined __hpux__ || defined __hpux @@ -201,6 +202,10 @@ int do_open(const char *pathname, int fl RETURN_ERROR_IF(dry_run, 0); RETURN_ERROR_IF_RO_OR_LO; } +#ifdef O_NOATIME + if (noatime) + flags |= O_NOATIME; +#endif return open(pathname, flags | O_BINARY, mode); } Index: rsync/tls.c =================================================================== --- rsync.orig/tls.c +++ rsync/tls.c @@ -53,6 +53,7 @@ int preserve_perms = 0; int preserve_executability = 0; int preallocate_files = 0; int inplace = 0; +int noatime = 0; #ifdef SUPPORT_XATTRS Index: rsync/t_unsafe.c =================================================================== --- rsync.orig/t_unsafe.c +++ rsync/t_unsafe.c @@ -33,6 +33,10 @@ int preserve_perms = 0; int preserve_executability = 0; short info_levels[COUNT_INFO], debug_levels[COUNT_DEBUG]; +/* These is to make syscall.o shut up. */ +int noatime = 0; + + int main(int argc, char **argv) { Index: rsync/wildtest.c =================================================================== --- rsync.orig/wildtest.c +++ rsync/wildtest.c @@ -32,6 +32,9 @@ int fnmatch_errors = 0; int wildmatch_errors = 0; +/* These is to make syscall.o shut up. */ +int noatime = 0; + typedef char bool; int output_iterations = 0; Index: rsync/trimslash.c =================================================================== --- rsync.orig/trimslash.c +++ rsync/trimslash.c @@ -30,6 +30,7 @@ int preserve_perms = 0; int preserve_executability = 0; int preallocate_files = 0; int inplace = 0; +int noatime = 0; int main(int argc, char **argv)