delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/08/29/04:10:08

X-Spam-Check-By: sourceware.org
Date: Wed, 29 Aug 2007 10:08:55 +0200
From: Peter Rosin <peda AT lysator DOT liu DOT se>
To: cygwin AT cygwin DOT com
Subject: Problem with "quilt add" + patch
Message-ID: <20070829080854.GA25233@cobra.lysator.liu.se>
MIME-Version: 1.0
User-Agent: Mutt/1.5.12-2006-07-14
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

--YiEDa0DAkWCtVeE4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi!

I'm having problems with "quilt add".

Basically it tries to first make a hard link from e.g. "foo" to
".pc/somepatch/foo", then copy ".pc/somepatch/foo" to
".pc/somepatch/sometempfile" using file descriptors and finally it
tries to rename ".pc/somepatch/sometempfile" back to ".pc/somepatch/foo"
effectivly just making a copy of the original file.

This is all within the support program /usr/lib/quilt/backup-files.exe
if you feed it the -L option, which "quilt add" does.

The problem is that the final rename fails, and the root cause is that
an fd is held open to the target file ".pc/somepatch/foo".

Here is a patch to fix it, but I guess the ultimate fix is to
make rename(2) more Linux-like...

Without the included patch, "quilt add" exits with an error but
leaves the backup hardlinked with the source resulting in empty
diffs when you "quilt diff", but you are left on your own trying
to fix up the damage caused by the failed command.

Cheers,
Peter

--YiEDa0DAkWCtVeE4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="quilt-backup-files.patch"

--- lib/backup-files.c.orig	2007-08-29 09:49:11.825125000 +0200
+++ lib/backup-files.c	2007-08-29 09:50:00.247000000 +0200
@@ -271,6 +271,10 @@
 #elif defined(HAVE_CHMOD)
 		(void) chmod(tmpname, st.st_mode);
 #endif
+		close(from_fd);
+		from_fd = -1;
+		close(to_fd);
+		to_fd = -1;
 		if (rename(tmpname, filename))
 			goto fail;
 
@@ -279,8 +283,10 @@
 		if (error)
 			perror(filename);
 		free(tmpname);
-		close(from_fd);
-		close(to_fd);
+		if (from_fd != -1)
+			close(from_fd);
+		if (to_fd != -1)
+			close(to_fd);
 		return error;
 	} else
 		return 0;


--YiEDa0DAkWCtVeE4
Content-Type: text/plain; charset=us-ascii

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

- Raw text -


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