summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2005-07-27 23:30:51 +0000
committerWayne Davison <wayned@samba.org>2005-07-27 23:30:51 +0000
commit25007999df5ef5ecb138f34193729e4019ad778c (patch)
treef6ebf7464c40882655dc27548f249528d08d528f
parent8ce65463104988d0d90fd9e8b2e55aa28ddd9482 (diff)
downloadrsync-25007999df5ef5ecb138f34193729e4019ad778c.tar.gz
- Changed set_modtime() to take the file's mode as an arg.
- Made set_modtime() handle symlinks or return 1 if not possible.
-rw-r--r--util.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/util.c b/util.c
index 234a61e8..e99ede8e 100644
--- a/util.c
+++ b/util.c
@@ -128,8 +128,13 @@ void overflow_exit(char *str)
-int set_modtime(char *fname, time_t modtime)
+int set_modtime(char *fname, time_t modtime, mode_t mode)
{
+#if !defined HAVE_LUTIMES || !defined HAVE_UTIMES
+ if (S_ISLNK(mode))
+ return 1;
+#endif
+
if (verbose > 2) {
rprintf(FINFO, "set modtime of %s to (%ld) %s",
safe_fname(fname), (long)modtime,
@@ -140,7 +145,18 @@ int set_modtime(char *fname, time_t modtime)
return 0;
{
-#ifdef HAVE_UTIMBUF
+#ifdef HAVE_UTIMES
+ struct timeval t[2];
+ t[0].tv_sec = time(NULL);
+ t[0].tv_usec = 0;
+ t[1].tv_sec = modtime;
+ t[1].tv_usec = 0;
+# ifdef HAVE_LUTIMES
+ if (S_ISLNK(mode))
+ return lutimes(fname, t);
+# endif
+ return utimes(fname, t);
+#elif defined HAVE_UTIMBUF
struct utimbuf tbuf;
tbuf.actime = time(NULL);
tbuf.modtime = modtime;
@@ -151,12 +167,7 @@ int set_modtime(char *fname, time_t modtime)
t[1] = modtime;
return utime(fname,t);
#else
- struct timeval t[2];
- t[0].tv_sec = time(NULL);
- t[0].tv_usec = 0;
- t[1].tv_sec = modtime;
- t[1].tv_usec = 0;
- return utimes(fname,t);
+#error No file-time-modification routine found!
#endif
}
}