delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/04/27/11:51:46

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Dan Grayson <dan AT math DOT uiuc DOT edu>
Subject: Re: untarring symlinks with ../ fails randomly
Date: Wed, 27 Apr 2011 15:50:58 +0000 (UTC)
Lines: 48
Message-ID: <loom.20110427T161737-566@post.gmane.org>
References: <BANLkTikh9rCN2GRwY3eW20H0isffN5fMUg AT mail DOT gmail DOT com> <BANLkTi=GZbtLmK-Sr06-M=5xXVFzPCi82w AT mail DOT gmail DOT com> <20110424121145 DOT GB30696 AT calimero DOT vinschen DOT de> <loom DOT 20110425T165316-628 AT post DOT gmane DOT org> <20110426074325 DOT GP3324 AT calimero DOT vinschen DOT de> <loom DOT 20110426T170653-639 AT post DOT gmane DOT org> <20110426152226 DOT GA22801 AT ednor DOT casa DOT cgf DOT cx> <20110426155346 DOT GA19578 AT calimero DOT vinschen DOT de>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Here is a patch to tar that fixes the problem by using mtime instead of ctime.
Yes, it's not a problem with cygwin or tar, but I see no way for users to
figure out, under Windows, which processes are changing the status of their
files.

diff -ur tar-1.25-copy/src/extract.c tar-1.25/src/extract.c
--- tar-1.25-copy/src/extract.c	2010-11-01 15:34:59.000000000 -0500
+++ tar-1.25/src/extract.c	2011-04-27 09:12:58.941555800 -0500
@@ -115,7 +115,10 @@
        other process removes the placeholder.  */
     dev_t dev;
     ino_t ino;
-    struct timespec ctime;
+       /* for cygwin, we use mtime instead of ctime of the 
+	  placeholder, because background processes running
+	  under Windows may change it */
+    struct timespec mtime0;
 
     /* True if the link is symbolic.  */
     bool is_symlink;
@@ -1064,7 +1067,7 @@
       delayed_link_head = p;
       p->dev = st.st_dev;
       p->ino = st.st_ino;
-      p->ctime = get_stat_ctime (&st);
+      p->mtime0 = get_stat_mtime (&st);
       p->is_symlink = is_symlink;
       if (is_symlink)
 	{
@@ -1122,7 +1125,7 @@
 	      if (ds->change_dir == chdir_current
 		  && ds->dev == st1.st_dev
 		  && ds->ino == st1.st_ino
-		  && timespec_cmp (ds->ctime, get_stat_ctime (&st1)) == 0)
+		  && timespec_cmp (ds->mtime0, get_stat_mtime (&st1)) == 0)
 		{
 		  struct string_list *p =  xmalloc (offsetof (struct string_list, string)
 						    + strlen (file_name) + 1);
@@ -1488,7 +1491,7 @@
 	  if (fstatat (chdir_fd, source, &st, AT_SYMLINK_NOFOLLOW) == 0
 	      && st.st_dev == ds->dev
 	      && st.st_ino == ds->ino
-	      && timespec_cmp (get_stat_ctime (&st), ds->ctime) == 0)
+	      && timespec_cmp (get_stat_mtime (&st), ds->mtime0) == 0)
 	    {
 	      /* Unlink the placeholder, then create a hard link if possible,
 		 a symbolic link otherwise.  */



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019