s3: keep subsecond times on cross-filesystem moves and don't follow links
authorBjörn Jacke <bj@sernet.de>
Wed, 9 Dec 2009 01:06:17 +0000 (02:06 +0100)
committerBjörn Jacke <bj@sernet.de>
Wed, 9 Dec 2009 01:58:40 +0000 (02:58 +0100)
source3/modules/vfs_default.c

index ded4b1af27674ce91dc3d675977e1da7a8342271..6e2a5712c83fe6d8209934f13d3921a42ee1abb6 100644 (file)
@@ -540,6 +540,27 @@ static int copy_reg(const char *source, const char *dest)
                return -1;
 
        /* Try to copy the old file's modtime and access time.  */
+#if defined(HAVE_UTIMENSAT)
+       {
+               struct timespec ts[2];
+
+               ts[0] = source_stats.st_ex_atime;
+               ts[1] = source_stats.st_ex_mtime;
+               utimensat(AT_FDCWD, dest, ts, AT_SYMLINK_NOFOLLOW);
+       }
+#elif defined(HAVE_UTIMES)
+       {
+               struct timeval tv[2];
+
+               tv[0] = convert_timespec_to_timeval(source_stats.st_ex_atime);
+               tv[1] = convert_timespec_to_timeval(source_stats.st_ex_mtime);
+#ifdef HAVE_LUTIMES
+               lutimes(dest, tv);
+#else
+               utimes(dest, tv);
+#endif
+       }
+#elif defined(HAVE_UTIME)
        {
                struct utimbuf tv;
 
@@ -547,6 +568,7 @@ static int copy_reg(const char *source, const char *dest)
                tv.modtime = convert_timespec_to_time_t(source_stats.st_ex_mtime);
                utime(dest, &tv);
        }
+#endif
 
        if (unlink (source) == -1)
                return -1;