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
--- 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;

--
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/

Reply via email to