popt/popthelp.o popt/poptparse.o
OBJS=$(OBJS1) $(OBJS2) $(OBJS3) @SIMD@ $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ @BUILD_POPT@
-TLS_OBJ = tls.o syscall.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
+TLS_OBJ = tls.o syscall.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
# Programs we must have to run the test cases
CHECK_PROGS = rsync$(EXEEXT) tls$(EXEEXT) getgroups$(EXEEXT) getfsdev$(EXEEXT) \
getfsdev$(EXEEXT): getfsdev.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ getfsdev.o $(LIBS)
-TRIMSLASH_OBJ = trimslash.o syscall.o t_stub.o lib/compat.o lib/snprintf.o
+TRIMSLASH_OBJ = trimslash.o syscall.o util2.o t_stub.o lib/compat.o lib/snprintf.o
trimslash$(EXEEXT): $(TRIMSLASH_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TRIMSLASH_OBJ) $(LIBS)
#ifdef SUPPORT_CRTIMES
if (!differs && crtimes_ndx) {
if (sxp->crtime == 0)
- sxp->crtime = get_create_time(fname);
+ sxp->crtime = get_create_time(fname, &sxp->st);
differs = !same_time(sxp->crtime, 0, F_CRTIME(file), 0);
}
#endif
#ifdef SUPPORT_CRTIMES
if (crtimes_ndx) {
if (sxp->crtime == 0)
- sxp->crtime = get_create_time(fnamecmp);
+ sxp->crtime = get_create_time(fnamecmp, &sxp->st);
if (!same_time(sxp->crtime, 0, F_CRTIME(file), 0))
iflags |= ITEM_REPORT_CRTIME;
}
if (crtimes_ndx && !(flags & ATTRS_SKIP_CRTIME)) {
time_t file_crtime = F_CRTIME(file);
if (sxp->crtime == 0)
- sxp->crtime = get_create_time(fname);
+ sxp->crtime = get_create_time(fname, &sxp->st);
if (!same_time(sxp->crtime, 0L, file_crtime, 0L)
&& set_create_time(fname, file_crtime) == 0)
updated = 1;
#endif
#ifdef SUPPORT_CRTIMES
+#ifdef HAVE_GETATTRLIST
#pragma pack(push, 4)
struct create_time {
uint32 length;
struct timespec crtime;
};
#pragma pack(pop)
+#elif defined __CYGWIN__
+#include <windows.h>
+#endif
#endif
#define RETURN_ERROR_IF(x,e) \
#endif
#ifdef SUPPORT_CRTIMES
-time_t get_create_time(const char *path)
+time_t get_create_time(const char *path, STRUCT_STAT *stp)
{
+#ifdef HAVE_GETATTRLIST
static struct create_time attrBuf;
struct attrlist attrList;
+ (void)stp;
memset(&attrList, 0, sizeof attrList);
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.commonattr = ATTR_CMN_CRTIME;
if (getattrlist(path, &attrList, &attrBuf, sizeof attrBuf, FSOPT_NOFOLLOW) < 0)
return 0;
return attrBuf.crtime.tv_sec;
-}
+#elif defined __CYGWIN__
+ (void)path;
+ return stp->st_birthtime;
+#else
+#error Unknown crtimes implementation
#endif
+}
-#ifdef SUPPORT_CRTIMES
int set_create_time(const char *path, time_t crtime)
{
+#ifdef HAVE_GETATTRLIST
struct attrlist attrList;
struct timespec ts;
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;
+ WCHAR *pathw = new_array(WCHAR, cnt);
+ if (!pathw)
+ return -1;
+ MultiByteToWideChar(CP_UTF8, 0, path, -1, pathw, cnt);
+ HANDLE handle = CreateFileW(pathw, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ free(pathw);
+ if (handle == INVALID_HANDLE_VALUE)
+ return -1;
+ int64 temp_time = Int32x32To64(crtime, 10000000) + 116444736000000000LL;
+ FILETIME birth_time;
+ birth_time.dwLowDateTime = (DWORD)temp_time;
+ birth_time.dwHighDateTime = (DWORD)(temp_time >> 32);
+ int ok = SetFileTime(handle, &birth_time, NULL, NULL);
+ CloseHandle(handle);
+ return ok ? 0 : -1;
+#endif
}
#endif