[OpenAFS-devel] Patch 'up' utility to preserve time stamps on directories

Todd M. Lewis Todd_Lewis@unc.edu, openafs-devel@openafs.org, Lester Barrows <barrows@email.arc.nasa.gov>
Fri, 13 Feb 2004 09:10:59 -0500


This is a multi-part message in MIME format.
--------------020301000909050804020803
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

The attached patch from Lester Barrows <barrows@email.arc.nasa.gov> 
(Hey, look, an actual rocket scientist!) makes the 'up' utility preserve 
time stamps on copied directories.

BTW, I looked on the OpenAFS.org pages for a documented channel to 
submit patches, but didn't find one.  If there's a better way to submit 
patches, I'd be happy to do that instead.
-- 
    +--------------------------------------------------------------+
   / Todd_Lewis@unc.edu  919-962-5273  http://www.unc.edu/~utoddl /
  /       Energizer Bunny arrested - charged with battery.       /
+--------------------------------------------------------------+

-------- Original Message --------
Subject: Re: [OpenAFS] 'split' a tree of directory into volumes?
Date: Thu, 12 Feb 2004 15:02:30 -0800
From: Lester Barrows <barrows@email.arc.nasa.gov>
Organization: Asani Solutions, LLC
To: Todd_Lewis@unc.edu

Hi Todd,

Not sure if I should submit a patch to the openafs-info list, so I
thought I'd send it to you. It's a trivial patch so I doubt that it
matters, but if you have a preferred incantation of diff aside from
unified format (or if I should send this elsewhere) let me know. It's
intended to be applied from the root of the openafs directory.

Regards,

Lester Barrows
Asani Solutions, LLC
Code IC Systems Group
NASA Ames Research Center

"Jura rapelcgvba vf bhgynjrq, bayl bhgynjf jvyy unir cevinpl."

On Monday 09 February 2004 11:51 am, Todd M. Lewis wrote:
> Lester Barrows wrote:
> > [... good stuff about 'up' not preserving directory timestamps...]
> >
> > It seems to work as-is, but begs the question: If it's that easy, do you
> > (or does anyone) know why this isn't done already?
>
> Sure: Nobody's contributed the code.  Seriously.  When I added the bits
> to make it aware of mount points, I had a particular itch to scratch
> that day.  The fact that directory time stamps weren't preserved just
> didn't itch me then, and evidently hasn't bothered anybody else enough
> to do something about it...
>
> ...until you came along, of course!  I'm looking forward to your
> patches.  :-)
>
> > Is there a reason that in
> > general we don't want to preserve directory timestamps when duplicating a
> > directory? Or is it possible for this to somehow blow up on me in an
> > obscure fashion? :-)
>
> I can't think of any reason not to preserve timestamps. OTOH, I couldn't
> imagine why you'd ever want the old, non-mount point aware behavior
> either, but I made it an option with the old behavior as the default
> anyway. I guess that was not to surprise either one of the regular 'up'
> users who might have a script that depends on the old behavior. I still
> can't decide if that was a mistake.
>
> Does 'up' preserve timestamps on files? If so, it should preserve them
> on directories too. My opinion, ymmv, etc.  Cheers,

--------------020301000909050804020803
Content-Type: text/x-diff;
 name="up.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="up.c.diff"

--- src/venus/up.c.orig	2004-02-09 10:29:25.000000000 -0800
+++ src/venus/up.c	2004-02-09 10:56:48.000000000 -0800
@@ -510,6 +510,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);
@@ -590,6 +591,14 @@ Copy(file1, file2, recursive, level)
 	  rcode = 1;
        }
 
+       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);
+	}
+
        if (setacl == true) {
 	  if (verbose) {
 	     printf("  Set acls for %s\n", file2);


--------------020301000909050804020803--