From 1d4d8f5c4f125707fc6af432024d99e2672cadab Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Mon, 7 May 2007 18:17:42 +0000 Subject: [PATCH] up-preserve-dir-mtime-20070507 FIXES 34522 Set the mtime on newly created directories to match the original directory. --- src/venus/up.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/venus/up.c b/src/venus/up.c index af2e18f38..2dee7cfa8 100644 --- a/src/venus/up.c +++ b/src/venus/up.c @@ -511,6 +511,7 @@ Copy(char *file1, char *file2, short recursive, int level) char f1[MAXPATHLEN], f2[MAXPATHLEN]; char *p1, *p2; struct dirent *d; + struct timeval tv[2]; if (verbose) { printf("Level %d: Directory %s to %s\n", level, file1, file2); @@ -698,6 +699,15 @@ Copy(char *file1, char *file2, short recursive, int level) printf("Not setting acls\n"); } } + + /* preserve access and modification times: ("-x" disables) */ + if (preserveDate) { + tv[0].tv_sec = s1.st_atime; + tv[0].tv_usec = 0; + tv[1].tv_sec = s1.st_mtime; + tv[1].tv_usec = 0; + utimes(file2, tv); + } } return rcode; -- 2.39.5