Enable --atimes on macOS.
authorWayne Davison <wayne@opencoder.net>
Sat, 2 Oct 2021 17:16:58 +0000 (10:16 -0700)
committerWayne Davison <wayne@opencoder.net>
Sat, 2 Oct 2021 22:23:30 +0000 (15:23 -0700)
NEWS.md
acls.c
rsync.h
syscall.c

diff --git a/NEWS.md b/NEWS.md
index 5e93ce1131a8922ca82d2bd4157efb79d5eff815..74c3edfceefb6bfff677bb1c6821f4289279a592 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -51,6 +51,8 @@
  - Reduced memory usage for an incremental transfer that has a bunch of small
    diretories.
 
+ - Add support for `--atimes` on macOS.
+
  - Rsync can now update the xattrs on a read-only file when your user can
    temporarily add user-write permission to the file. (It always worked for a
    root transfer.)
diff --git a/acls.c b/acls.c
index 4303c2a744837d04696bb3298313def7c77db2ff..c98f7b40be7083a95ec6b4a246db4499fc72290e 100644 (file)
--- a/acls.c
+++ b/acls.c
@@ -763,6 +763,7 @@ static int recv_rsync_acl(int f, item_list *racl_list, SMB_ACL_TYPE_T type, mode
 #ifdef HAVE_OSX_ACLS
        /* If we received a superfluous mask, throw it away. */
        duo_item->racl.mask_obj = NO_ENTRY;
+       (void)mode;
 #else
        if (duo_item->racl.names.count && duo_item->racl.mask_obj == NO_ENTRY) {
                /* Mask must be non-empty with lists. */
diff --git a/rsync.h b/rsync.h
index f8fcbffbda53f29f29b8216b7cf3df0d1ed3334b..1fe4a12fcee8333f48046c3a6af57db5a2b9abe7 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -584,7 +584,7 @@ typedef unsigned int size_t;
 #endif
 #endif
 
-#ifndef __APPLE__ /* Do we need a configure check for this? */
+#if !defined __APPLE__ || defined HAVE_GETATTRLIST
 #define SUPPORT_ATIMES 1
 #endif
 
index fe79fe014fe4c5d6f2744c8bf3f56d2f0609c871..abb0057546935fb21df7ae8c3205ae1fb22dbb66 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -388,18 +388,22 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
 int do_setattrlist_times(const char *fname, STRUCT_STAT *stp)
 {
        struct attrlist attrList;
-       struct timespec ts;
+       struct timespec ts[2];
 
        if (dry_run) return 0;
        RETURN_ERROR_IF_RO_OR_LO;
 
-       ts.tv_sec = stp->st_mtime;
-       ts.tv_nsec = stp->ST_MTIME_NSEC;
+       /* Yes, this is in the opposite order of utime and similar. */
+       ts[0].tv_sec = stp->st_mtime;
+       ts[0].tv_nsec = stp->ST_MTIME_NSEC;
+
+       ts[1].tv_sec = stp->st_atime;
+       ts[1].tv_nsec = stp->ST_ATIME_NSEC;
 
        memset(&attrList, 0, sizeof attrList);
        attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
-       attrList.commonattr = ATTR_CMN_MODTIME;
-       return setattrlist(fname, &attrList, &ts, sizeof ts, FSOPT_NOFOLLOW);
+       attrList.commonattr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME;
+       return setattrlist(fname, &attrList, ts, sizeof ts, FSOPT_NOFOLLOW);
 }
 #endif
 
@@ -465,7 +469,7 @@ int set_create_time(const char *path, time_t crtime)
 #endif
     }
 }
-#endif
+#endif /* SUPPORT_CRTIMES */
 
 #ifdef HAVE_UTIMENSAT
 int do_utimensat(const char *fname, STRUCT_STAT *stp)