]>
Commit | Line | Data |
---|---|---|
c852e141 ER |
1 | Optionally preserve atimes. |
2 | ||
3 | Based on https://bugzilla.samba.org/show_bug.cgi?id=7249#c1 by Nicolas George. | |
4 | ||
5 | Index: rsync-3.1.0/options.c | |
6 | =================================================================== | |
7 | --- rsync-3.1.0.orig/options.c | |
8 | +++ rsync-3.1.0/options.c | |
9 | @@ -125,6 +125,7 @@ int delay_updates = 0; | |
10 | long block_size = 0; /* "long" because popt can't set an int32. */ | |
11 | char *skip_compress = NULL; | |
12 | item_list dparam_list = EMPTY_ITEM_LIST; | |
13 | +int noatime = 0; | |
14 | ||
15 | /** Network address family. **/ | |
16 | int default_af_hint | |
17 | @@ -802,6 +803,7 @@ void usage(enum logcode F) | |
18 | rprintf(F," --iconv=CONVERT_SPEC request charset conversion of filenames\n"); | |
19 | #endif | |
20 | rprintf(F," --checksum-seed=NUM set block/file checksum seed (advanced)\n"); | |
21 | + rprintf(F," --noatime do not alter atime when opening source files\n"); | |
22 | rprintf(F," -4, --ipv4 prefer IPv4\n"); | |
23 | rprintf(F," -6, --ipv6 prefer IPv6\n"); | |
24 | rprintf(F," --version print version number\n"); | |
25 | @@ -1019,6 +1021,7 @@ static struct poptOption long_options[] | |
26 | {"iconv", 0, POPT_ARG_STRING, &iconv_opt, 0, 0, 0 }, | |
27 | {"no-iconv", 0, POPT_ARG_NONE, 0, OPT_NO_ICONV, 0, 0 }, | |
28 | #endif | |
29 | + {"noatime", 0, POPT_ARG_VAL, &noatime, 1, 0, 0 }, | |
30 | {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, | |
31 | {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, | |
32 | {"8-bit-output", '8', POPT_ARG_VAL, &allow_8bit_chars, 1, 0, 0 }, | |
33 | @@ -2739,6 +2742,12 @@ void server_options(char **args, int *ar | |
34 | if (preallocate_files && am_sender) | |
35 | args[ac++] = "--preallocate"; | |
36 | ||
37 | + /* | |
38 | + * Do we want remote atime preservation when we preserve local ones? | |
39 | + if (noatime) | |
40 | + args[ac++] = "--noatime"; | |
41 | + */ | |
42 | + | |
43 | if (ac > MAX_SERVER_ARGS) { /* Not possible... */ | |
44 | rprintf(FERROR, "argc overflow in server_options().\n"); | |
45 | exit_cleanup(RERR_MALLOC); | |
46 | Index: rsync-3.1.0/rsync.yo | |
47 | =================================================================== | |
48 | --- rsync-3.1.0.orig/rsync.yo | |
49 | +++ rsync-3.1.0/rsync.yo | |
50 | @@ -454,6 +454,7 @@ to the detailed description below for a | |
51 | --protocol=NUM force an older protocol version to be used | |
52 | --iconv=CONVERT_SPEC request charset conversion of filenames | |
53 | --checksum-seed=NUM set block/file checksum seed (advanced) | |
54 | + --noatime do not alter atime when opening source files | |
55 | -4, --ipv4 prefer IPv4 | |
56 | -6, --ipv6 prefer IPv6 | |
57 | --version print version number | |
58 | @@ -2543,6 +2544,13 @@ daemon uses the charset specified in its | |
59 | regardless of the remote charset you actually pass. Thus, you may feel free to | |
60 | specify just the local charset for a daemon transfer (e.g. bf(--iconv=utf8)). | |
61 | ||
62 | +dit(bf(--noatime)) Use the O_NOATIME open flag on systems that support it. | |
63 | +The effect of this flag is to avoid altering the access time (atime) of the | |
64 | +opened files. | |
65 | +If the system does not support the O_NOATIME flag, this option does nothing. | |
66 | +Currently, systems known to support O_NOATIME are Linux >= 2.6.8 with glibc | |
67 | +>= 2.3.4. | |
68 | + | |
69 | dit(bf(-4, --ipv4) or bf(-6, --ipv6)) Tells rsync to prefer IPv4/IPv6 | |
70 | when creating sockets. This only affects sockets that rsync has direct | |
71 | control over, such as the outgoing socket when directly contacting an | |
72 | diff --git a/syscall.c b/syscall.c | |
73 | index c46a8b4..6620563 100644 | |
74 | --- a/syscall.c | |
75 | +++ b/syscall.c | |
76 | @@ -42,6 +42,7 @@ extern int inplace; | |
77 | extern int preallocate_files; | |
78 | extern int preserve_perms; | |
79 | extern int preserve_executability; | |
80 | +extern int noatime; | |
81 | ||
82 | #ifndef S_BLKSIZE | |
83 | # if defined hpux || defined __hpux__ || defined __hpux | |
84 | @@ -189,6 +190,10 @@ int do_open(const char *pathname, int fl | |
85 | RETURN_ERROR_IF(dry_run, 0); | |
86 | RETURN_ERROR_IF_RO_OR_LO; | |
87 | } | |
88 | +#ifdef O_NOATIME | |
89 | + if (noatime) | |
90 | + flags |= O_NOATIME; | |
91 | +#endif | |
92 | ||
93 | return open(pathname, flags | O_BINARY, mode); | |
94 | } |