-@@ -600,19 +618,23 @@ static struct file_struct *receive_file_
-
- sum_len = always_checksum && S_ISREG(mode) ? MD4_SUM_LENGTH : 0;
-
-+ atime_len = preserve_atimes ? 4 : 0;
-+
- alloc_len = file_struct_len + dirname_len + basename_len
-- + linkname_len + sum_len;
-+ + atime_len + linkname_len + sum_len;
- bp = pool_alloc(flist->file_pool, alloc_len, "receive_file_entry");
-
- file = (struct file_struct *)bp;
- memset(bp, 0, file_struct_len);
-- bp += file_struct_len;
-+ bp += file_struct_len + atime_len;
-
- file->modtime = modtime;
- file->length = file_length;
- file->mode = mode;
- file->uid = uid;
- file->gid = gid;
-+ if (preserve_atimes)
-+ SIVAL(ATIME_PTR(file), 0, atime);
-
- if (dirname_len) {
- file->dirname = lastdir = bp;
-@@ -731,6 +753,7 @@ struct file_struct *make_file(char *fnam
- char thisname[MAXPATHLEN];
- char linkname[MAXPATHLEN];
- int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
-+ int atime_len;
- char *basename, *dirname, *bp;
-
- if (!flist || !flist->count) /* Ignore lastdir when invalid. */
-@@ -854,8 +877,10 @@ struct file_struct *make_file(char *fnam
- sum_len = always_checksum && am_sender && S_ISREG(st.st_mode)
- ? MD4_SUM_LENGTH : 0;
-
-+ atime_len = preserve_atimes ? 4 : 0;
-+
- alloc_len = file_struct_len + dirname_len + basename_len
-- + linkname_len + sum_len;
-+ + atime_len + linkname_len + sum_len;
- if (flist)
- bp = pool_alloc(flist->file_pool, alloc_len, "make_file");
- else {
-@@ -865,7 +890,7 @@ struct file_struct *make_file(char *fnam
-
- file = (struct file_struct *)bp;
- memset(bp, 0, file_struct_len);
-- bp += file_struct_len;
-+ bp += file_struct_len + atime_len;
-
- file->flags = flags;
- file->modtime = st.st_mtime;
-@@ -873,6 +898,8 @@ struct file_struct *make_file(char *fnam
- file->mode = st.st_mode;
- file->uid = st.st_uid;
- file->gid = st.st_gid;
-+ if (preserve_atimes)
-+ SIVAL(ATIME_PTR(file), 0, st.st_atime);
-
- #ifdef SUPPORT_HARD_LINKS
- if (flist && flist->hlink_pool) {
-@@ -1595,8 +1622,9 @@ static void clean_flist(struct file_list
- }
- /* Make sure we don't lose track of a user-specified
- * top directory. */
-- flist->files[keep]->flags |= flist->files[drop]->flags
-- & (FLAG_TOP_DIR|FLAG_DEL_HERE);
-+ flist->files[keep]->flags
-+ |= flist->files[drop]->flags
-+ & (FLAG_TOP_DIR|FLAG_DEL_HERE);
-
- clear_file(flist->files[drop], flist);
-
---- old/generator.c
-+++ new/generator.c
-@@ -43,6 +43,7 @@ extern int preserve_perms;
- extern int preserve_uid;
- extern int preserve_gid;
- extern int preserve_times;
-+extern int preserve_atimes;
- extern int omit_dir_times;
- extern int delete_mode;
- extern int delete_before;
-@@ -90,6 +91,7 @@ extern dev_t filesystem_dev;
- extern char *backup_dir;
- extern char *backup_suffix;
- extern int backup_suffix_len;
-+extern unsigned int file_struct_len;
- extern struct file_list *the_file_list;
- extern struct filter_list_struct server_filter_list;
-
-@@ -409,6 +411,9 @@ void itemize(struct file_struct *file, i
+@@ -981,6 +1001,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+ F_GROUP(file) = gid;
+ file->flags |= gid_flags;
+ }
++ if (atimes_ndx)
++ f_atime_set(file, (time_t)atime);
+ if (unsort_ndx)
+ F_NDX(file) = flist->used + flist->ndx_start;
+
+@@ -1376,6 +1398,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+ F_OWNER(file) = st.st_uid;
+ if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
+ F_GROUP(file) = st.st_gid;
++ if (atimes_ndx)
++ f_atime_set(file, st.st_atime);
+
+ if (basename != thisname)
+ file->dirname = lastdir;
+diff --git a/generator.c b/generator.c
+--- a/generator.c
++++ b/generator.c
+@@ -454,6 +454,9 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
+ : iflags & (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) && !(iflags & ITEM_MATCHED)