From 06cee6bb978209ed1397b1e845bb364aee6fc391 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Mon, 7 May 2007 18:23:11 +0000 Subject: [PATCH] STABLE14-up-preserve-dir-mtime-20070507 FIXES 34522 Set the mtime on newly created directories to match the original directory. (cherry picked from commit 1d4d8f5c4f125707fc6af432024d99e2672cadab) --- src/venus/up.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/venus/up.c b/src/venus/up.c index 754434350..b8305ea9c 100644 --- a/src/venus/up.c +++ b/src/venus/up.c @@ -528,6 +528,7 @@ Copy(file1, file2, recursive, 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); @@ -689,6 +690,15 @@ Copy(file1, file2, recursive, 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