[Rpm-maint] Small patch to reverse hardlink ordering

Michael Schroeder mls at suse.de
Thu May 3 09:49:56 UTC 2012


Hi Panu et al,

Here's a small patch that changes the ordering used for putting
hardlinked files into the cpio archive back to lexicographical.

You might wonder what this is about. Well, old rpm-3 (and
also old versions of rpm-4, I think) already used lexicographical
ordering for files and hardlinks. When deltarpm was created,
it made use of this fact when "compressing" the file order
of the cpio archive into the so-called "sequence". Deltarpm
can deal with "out of order" files, but in that case it needs
to reset the compression, which leads to really long sequence
strings.

--- lib/fsm.c.orig	2012-05-03 09:26:05.000000000 +0000
+++ lib/fsm.c	2012-05-03 09:29:09.000000000 +0000
@@ -469,9 +469,10 @@ static int saveHardLink(FSM_t fsm)
     int rc = 0;
     int ix = -1;
     int j;
+    hardLink_t *tailp;
 
     /* Find hard link set. */
-    for (fsm->li = fsm->links; fsm->li; fsm->li = fsm->li->next) {
+    for (tailp = &fsm->links; (fsm->li = *tailp) != NULL; tailp = &fsm->li->next) {
 	if (fsm->li->sb.st_ino == st->st_ino && fsm->li->sb.st_dev == st->st_dev)
 	    break;
     }
@@ -494,8 +495,7 @@ static int saveHardLink(FSM_t fsm)
 	if (fsm->goal == FSM_PKGINSTALL)
 	    fsm->li->linksLeft = 0;
 
-	fsm->li->next = fsm->links;
-	fsm->links = fsm->li;
+	*tailp = fsm->li;	/* append to tail of linked list */
     }
 
     if (fsm->goal == FSM_PKGBUILD) --fsm->li->linksLeft;

Cheers,
  Michael.

-- 
Michael Schroeder                                   mls at suse.de
SUSE LINUX Products GmbH,  GF Jeff Hawn, HRB 16746 AG Nuernberg
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}


More information about the Rpm-maint mailing list