Re: Another 2.4 upgrade horror story

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simon Matter wrote, on 26.09.2012 06:58:
> I have not used freedup for restoring the hardlinks but I'm interested in
> the patch. If it's not big could you post it here?

Sure! attached.

I built a RPM based on
http://pkgs.repoforge.org/freedup/freedup-1.5.3-1.rf.src.rpm
and latest source.
But building based on
http://www.freedup.org/freedup-1.6-2.src.rpm
should work as well.

Greetings, Wolfgang
-- 
Wolfgang Breyha <wbreyha@xxxxxxx> | http://www.blafasel.at/
Vienna University Computer Center | Austria

--- freedup-1.6/freedup.c.orig	2011-02-04 08:22:15.000000000 +0100
+++ freedup-1.6/freedup.c	2011-11-11 10:52:24.788733835 +0100
@@ -613,7 +613,7 @@
 	 */
 	if( mktemp(tmpfilename) == NULL )
 	{
-	    perror("There is no unique temporory file name.");
+	    perror("There is no unique temporary file name.");
 	}
 	if( dirmtime!=0 )
 	{
@@ -628,7 +628,7 @@
 	if( lstat(tmpfilename,&tstat) != 0 )
 	{
 	    /*
-	     * The errror needs not to be catched, since it is wanted
+	     * The error needs not to be catched, since it is wanted
 	     * that no file exists with the target name
 	     */
 	    rename( bname, tmpfilename );
@@ -643,12 +643,23 @@
 	}
 	if( lnk( symaname, bname ) != 0 )
 	{
-	    perror("Linking failed.");
-	}
-	if( unlink( tmpfilename ) != 0 )
-	{
-	    perror("Unlink failed.");
-	}
+	    // linking failed! try to move original in place again and
+	    // log that fact
+	    fprintf(stderr, "Linking failed. Trying roleback: \"%s\"", bname);
+	    if ( rename( tmpfilename, bname ) != 0 )
+	    {
+		// moving old file in place again failed.
+		// at least log that -v
+		fprintf(stderr, "unable to rename: \"%s\"", tmpfilename);
+	    }
+	}
+	else 
+	    // unlink renamed original only of linking was successful
+	    if( unlink( tmpfilename ) != 0 )
+	    {
+		// unlinking failed! log that -v
+		fprintf(stderr, "Unlink failed: \"%s\"", tmpfilename);
+	    }
 	if( (dirmtime!=0) & (gotdirtime!=0) )
 	{
 	    utimecache.actime  = dstat.st_atime;
----
Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/
To Unsubscribe:
https://lists.andrew.cmu.edu/mailman/listinfo/info-cyrus

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux