Small patch to reverse hardlink ordering
authorMichael Schroeder <mls@suse.de>
Thu, 3 May 2012 09:49:56 +0000 (11:49 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 4 May 2012 09:47:25 +0000 (12:47 +0300)
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.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
(cherry picked from commit bb335292d30893eb88bdf47f166e254fa7abe37e)

lib/fsm.c

index 5c13914..124491e 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -470,9 +470,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;
     }
@@ -495,8 +496,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;