-@@ -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) {
-@@ -1594,8 +1621,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);
-
+@@ -883,6 +907,8 @@ static struct file_struct *recv_file_ent
+ F_GROUP(file) = gid;
+ file->flags |= gid_flags;
+ }
++ if (atimes_ndx)
++ F_ATIME(file) = (time_t)atime;
+ #ifdef ICONV_OPTION
+ if (ic_ndx)
+ F_NDX(file) = flist->used + flist->ndx_start;
+@@ -1198,6 +1224,8 @@ struct file_struct *make_file(const char
+ F_OWNER(file) = st.st_uid;
+ if (gid_ndx)
+ F_GROUP(file) = st.st_gid;
++ if (atimes_ndx)
++ F_ATIME(file) = st.st_atime;
+
+ if (basename != thisname)
+ file->dirname = lastdir;