summaryrefslogtreecommitdiff
path: root/syscall.c
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2021-10-10 11:45:14 -0700
committerWayne Davison <wayne@opencoder.net>2021-10-10 12:43:11 -0700
commit296352ecb0175fa3c37de550dd57aeff39632095 (patch)
treee58ac282baece4520265699b155b2c97c3496042 /syscall.c
parent11a9b623226ef2324985958c3416d2bae5a3b7f3 (diff)
downloadrsync-296352ecb0175fa3c37de550dd57aeff39632095.tar.gz
Tweak atime/crtime code a bit more.
Diffstat (limited to 'syscall.c')
-rw-r--r--syscall.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/syscall.c b/syscall.c
index 80a9a2f6..56948a83 100644
--- a/syscall.c
+++ b/syscall.c
@@ -233,8 +233,10 @@ int do_chmod(const char *path, mode_t mode)
{
static int switch_step = 0;
int code;
+
if (dry_run) return 0;
RETURN_ERROR_IF_RO_OR_LO;
+
switch (switch_step) {
#ifdef HAVE_LCHMOD
case 0:
@@ -415,7 +417,26 @@ int do_setattrlist_times(const char *path, STRUCT_STAT *stp)
attrList.commonattr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME;
return setattrlist(path, &attrList, ts, sizeof ts, FSOPT_NOFOLLOW);
}
+
+#ifdef SUPPORT_CRTIMES
+int do_setattrlist_crtime(const char *path, time_t crtime)
+{
+ struct attrlist attrList;
+ struct timespec ts;
+
+ if (dry_run) return 0;
+ RETURN_ERROR_IF_RO_OR_LO;
+
+ ts.tv_sec = crtime;
+ ts.tv_nsec = 0;
+
+ memset(&attrList, 0, sizeof attrList);
+ attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
+ attrList.commonattr = ATTR_CMN_CRTIME;
+ return setattrlist(path, &attrList, &ts, sizeof ts, FSOPT_NOFOLLOW);
+}
#endif
+#endif /* HAVE_SETATTRLIST */
#ifdef SUPPORT_CRTIMES
time_t get_create_time(const char *path, STRUCT_STAT *stp)
@@ -439,24 +460,12 @@ time_t get_create_time(const char *path, STRUCT_STAT *stp)
#endif
}
-int set_create_time(const char *path, time_t crtime)
+#if defined __CYGWIN__
+int do_SetFileTime(const char *path, time_t crtime)
{
if (dry_run) return 0;
RETURN_ERROR_IF_RO_OR_LO;
- {
-#ifdef HAVE_GETATTRLIST
- struct attrlist attrList;
- struct timespec ts;
-
- ts.tv_sec = crtime;
- ts.tv_nsec = 0;
-
- memset(&attrList, 0, sizeof attrList);
- attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
- attrList.commonattr = ATTR_CMN_CRTIME;
- return setattrlist(path, &attrList, &ts, sizeof ts, FSOPT_NOFOLLOW);
-#elif defined __CYGWIN__
int cnt = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
if (cnt == 0)
return -1;
@@ -476,9 +485,8 @@ int set_create_time(const char *path, time_t crtime)
int ok = SetFileTime(handle, &birth_time, NULL, NULL);
CloseHandle(handle);
return ok ? 0 : -1;
-#endif
- }
}
+#endif
#endif /* SUPPORT_CRTIMES */
#ifdef HAVE_UTIMENSAT