rpm/backport-Add-hardlink-helper-to-fsm-to-make-it-debuggable.patch

53 lines
1.4 KiB
Diff

From bbd30984dcedd2de4762b96c92b62a32f9448b03 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Thu, 11 Feb 2021 09:54:41 +0200
Subject: [PATCH] Add hardlink helper to fsm to make it debuggable
Conflict:NA
Reference:https://github.com/rpm-software-management/rpm/commit/bbd30984dcedd2de4762b96c92b62a32f9448b03
---
lib/fsm.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/fsm.c b/lib/fsm.c
index 6efd25bdd..f8038e09b 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -211,6 +211,20 @@ const char * dnlNextIterator(DNLI_t dnli)
return dn;
}
+static int fsmLink(const char *opath, const char *path)
+{
+ int rc = link(opath, path);
+
+ if (_fsm_debug) {
+ rpmlog(RPMLOG_DEBUG, " %8s (%s, %s) %s\n", __func__,
+ opath, path, (rc < 0 ? strerror(errno) : ""));
+ }
+
+ if (rc < 0)
+ rc = RPMERR_LINK_FAILED;
+ return rc;
+}
+
static int fsmSetFCaps(const char *path, const char *captxt)
{
int rc = 0;
@@ -304,10 +318,7 @@ static int fsmMkfile(rpmfi fi, struct filedata_s *fp, rpmfiles files,
rc = wfd_open(firstlinkfile, fp->fpath);
} else {
/* Create hard links for others */
- rc = link((*firstlink)->fpath, fp->fpath);
- if (rc < 0) {
- rc = RPMERR_LINK_FAILED;
- }
+ rc = fsmLink((*firstlink)->fpath, fp->fpath);
}
}
/* Write normal files or fill the last hardlinked (already
--
2.27.0