From: Wayne Davison Date: Sat, 2 Oct 2021 17:16:58 +0000 (-0700) Subject: Enable --atimes on macOS. X-Git-Tag: v3.2.4pre1~45 X-Git-Url: http://git.samba.org/?p=rsync.git;a=commitdiff_plain;h=78b5bc66290aa24c69966110421a005faa37a625 Enable --atimes on macOS. --- diff --git a/NEWS.md b/NEWS.md index 5e93ce11..74c3edfc 100644 --- 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 4303c2a7..c98f7b40 100644 --- 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 f8fcbffb..1fe4a12f 100644 --- 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 diff --git a/syscall.c b/syscall.c index fe79fe01..abb00575 100644 --- 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)