Commit | Line | Data |
---|---|---|
03019e41 | 1 | To use this patch, run these commands for a successful build: |
8a529471 | 2 | |
03019e41 | 3 | patch -p1 <patches/atimes.diff |
27e96866 WD |
4 | ./prepare-source |
5 | ./configure (optional if already run) | |
6 | make | |
8a529471 WD |
7 | |
8 | ||
9a7eef96 WD |
9 | --- old/flist.c |
10 | +++ new/flist.c | |
b3593e7c | 11 | @@ -46,6 +46,7 @@ extern int preserve_devices; |
4a65fe72 | 12 | extern int preserve_specials; |
81c32ffd WD |
13 | extern int preserve_uid; |
14 | extern int preserve_gid; | |
15 | +extern int preserve_atimes; | |
16 | extern int relative_paths; | |
a5e0f697 | 17 | extern int implied_dirs; |
4a65fe72 | 18 | extern int prune_empty_dirs; |
b3593e7c | 19 | @@ -79,7 +80,13 @@ void init_flist(void) |
1cb60481 WD |
20 | struct file_struct f; |
21 | ||
22 | /* Figure out how big the file_struct is without trailing padding */ | |
23 | - file_struct_len = offsetof(struct file_struct, flags) + sizeof f.flags; | |
24 | + if (preserve_atimes) | |
55602791 | 25 | + file_struct_len = offsetof(struct file_struct, fl4g5); |
1cb60481 WD |
26 | + else |
27 | + file_struct_len = offsetof(struct file_struct, atime); | |
55602791 WD |
28 | + /* The "flags" uchar is no longer accessed directly, so I |
29 | + * mangled the name to fl4g5 as a reminder. */ | |
30 | + file_struct_len += sizeof f.fl4g5; | |
1cb60481 WD |
31 | checksum_len = protocol_version < 21 ? 2 : MD4_SUM_LENGTH; |
32 | } | |
33 | ||
b3593e7c | 34 | @@ -135,16 +142,18 @@ static void list_file_entry(struct file_ |
43581f16 | 35 | |
09fb8f03 | 36 | #ifdef SUPPORT_LINKS |
43581f16 WD |
37 | if (preserve_links && S_ISLNK(f->mode)) { |
38 | - rprintf(FINFO, "%s %11.0f %s %s -> %s\n", | |
39 | + rprintf(FINFO, "%s %11.0f %s %s %s -> %s\n", | |
4a65fe72 | 40 | permbuf, |
f3e2725a | 41 | (double)f->length, timestring(f->modtime), |
1cb60481 | 42 | + preserve_atimes ? timestring(f->atime) : "", |
bd68c3c2 | 43 | f_name(f, NULL), f->u.link); |
43581f16 WD |
44 | } else |
45 | #endif | |
896c61d0 | 46 | { |
43581f16 WD |
47 | - rprintf(FINFO, "%s %11.0f %s %s\n", |
48 | + rprintf(FINFO, "%s %11.0f %s %s %s\n", | |
4a65fe72 | 49 | permbuf, |
f3e2725a | 50 | (double)f->length, timestring(f->modtime), |
1cb60481 | 51 | + preserve_atimes ? timestring(f->atime) : "", |
bd68c3c2 | 52 | f_name(f, NULL)); |
896c61d0 | 53 | } |
43581f16 | 54 | } |
3f053c45 | 55 | @@ -302,6 +311,7 @@ static void send_file_entry(struct file_ |
43581f16 WD |
56 | { |
57 | unsigned short flags; | |
58 | static time_t modtime; | |
59 | + static time_t atime; | |
60 | static mode_t mode; | |
ba50e96c | 61 | static int64 dev; |
43581f16 | 62 | static dev_t rdev; |
3f053c45 | 63 | @@ -317,7 +327,7 @@ static void send_file_entry(struct file_ |
43581f16 WD |
64 | |
65 | if (!file) { | |
66 | write_byte(f, 0); | |
67 | - modtime = 0, mode = 0; | |
68 | + modtime = 0, atime = 0, mode = 0; | |
d9f0e41c | 69 | dev = 0, rdev = MAKEDEV(0, 0); |
43581f16 WD |
70 | rdev_major = 0; |
71 | uid = 0, gid = 0; | |
3f053c45 | 72 | @@ -327,7 +337,7 @@ static void send_file_entry(struct file_ |
1cb60481 WD |
73 | |
74 | f_name(file, fname); | |
75 | ||
76 | - flags = file->flags & XMIT_TOP_DIR; | |
77 | + flags = FFLAGS(file) & XMIT_TOP_DIR; | |
78 | ||
79 | if (file->mode == mode) | |
80 | flags |= XMIT_SAME_MODE; | |
3f053c45 | 81 | @@ -363,6 +373,12 @@ static void send_file_entry(struct file_ |
43581f16 WD |
82 | flags |= XMIT_SAME_TIME; |
83 | else | |
84 | modtime = file->modtime; | |
81c32ffd | 85 | + if (preserve_atimes && !S_ISDIR(mode)) { |
43581f16 WD |
86 | + if (file->atime == atime) |
87 | + flags |= XMIT_SAME_ATIME; | |
88 | + else | |
89 | + atime = file->atime; | |
90 | + } | |
91 | ||
09fb8f03 | 92 | #ifdef SUPPORT_HARD_LINKS |
43581f16 | 93 | if (file->link_u.idev) { |
3f053c45 | 94 | @@ -416,6 +432,8 @@ static void send_file_entry(struct file_ |
43581f16 WD |
95 | write_int(f, modtime); |
96 | if (!(flags & XMIT_SAME_MODE)) | |
97 | write_int(f, to_wire_mode(mode)); | |
81c32ffd | 98 | + if (preserve_atimes && !S_ISDIR(mode) && !(flags & XMIT_SAME_ATIME)) |
43581f16 WD |
99 | + write_int(f, atime); |
100 | if (preserve_uid && !(flags & XMIT_SAME_UID)) { | |
101 | if (!numeric_ids) | |
102 | add_uid(uid); | |
3f053c45 | 103 | @@ -482,6 +500,7 @@ static struct file_struct *receive_file_ |
09fb8f03 | 104 | unsigned short flags, int f) |
43581f16 WD |
105 | { |
106 | static time_t modtime; | |
107 | + static time_t atime; | |
108 | static mode_t mode; | |
ba50e96c | 109 | static int64 dev; |
43581f16 | 110 | static dev_t rdev; |
3f053c45 | 111 | @@ -500,7 +519,7 @@ static struct file_struct *receive_file_ |
43581f16 WD |
112 | struct file_struct *file; |
113 | ||
a7219d20 | 114 | if (!flist) { |
43581f16 WD |
115 | - modtime = 0, mode = 0; |
116 | + modtime = 0, atime = 0, mode = 0; | |
d9f0e41c | 117 | dev = 0, rdev = MAKEDEV(0, 0); |
43581f16 WD |
118 | rdev_major = 0; |
119 | uid = 0, gid = 0; | |
3f053c45 | 120 | @@ -556,6 +575,8 @@ static struct file_struct *receive_file_ |
43581f16 WD |
121 | modtime = (time_t)read_int(f); |
122 | if (!(flags & XMIT_SAME_MODE)) | |
123 | mode = from_wire_mode(read_int(f)); | |
81c32ffd | 124 | + if (preserve_atimes && !S_ISDIR(mode) && !(flags & XMIT_SAME_ATIME)) |
43581f16 WD |
125 | + atime = (time_t)read_int(f); |
126 | ||
1cb60481 WD |
127 | if (chmod_modes && !S_ISLNK(mode)) |
128 | mode = tweak_mode(mode, chmod_modes); | |
3f053c45 | 129 | @@ -611,6 +632,8 @@ static struct file_struct *receive_file_ |
43581f16 | 130 | file->mode = mode; |
8a04c9a7 WD |
131 | file->uid = uid; |
132 | file->gid = gid; | |
1cb60481 WD |
133 | + if (preserve_atimes) |
134 | + file->atime = atime; | |
135 | ||
136 | if (dirname_len) { | |
137 | file->dirname = lastdir = bp; | |
3f053c45 | 138 | @@ -636,12 +659,12 @@ static struct file_struct *receive_file_ |
1cb60481 WD |
139 | && lastname[del_hier_name_len-1] == '.' |
140 | && lastname[del_hier_name_len-2] == '/') | |
141 | del_hier_name_len -= 2; | |
142 | - file->flags |= FLAG_TOP_DIR | FLAG_DEL_HERE; | |
143 | + FFLAGS(file) |= FLAG_TOP_DIR | FLAG_DEL_HERE; | |
144 | } else if (in_del_hier) { | |
145 | if (!relative_paths || !del_hier_name_len | |
146 | || (l1 >= del_hier_name_len | |
147 | && lastname[del_hier_name_len] == '/')) | |
148 | - file->flags |= FLAG_DEL_HERE; | |
149 | + FFLAGS(file) |= FLAG_DEL_HERE; | |
150 | else | |
151 | in_del_hier = 0; | |
152 | } | |
3f053c45 | 153 | @@ -858,12 +881,14 @@ struct file_struct *make_file(char *fnam |
1cb60481 WD |
154 | memset(bp, 0, file_struct_len); |
155 | bp += file_struct_len; | |
43581f16 | 156 | |
1cb60481 WD |
157 | - file->flags = flags; |
158 | + FFLAGS(file) = flags; | |
43581f16 | 159 | file->modtime = st.st_mtime; |
43581f16 | 160 | file->length = st.st_size; |
1cb60481 | 161 | file->mode = st.st_mode; |
8a04c9a7 WD |
162 | file->uid = st.st_uid; |
163 | file->gid = st.st_gid; | |
1cb60481 WD |
164 | + if (preserve_atimes) |
165 | + file->atime = st.st_atime; | |
166 | ||
167 | #ifdef SUPPORT_HARD_LINKS | |
168 | if (flist && flist->hlink_pool) { | |
3f053c45 | 169 | @@ -976,7 +1001,7 @@ static void send_if_directory(int f, str |
1cb60481 WD |
170 | char is_dot_dir = fbuf[ol-1] == '.' && (ol == 1 || fbuf[ol-2] == '/'); |
171 | ||
172 | if (S_ISDIR(file->mode) | |
173 | - && !(file->flags & FLAG_MOUNT_POINT) && f_name(file, fbuf)) { | |
174 | + && !(FFLAGS(file) & FLAG_MOUNT_POINT) && f_name(file, fbuf)) { | |
175 | void *save_filters; | |
176 | unsigned int len = strlen(fbuf); | |
177 | if (len > 1 && fbuf[len-1] == '/') | |
21d7083a | 178 | @@ -1586,8 +1611,9 @@ static void clean_flist(struct file_list |
1cb60481 | 179 | } |
4a65fe72 WD |
180 | /* Make sure we don't lose track of a user-specified |
181 | * top directory. */ | |
1cb60481 WD |
182 | - flist->files[keep]->flags |= flist->files[drop]->flags |
183 | - & (FLAG_TOP_DIR|FLAG_DEL_HERE); | |
184 | + FFLAGS(flist->files[keep]) | |
185 | + |= FFLAGS(flist->files[drop]) | |
186 | + & (FLAG_TOP_DIR|FLAG_DEL_HERE); | |
187 | ||
4a65fe72 | 188 | clear_file(flist->files[drop], flist); |
1cb60481 | 189 | |
21d7083a | 190 | @@ -1711,7 +1737,7 @@ static void output_flist(struct file_lis |
1cb60481 WD |
191 | file->dirname ? file->dirname : "", |
192 | file->dirname ? "/" : "", NS(file->basename), | |
193 | S_ISDIR(file->mode) ? "/" : "", (int)file->mode, | |
194 | - (double)file->length, uidbuf, gidbuf, file->flags); | |
195 | + (double)file->length, uidbuf, gidbuf, FFLAGS(file)); | |
196 | } | |
197 | } | |
198 | ||
9a7eef96 WD |
199 | --- old/generator.c |
200 | +++ new/generator.c | |
195ca26e | 201 | @@ -43,6 +43,7 @@ extern int preserve_perms; |
55602791 | 202 | extern int preserve_uid; |
81c32ffd WD |
203 | extern int preserve_gid; |
204 | extern int preserve_times; | |
81c32ffd | 205 | +extern int preserve_atimes; |
55602791 | 206 | extern int omit_dir_times; |
4a65fe72 | 207 | extern int delete_mode; |
81c32ffd | 208 | extern int delete_before; |
3758a5a5 | 209 | @@ -90,6 +91,7 @@ extern dev_t filesystem_dev; |
1cb60481 WD |
210 | extern char *backup_dir; |
211 | extern char *backup_suffix; | |
212 | extern int backup_suffix_len; | |
213 | +extern unsigned int file_struct_len; | |
214 | extern struct file_list *the_file_list; | |
215 | extern struct filter_list_struct server_filter_list; | |
216 | ||
3758a5a5 | 217 | @@ -182,7 +184,7 @@ static int delete_item(char *fname, int |
1cb60481 WD |
218 | for (j = dirlist->count; j--; ) { |
219 | struct file_struct *fp = dirlist->files[j]; | |
220 | ||
221 | - if (fp->flags & FLAG_MOUNT_POINT) | |
222 | + if (FFLAGS(fp) & FLAG_MOUNT_POINT) | |
223 | continue; | |
224 | ||
225 | strlcpy(p, fp->basename, remainder); | |
3758a5a5 | 226 | @@ -260,7 +262,7 @@ static void delete_in_dir(struct file_li |
1cb60481 WD |
227 | filt_array[cur_depth] = push_local_filters(fbuf, dlen); |
228 | ||
229 | if (one_file_system) { | |
230 | - if (file->flags & FLAG_TOP_DIR) | |
231 | + if (FFLAGS(file) & FLAG_TOP_DIR) | |
232 | filesystem_dev = stp->st_dev; | |
233 | else if (filesystem_dev != stp->st_dev) | |
234 | return; | |
3758a5a5 | 235 | @@ -272,7 +274,7 @@ static void delete_in_dir(struct file_li |
1cb60481 WD |
236 | * from the filesystem. */ |
237 | for (i = dirlist->count; i--; ) { | |
238 | struct file_struct *fp = dirlist->files[i]; | |
239 | - if (!fp->basename || fp->flags & FLAG_MOUNT_POINT) | |
240 | + if (!fp->basename || FFLAGS(fp) & FLAG_MOUNT_POINT) | |
241 | continue; | |
242 | if (flist_find(flist, fp) < 0) { | |
4a65fe72 | 243 | f_name(fp, delbuf); |
3758a5a5 | 244 | @@ -298,11 +300,11 @@ static void do_delete_pass(struct file_l |
1cb60481 WD |
245 | for (j = 0; j < flist->count; j++) { |
246 | struct file_struct *file = flist->files[j]; | |
247 | ||
248 | - if (!(file->flags & FLAG_DEL_HERE)) | |
249 | + if (!(FFLAGS(file) & FLAG_DEL_HERE)) | |
250 | continue; | |
251 | ||
252 | f_name(file, fbuf); | |
253 | - if (verbose > 1 && file->flags & FLAG_TOP_DIR) | |
254 | + if (verbose > 1 && FFLAGS(file) & FLAG_TOP_DIR) | |
255 | rprintf(FINFO, "deleting in %s\n", fbuf); | |
256 | ||
257 | if (link_stat(fbuf, &st, keep_dirlinks) < 0 | |
3758a5a5 | 258 | @@ -346,6 +348,9 @@ void itemize(struct file_struct *file, i |
55602791 | 259 | && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname)) |
577db5e2 | 260 | || (keep_time && cmp_time(file->modtime, st->st_mtime) != 0)) |
f20eb450 | 261 | iflags |= ITEM_REPORT_TIME; |
55602791 WD |
262 | + if (preserve_atimes && !S_ISDIR(file->mode) && !S_ISLNK(file->mode) |
263 | + && cmp_time(file->atime, st->st_atime) != 0) | |
264 | + iflags |= ITEM_REPORT_ATIME; | |
7a56a8f1 | 265 | if ((file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS)) |
f20eb450 | 266 | iflags |= ITEM_REPORT_PERMS; |
7a56a8f1 | 267 | if (preserve_uid && am_root && file->uid != st->st_uid) |
3758a5a5 | 268 | @@ -549,7 +554,7 @@ static int find_fuzzy(struct file_struct |
1cb60481 WD |
269 | uint32 dist; |
270 | ||
271 | if (!S_ISREG(fp->mode) || !fp->length | |
272 | - || fp->flags & FLAG_NO_FUZZY) | |
273 | + || FFLAGS(fp) & FLAG_NO_FUZZY) | |
274 | continue; | |
275 | ||
81c32ffd | 276 | name = fp->basename; |
3758a5a5 | 277 | @@ -658,6 +663,8 @@ static int try_dests_reg(struct file_str |
8a04c9a7 WD |
278 | itemizing && verbose > 1, |
279 | code) < 0) | |
280 | goto try_a_copy; | |
281 | + if (preserve_atimes) | |
4a65fe72 | 282 | + set_file_attrs(fname, file, stp, 0); |
a6f0fb54 WD |
283 | if (preserve_hard_links && file->link_u.links) { |
284 | if (dry_run) | |
285 | file->link_u.links->link_dest_used = j + 1; | |
de565f59 WD |
286 | @@ -930,7 +937,7 @@ static void recv_generator(char *fname, |
287 | rsyserr(FERROR, errno, | |
288 | "recv_generator: mkdir %s failed", | |
289 | full_fname(fname)); | |
290 | - file->flags |= FLAG_MISSING; | |
291 | + FFLAGS(file) |= FLAG_MISSING; | |
292 | if (ndx+1 < the_file_list->count | |
293 | && the_file_list->files[ndx+1]->dir.depth > file->dir.depth) { | |
294 | rprintf(FERROR, | |
3758a5a5 WD |
295 | @@ -944,7 +951,7 @@ static void recv_generator(char *fname, |
296 | && verbose && code != FNONE && f_out != -1) | |
1cb60481 WD |
297 | rprintf(code, "%s/\n", fname); |
298 | if (delete_during && f_out != -1 && !phase && dry_run < 2 | |
299 | - && (file->flags & FLAG_DEL_HERE)) | |
300 | + && (FFLAGS(file) & FLAG_DEL_HERE)) | |
301 | delete_in_dir(the_file_list, fname, file, &st); | |
302 | return; | |
303 | } | |
03019e41 | 304 | @@ -1252,7 +1259,7 @@ static void recv_generator(char *fname, |
d9a67109 | 305 | if (fuzzy_dirlist) { |
1cb60481 WD |
306 | int j = flist_find(fuzzy_dirlist, file); |
307 | if (j >= 0) /* don't use changing file as future fuzzy basis */ | |
308 | - fuzzy_dirlist->files[j]->flags |= FLAG_NO_FUZZY; | |
309 | + FFLAGS(fuzzy_dirlist->files[j]) |= FLAG_NO_FUZZY; | |
310 | } | |
311 | ||
312 | /* open the file */ | |
03019e41 | 313 | @@ -1517,7 +1524,7 @@ void generate_files(int f_out, struct fi |
de565f59 WD |
314 | continue; |
315 | if (!need_retouch_dir_times && file->mode & S_IWUSR) | |
316 | continue; | |
317 | - if (file->flags & FLAG_MISSING) { | |
318 | + if (FFLAGS(file) & FLAG_MISSING) { | |
319 | int missing = file->dir.depth; | |
320 | while (++i < flist->count) { | |
321 | file = flist->files[i]; | |
9a7eef96 WD |
322 | --- old/hlink.c |
323 | +++ new/hlink.c | |
195ca26e WD |
324 | @@ -30,6 +30,7 @@ extern int make_backups; |
325 | extern int remove_source_files; | |
a859733e | 326 | extern int stdout_format_has_i; |
1cb60481 WD |
327 | extern char *basis_dir[]; |
328 | +extern unsigned int file_struct_len; | |
329 | extern struct file_list *the_file_list; | |
330 | ||
331 | #ifdef SUPPORT_HARD_LINKS | |
14e6c941 | 332 | @@ -91,10 +92,10 @@ static void link_idev_data(void) |
1cb60481 WD |
333 | FPTR(cur)->link_u.links = pool_talloc(hlink_pool, |
334 | struct hlink, 1, "hlink_list"); | |
335 | ||
336 | - FPTR(head)->flags |= FLAG_HLINK_TOL; | |
337 | + FFLAGS(FPTR(head)) |= FLAG_HLINK_TOL; | |
338 | FPTR(cur)->F_HLINDEX = to; | |
339 | FPTR(cur)->F_NEXT = head; | |
340 | - FPTR(cur)->flags |= FLAG_HLINK_EOL; | |
341 | + FFLAGS(FPTR(cur)) |= FLAG_HLINK_EOL; | |
14e6c941 | 342 | FPTR(cur)->link_u.links->link_dest_used = 0; |
1cb60481 WD |
343 | hlink_list[to++] = head; |
344 | } else | |
14e6c941 | 345 | @@ -181,7 +182,7 @@ int hard_link_check(struct file_struct * |
1cb60481 WD |
346 | { |
347 | #ifdef SUPPORT_HARD_LINKS | |
348 | int head; | |
349 | - if (skip && !(file->flags & FLAG_HLINK_EOL)) | |
350 | + if (skip && !(FFLAGS(file) & FLAG_HLINK_EOL)) | |
351 | head = hlink_list[file->F_HLINDEX] = file->F_NEXT; | |
352 | else | |
353 | head = hlink_list[file->F_HLINDEX]; | |
14e6c941 | 354 | @@ -289,8 +290,8 @@ void hard_link_cluster(struct file_struc |
1cb60481 WD |
355 | file->F_HLINDEX = FINISHED_LINK; |
356 | if (link_stat(f_name(file, hlink1), &st1, 0) < 0) | |
357 | return; | |
358 | - if (!(file->flags & FLAG_HLINK_TOL)) { | |
359 | - while (!(file->flags & FLAG_HLINK_EOL)) { | |
360 | + if (!(FFLAGS(file) & FLAG_HLINK_TOL)) { | |
361 | + while (!(FFLAGS(file) & FLAG_HLINK_EOL)) { | |
362 | ndx = file->F_NEXT; | |
363 | file = FPTR(ndx); | |
364 | } | |
14e6c941 | 365 | @@ -310,6 +311,6 @@ void hard_link_cluster(struct file_struc |
195ca26e WD |
366 | send_msg(MSG_SUCCESS, numbuf, 4); |
367 | } | |
1cb60481 WD |
368 | file->F_HLINDEX = FINISHED_LINK; |
369 | - } while (!(file->flags & FLAG_HLINK_EOL)); | |
370 | + } while (!(FFLAGS(file) & FLAG_HLINK_EOL)); | |
371 | #endif | |
372 | } | |
9a7eef96 WD |
373 | --- old/log.c |
374 | +++ new/log.c | |
b3593e7c | 375 | @@ -37,6 +37,7 @@ extern int msg_fd_out; |
577db5e2 | 376 | extern int allow_8bit_chars; |
81c32ffd WD |
377 | extern int protocol_version; |
378 | extern int preserve_times; | |
379 | +extern int preserve_atimes; | |
a859733e WD |
380 | extern int stdout_format_has_i; |
381 | extern int stdout_format_has_o_or_i; | |
21d7083a WD |
382 | extern int logfile_format_has_i; |
383 | @@ -606,7 +607,8 @@ static void log_formatted(enum logcode c | |
ccc3a12c WD |
384 | n[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p'; |
385 | n[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o'; | |
386 | n[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g'; | |
387 | - n[8] = '.'; | |
388 | + n[8] = !(iflags & ITEM_REPORT_ATIME) ? '.' | |
55602791 | 389 | + : S_ISLNK(file->mode) ? 'U' : 'u'; |
ccc3a12c | 390 | n[9] = '\0'; |
81c32ffd WD |
391 | |
392 | if (iflags & (ITEM_IS_NEW|ITEM_MISSING_DATA)) { | |
9a7eef96 WD |
393 | --- old/options.c |
394 | +++ new/options.c | |
b3593e7c | 395 | @@ -55,6 +55,7 @@ int preserve_uid = 0; |
43581f16 WD |
396 | int preserve_gid = 0; |
397 | int preserve_times = 0; | |
9a21ad72 | 398 | int omit_dir_times = 0; |
81c32ffd | 399 | +int preserve_atimes = 0; |
43581f16 WD |
400 | int update_only = 0; |
401 | int cvs_exclude = 0; | |
402 | int dry_run = 0; | |
03019e41 | 403 | @@ -311,8 +312,9 @@ void usage(enum logcode F) |
4a65fe72 WD |
404 | rprintf(F," --devices preserve device files (super-user only)\n"); |
405 | rprintf(F," --specials preserve special files\n"); | |
406 | rprintf(F," -D same as --devices --specials\n"); | |
81c32ffd WD |
407 | - rprintf(F," -t, --times preserve times\n"); |
408 | - rprintf(F," -O, --omit-dir-times omit directories when preserving times\n"); | |
409 | + rprintf(F," -t, --times preserve modify times\n"); | |
410 | + rprintf(F," -O, --omit-dir-times omit directories when preserving modify times\n"); | |
55602791 | 411 | + rprintf(F," -U, --atimes preserve access (use) times\n"); |
4a65fe72 | 412 | rprintf(F," --super receiver attempts super-user activities\n"); |
43581f16 WD |
413 | rprintf(F," -S, --sparse handle sparse files efficiently\n"); |
414 | rprintf(F," -n, --dry-run show what would have been transferred\n"); | |
03019e41 | 415 | @@ -428,6 +430,9 @@ static struct poptOption long_options[] |
489b0a72 WD |
416 | {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, |
417 | {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, | |
418 | {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, | |
55602791 | 419 | + {"atimes", 'U', POPT_ARG_VAL, &preserve_atimes, 1, 0, 0 }, |
489b0a72 | 420 | + {"no-atimes", 0, POPT_ARG_VAL, &preserve_atimes, 0, 0, 0 }, |
58070e2e | 421 | + {"no-k", 0, POPT_ARG_VAL, &preserve_atimes, 0, 0, 0 }, |
52f25864 | 422 | {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 2, 0, 0 }, |
489b0a72 | 423 | {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 }, |
4a65fe72 | 424 | {"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 }, |
03019e41 | 425 | @@ -1538,6 +1543,8 @@ void server_options(char **args,int *arg |
43581f16 WD |
426 | argstr[x++] = 'D'; |
427 | if (preserve_times) | |
428 | argstr[x++] = 't'; | |
81c32ffd | 429 | + if (preserve_atimes) |
55602791 | 430 | + argstr[x++] = 'U'; |
43581f16 | 431 | if (preserve_perms) |
4a65fe72 WD |
432 | argstr[x++] = 'p'; |
433 | else if (preserve_executability && am_sender) | |
9a7eef96 WD |
434 | --- old/rsync.c |
435 | +++ new/rsync.c | |
195ca26e WD |
436 | @@ -34,6 +34,7 @@ extern int verbose; |
437 | extern int dry_run; | |
d9a67109 | 438 | extern int preserve_perms; |
4a65fe72 | 439 | extern int preserve_executability; |
d9a67109 | 440 | +extern int preserve_atimes; |
43581f16 | 441 | extern int preserve_times; |
9a21ad72 | 442 | extern int omit_dir_times; |
43581f16 | 443 | extern int am_root; |
1ed0b5c9 | 444 | @@ -129,6 +130,7 @@ int set_file_attrs(char *fname, struct f |
9a21ad72 WD |
445 | int updated = 0; |
446 | STRUCT_STAT st2; | |
447 | int change_uid, change_gid; | |
448 | + time_t atime, mtime; | |
1ed0b5c9 | 449 | mode_t new_mode = file->mode; |
9a21ad72 WD |
450 | |
451 | if (!st) { | |
1ed0b5c9 | 452 | @@ -148,18 +150,33 @@ int set_file_attrs(char *fname, struct f |
7a56a8f1 | 453 | } |
8a04c9a7 | 454 | } |
9a21ad72 | 455 | |
8a04c9a7 WD |
456 | + /* This code must be the first update in the function due to |
457 | + * how it uses the "updated" variable. */ | |
9e355bf1 | 458 | if (!preserve_times || (S_ISDIR(st->st_mode) && omit_dir_times)) |
4a65fe72 | 459 | flags |= ATTRS_SKIP_MTIME; |
81c32ffd | 460 | + if (!preserve_atimes || S_ISDIR(st->st_mode)) |
4a65fe72 WD |
461 | + flags |= ATTRS_SKIP_ATIME; |
462 | if (!(flags & ATTRS_SKIP_MTIME) | |
577db5e2 | 463 | && cmp_time(st->st_mtime, file->modtime) != 0) { |
9e355bf1 | 464 | - int ret = set_modtime(fname, file->modtime, st->st_mode); |
9a21ad72 | 465 | + mtime = file->modtime; |
9e355bf1 | 466 | + updated = 1; |
9a21ad72 WD |
467 | + } else |
468 | + mtime = st->st_mtime; | |
4a65fe72 | 469 | + if (!(flags & ATTRS_SKIP_ATIME) |
81c32ffd WD |
470 | + && cmp_time(st->st_atime, file->atime) != 0) { |
471 | + atime = file->atime; | |
472 | + updated = 1; | |
473 | + } else | |
474 | + atime = st->st_atime; | |
9e355bf1 WD |
475 | + if (updated) { |
476 | + int ret = set_times(fname, mtime, atime, st->st_mode); | |
477 | if (ret < 0) { | |
478 | rsyserr(FERROR, errno, "failed to set times on %s", | |
479 | full_fname(fname)); | |
480 | return 0; | |
481 | } | |
482 | - if (ret == 0) /* ret == 1 if symlink could not be set */ | |
483 | - updated = 1; | |
484 | + if (ret > 0) /* ret == 1 if symlink could not be set */ | |
485 | + updated = 0; | |
43581f16 WD |
486 | } |
487 | ||
8a04c9a7 | 488 | change_uid = am_root && preserve_uid && st->st_uid != file->uid; |
9a7eef96 WD |
489 | --- old/rsync.h |
490 | +++ new/rsync.h | |
43581f16 WD |
491 | @@ -54,6 +54,7 @@ |
492 | #define XMIT_HAS_IDEV_DATA (1<<9) | |
493 | #define XMIT_SAME_DEV (1<<10) | |
494 | #define XMIT_RDEV_MINOR_IS_SMALL (1<<11) | |
495 | +#define XMIT_SAME_ATIME (1<<12) | |
496 | ||
497 | /* These flags are used in the live flist data. */ | |
498 | ||
195ca26e | 499 | @@ -120,6 +121,7 @@ |
8a529471 | 500 | |
4a65fe72 WD |
501 | #define ATTRS_REPORT (1<<0) |
502 | #define ATTRS_SKIP_MTIME (1<<1) | |
503 | +#define ATTRS_SKIP_ATIME (1<<2) | |
8a529471 WD |
504 | |
505 | #define FULL_FLUSH 1 | |
506 | #define NORMAL_FLUSH 0 | |
a6f0fb54 | 507 | @@ -530,9 +532,12 @@ struct file_struct { |
8a04c9a7 WD |
508 | uid_t uid; |
509 | gid_t gid; | |
43581f16 | 510 | mode_t mode; |
55602791 | 511 | - uchar flags; /* this item MUST remain last */ |
1cb60481 | 512 | + time_t atime; /* this MUST be second to last */ |
55602791 | 513 | + uchar fl4g5; /* this item MUST remain last */ |
1cb60481 WD |
514 | }; |
515 | ||
516 | +#define FFLAGS(f) ((uchar*)(f))[file_struct_len-1] | |
517 | + | |
518 | /* | |
519 | * Start the flist array at FLIST_START entries and grow it | |
520 | * by doubling until FLIST_LINEAR then grow by FLIST_LINEAR | |
9a7eef96 WD |
521 | --- old/rsync.yo |
522 | +++ new/rsync.yo | |
03019e41 | 523 | @@ -328,8 +328,9 @@ to the detailed description below for a |
4a65fe72 WD |
524 | --devices preserve device files (super-user only) |
525 | --specials preserve special files | |
526 | -D same as --devices --specials | |
81c32ffd | 527 | - -t, --times preserve times |
610969d1 | 528 | - -O, --omit-dir-times omit directories when preserving times |
81c32ffd | 529 | + -t, --times preserve modify times |
610969d1 | 530 | + -O, --omit-dir-times omit directories when preserving mod-times |
55602791 | 531 | + -U, --atimes preserve access (use) times |
4a65fe72 | 532 | --super receiver attempts super-user activities |
43581f16 WD |
533 | -S, --sparse handle sparse files efficiently |
534 | -n, --dry-run show what would have been transferred | |
03019e41 | 535 | @@ -869,6 +870,12 @@ it is preserving modification times (see |
a7219d20 | 536 | the directories on the receiving side, it is a good idea to use bf(-O). |
333b8af4 | 537 | This option is inferred if you use bf(--backup) without bf(--backup-dir). |
7b675ff5 | 538 | |
55602791 WD |
539 | +dit(bf(-U, --atimes)) This tells rsync to set the access (use) times of the |
540 | +destination files to the same value as the source files. Note that the | |
81c32ffd WD |
541 | +reading of the source file may update the atime of the source files, so |
542 | +repeated rsync runs with --atimes may be needed if you want to force the | |
543 | +access-time values to be 100% identical on the two systems. | |
7b675ff5 | 544 | + |
4a65fe72 WD |
545 | dit(bf(--super)) This tells the receiving side to attempt super-user |
546 | activities even if the receiving rsync wasn't run by the super-user. These | |
547 | activities include: preserving users via the bf(--owner) option, preserving | |
03019e41 | 548 | @@ -1390,7 +1397,7 @@ with older versions of rsync, but that a |
4a65fe72 WD |
549 | verbose messages). |
550 | ||
ccc3a12c WD |
551 | The "%i" escape has a cryptic output that is 9 letters long. The general |
552 | -format is like the string bf(YXcstpogz), where bf(Y) is replaced by the | |
553 | +format is like the string bf(YXcstpogu), where bf(Y) is replaced by the | |
554 | type of update being done, bf(X) is replaced by the file-type, and the | |
4a65fe72 WD |
555 | other letters represent attributes that may be output if they are being |
556 | modified. | |
03019e41 | 557 | @@ -1430,7 +1437,7 @@ quote(itemization( |
81c32ffd WD |
558 | by the file transfer. |
559 | it() A bf(t) means the modification time is different and is being updated | |
560 | to the sender's value (requires bf(--times)). An alternate value of bf(T) | |
561 | - means that the time will be set to the transfer time, which happens | |
562 | + means that the modify time will be set to the transfer time, which happens | |
563 | anytime a symlink is transferred, or when a file or device is transferred | |
564 | without bf(--times). | |
ccc3a12c | 565 | it() A bf(p) means the permissions are different and are being updated to |
03019e41 | 566 | @@ -1439,7 +1446,10 @@ quote(itemization( |
ccc3a12c WD |
567 | sender's value (requires bf(--owner) and super-user privileges). |
568 | it() A bf(g) means the group is different and is being updated to the | |
569 | sender's value (requires bf(--group) and the authority to set the group). | |
570 | - it() The bf(z) slot is reserved for future use. | |
55602791 WD |
571 | + it() A bf(u) means the access (use) time is different and is being updated to |
572 | + the sender's value (requires bf(--atimes)). An alternate value of bf(U) | |
573 | + means that the access time will be set to the transfer time, which happens | |
ccc3a12c WD |
574 | + when a symlink or directory is updated. |
575 | )) | |
576 | ||
577 | One other output is possible: when deleting files, the "%i" will output | |
9a7eef96 WD |
578 | --- old/sender.c |
579 | +++ new/sender.c | |
b3593e7c | 580 | @@ -41,6 +41,7 @@ extern int do_progress; |
1cb60481 WD |
581 | extern int inplace; |
582 | extern int batch_fd; | |
583 | extern int write_batch; | |
584 | +extern unsigned int file_struct_len; | |
585 | extern struct stats stats; | |
586 | extern struct file_list *the_file_list; | |
a859733e | 587 | extern char *stdout_format; |
1ed0b5c9 | 588 | @@ -373,7 +374,7 @@ void send_files(struct file_list *flist, |
1cb60481 WD |
589 | rprintf(FINFO, "sender finished %s\n", fname); |
590 | ||
591 | /* Flag that we actually sent this entry. */ | |
592 | - file->flags |= FLAG_SENT; | |
593 | + FFLAGS(file) |= FLAG_SENT; | |
594 | } | |
595 | make_backups = save_make_backups; | |
596 | ||
9a7eef96 WD |
597 | --- old/testsuite/atimes.test |
598 | +++ new/testsuite/atimes.test | |
13bed3dd WD |
599 | @@ -0,0 +1,19 @@ |
600 | +#! /bin/sh | |
601 | + | |
602 | +# Test rsync copying atimes | |
603 | + | |
604 | +. "$suitedir/rsync.fns" | |
605 | + | |
606 | +set -x | |
607 | + | |
608 | +mkdir "$fromdir" | |
609 | + | |
610 | +touch "$fromdir/foo" | |
611 | +touch -a -t 200102031717.42 "$fromdir/foo" | |
612 | + | |
613 | +TLS_ARGS=--atime | |
614 | + | |
55602791 | 615 | +checkit "$RSYNC -rtUgvvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" |
13bed3dd WD |
616 | + |
617 | +# The script would have aborted on error, so getting here means we've won. | |
618 | +exit 0 | |
9a7eef96 WD |
619 | --- old/testsuite/rsync.fns |
620 | +++ new/testsuite/rsync.fns | |
7a56a8f1 WD |
621 | @@ -66,7 +66,7 @@ printmsg() { |
622 | } | |
13bed3dd WD |
623 | |
624 | rsync_ls_lR() { | |
b78a6aba WD |
625 | - find "$@" -print | sort | sed 's/ /\\ /g' | xargs "$TOOLDIR/tls" |
626 | + find "$@" -print | sort | sed 's/ /\\ /g' | xargs "$TOOLDIR/tls" $TLS_ARGS | |
13bed3dd WD |
627 | } |
628 | ||
7a56a8f1 WD |
629 | check_perms() { |
630 | @@ -184,6 +184,10 @@ checkit() { | |
13bed3dd WD |
631 | # We can just write everything to stdout/stderr, because the |
632 | # wrapper hides it unless there is a problem. | |
633 | ||
81c32ffd WD |
634 | + if test x$TLS_ARGS = x--atime; then |
635 | + ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from" | |
636 | + fi | |
13bed3dd WD |
637 | + |
638 | echo "Running: \"$1\"" | |
639 | eval "$1" | |
640 | status=$? | |
7a56a8f1 | 641 | @@ -191,10 +195,13 @@ checkit() { |
81c32ffd WD |
642 | failed="YES"; |
643 | fi | |
644 | ||
645 | + if test x$TLS_ARGS != x--atime; then | |
646 | + ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from" | |
647 | + fi | |
648 | + | |
13bed3dd | 649 | echo "-------------" |
b78a6aba WD |
650 | echo "check how the directory listings compare with diff:" |
651 | echo "" | |
13bed3dd | 652 | - ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from" |
b78a6aba WD |
653 | ( cd "$3" && rsync_ls_lR . ) > "$tmpdir/ls-to" |
654 | diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to" || failed=YES | |
4da25dad | 655 | |
9a7eef96 WD |
656 | --- old/tls.c |
657 | +++ new/tls.c | |
b3593e7c WD |
658 | @@ -34,6 +34,7 @@ |
659 | * change. */ | |
43581f16 WD |
660 | |
661 | #include "rsync.h" | |
662 | +#include "popt.h" | |
663 | ||
664 | #define PROGRAM "tls" | |
665 | ||
b3593e7c | 666 | @@ -43,6 +44,8 @@ int read_only = 1; |
43581f16 WD |
667 | int list_only = 0; |
668 | int preserve_perms = 0; | |
669 | ||
670 | +static int display_atime = 0; | |
b3593e7c | 671 | + |
fe6407b5 WD |
672 | static void failed(char const *what, char const *where) |
673 | { | |
b3593e7c WD |
674 | fprintf(stderr, PROGRAM ": %s %s: %s\n", |
675 | @@ -50,12 +53,29 @@ static void failed(char const *what, cha | |
fe6407b5 | 676 | exit(1); |
43581f16 WD |
677 | } |
678 | ||
3f053c45 | 679 | +static void storetime(char *dest, time_t t, size_t destsize) |
43581f16 WD |
680 | +{ |
681 | + if (t) { | |
682 | + struct tm *mt = gmtime(&t); | |
b3593e7c | 683 | + |
3f053c45 WD |
684 | + snprintf(dest, destsize, |
685 | + "%04d-%02d-%02d %02d:%02d:%02d ", | |
9d95bd65 WD |
686 | + (int)mt->tm_year + 1900, |
687 | + (int)mt->tm_mon + 1, | |
688 | + (int)mt->tm_mday, | |
689 | + (int)mt->tm_hour, | |
690 | + (int)mt->tm_min, | |
691 | + (int)mt->tm_sec); | |
3f053c45 WD |
692 | + } else |
693 | + strlcpy(dest, " ", destsize); | |
b3593e7c WD |
694 | +} |
695 | + | |
fe6407b5 | 696 | static void list_file(const char *fname) |
43581f16 WD |
697 | { |
698 | STRUCT_STAT buf; | |
699 | char permbuf[PERMSTRING_SIZE]; | |
700 | - struct tm *mt; | |
701 | - char datebuf[50]; | |
702 | + char mtimebuf[50]; | |
703 | + char atimebuf[50]; | |
704 | char linkbuf[4096]; | |
705 | ||
ba50e96c | 706 | if (do_lstat(fname, &buf) < 0) |
b3593e7c | 707 | @@ -88,19 +108,8 @@ static void list_file(const char *fname) |
43581f16 WD |
708 | |
709 | permstring(permbuf, buf.st_mode); | |
710 | ||
711 | - if (buf.st_mtime) { | |
712 | - mt = gmtime(&buf.st_mtime); | |
713 | - | |
3f053c45 WD |
714 | - snprintf(datebuf, sizeof datebuf, |
715 | - "%04d-%02d-%02d %02d:%02d:%02d", | |
9d95bd65 WD |
716 | - (int)mt->tm_year + 1900, |
717 | - (int)mt->tm_mon + 1, | |
718 | - (int)mt->tm_mday, | |
719 | - (int)mt->tm_hour, | |
720 | - (int)mt->tm_min, | |
721 | - (int)mt->tm_sec); | |
3f053c45 WD |
722 | - } else |
723 | - strlcpy(datebuf, " ", sizeof datebuf); | |
724 | + storetime(mtimebuf, buf.st_mtime, sizeof mtimebuf); | |
725 | + storetime(atimebuf, buf.st_atime, sizeof atimebuf); | |
43581f16 WD |
726 | |
727 | /* TODO: Perhaps escape special characters in fname? */ | |
728 | ||
b3593e7c | 729 | @@ -111,23 +120,55 @@ static void list_file(const char *fname) |
43581f16 WD |
730 | (long)minor(buf.st_rdev)); |
731 | } else /* NB: use double for size since it might not fit in a long. */ | |
732 | printf("%12.0f", (double)buf.st_size); | |
733 | - printf(" %6ld.%-6ld %6ld %s %s%s\n", | |
734 | + printf(" %6ld.%-6ld %6ld %s%s%s%s\n", | |
735 | (long)buf.st_uid, (long)buf.st_gid, (long)buf.st_nlink, | |
736 | - datebuf, fname, linkbuf); | |
c0be1af2 | 737 | + mtimebuf, display_atime && !S_ISDIR(buf.st_mode) ? atimebuf : "", |
43581f16 | 738 | + fname, linkbuf); |
b3593e7c WD |
739 | +} |
740 | + | |
43581f16 WD |
741 | +static struct poptOption long_options[] = { |
742 | + /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ | |
743 | + {"atime", 'u', POPT_ARG_NONE, &display_atime, 0, 0, 0}, | |
744 | + {"help", 'h', POPT_ARG_NONE, 0, 'h', 0, 0}, | |
745 | + {0,0,0,0,0,0,0} | |
746 | +}; | |
747 | + | |
748 | +static void tls_usage(int ret) | |
749 | +{ | |
750 | + fprintf(stderr, "usage: " PROGRAM " [--atime | -u] DIR ...\n" | |
751 | + "Trivial file listing program for portably checking rsync\n"); | |
752 | + exit(ret); | |
b3593e7c | 753 | } |
43581f16 WD |
754 | |
755 | int | |
756 | main(int argc, char *argv[]) | |
757 | { | |
758 | - if (argc < 2) { | |
fe6407b5 WD |
759 | - fprintf(stderr, "usage: " PROGRAM " DIR ...\n" |
760 | - "Trivial file listing program for portably checking rsync\n"); | |
43581f16 | 761 | - return 1; |
03019e41 | 762 | - } |
43581f16 WD |
763 | + poptContext pc; |
764 | + const char **extra_args; | |
765 | + int opt; | |
03019e41 WD |
766 | |
767 | - for (argv++; *argv; argv++) { | |
768 | - list_file(*argv); | |
43581f16 WD |
769 | + pc = poptGetContext(PROGRAM, argc, (const char **)argv, |
770 | + long_options, 0); | |
771 | + while ((opt = poptGetNextOpt(pc)) != -1) { | |
772 | + switch (opt) { | |
773 | + case 'h': | |
774 | + tls_usage(0); | |
775 | + default: | |
776 | + fprintf(stderr, | |
777 | + "%s: %s\n", | |
778 | + poptBadOption(pc, POPT_BADOPTION_NOALIAS), | |
779 | + poptStrerror(opt)); | |
780 | + tls_usage(1); | |
781 | + } | |
782 | } | |
783 | ||
43581f16 WD |
784 | + extra_args = poptGetArgs(pc); |
785 | + if (*extra_args == NULL) | |
786 | + tls_usage(1); | |
787 | + | |
788 | + for (; *extra_args; extra_args++) | |
789 | + list_file(*extra_args); | |
790 | + poptFreeContext(pc); | |
03019e41 | 791 | + |
43581f16 WD |
792 | return 0; |
793 | } | |
9a7eef96 WD |
794 | --- old/util.c |
795 | +++ new/util.c | |
3758a5a5 | 796 | @@ -121,7 +121,7 @@ NORETURN void overflow_exit(char *str) |
577db5e2 WD |
797 | exit_cleanup(RERR_MALLOC); |
798 | } | |
43581f16 | 799 | |
9e355bf1 WD |
800 | -int set_modtime(char *fname, time_t modtime, mode_t mode) |
801 | +int set_times(char *fname, time_t modtime, time_t atime, mode_t mode) | |
43581f16 | 802 | { |
9e355bf1 WD |
803 | #if !defined HAVE_LUTIMES || !defined HAVE_UTIMES |
804 | if (S_ISLNK(mode)) | |
a859733e | 805 | @@ -129,9 +129,13 @@ int set_modtime(char *fname, time_t modt |
9e355bf1 WD |
806 | #endif |
807 | ||
43581f16 WD |
808 | if (verbose > 2) { |
809 | - rprintf(FINFO, "set modtime of %s to (%ld) %s", | |
810 | + char mtimebuf[200]; | |
43581f16 | 811 | + |
125d7fca | 812 | + strlcpy(mtimebuf, timestring(modtime), sizeof mtimebuf); |
43581f16 WD |
813 | + rprintf(FINFO, |
814 | + "set modtime, atime of %s to (%ld) %s, (%ld) %s\n", | |
93ca4d27 | 815 | fname, (long)modtime, |
43581f16 | 816 | - asctime(localtime(&modtime))); |
9e355bf1 | 817 | + mtimebuf, (long)atime, timestring(atime)); |
43581f16 WD |
818 | } |
819 | ||
ba50e96c | 820 | if (dry_run) |
a859733e | 821 | @@ -140,7 +144,7 @@ int set_modtime(char *fname, time_t modt |
43581f16 | 822 | { |
9e355bf1 WD |
823 | #ifdef HAVE_UTIMES |
824 | struct timeval t[2]; | |
825 | - t[0].tv_sec = time(NULL); | |
826 | + t[0].tv_sec = atime; | |
827 | t[0].tv_usec = 0; | |
828 | t[1].tv_sec = modtime; | |
829 | t[1].tv_usec = 0; | |
a859733e | 830 | @@ -151,12 +155,12 @@ int set_modtime(char *fname, time_t modt |
9e355bf1 WD |
831 | return utimes(fname, t); |
832 | #elif defined HAVE_UTIMBUF | |
43581f16 WD |
833 | struct utimbuf tbuf; |
834 | - tbuf.actime = time(NULL); | |
835 | + tbuf.actime = atime; | |
836 | tbuf.modtime = modtime; | |
837 | return utime(fname,&tbuf); | |
09fb8f03 | 838 | #elif defined HAVE_UTIME |
43581f16 WD |
839 | time_t t[2]; |
840 | - t[0] = time(NULL); | |
841 | + t[0] = atime; | |
842 | t[1] = modtime; | |
843 | return utime(fname,t); | |
844 | #else |