69 lines
2.1 KiB
Diff
69 lines
2.1 KiB
Diff
From 693d828c035848585b500dfde6f4e58cfb8d4de4 Mon Sep 17 00:00:00 2001
|
|
From: Panu Matilainen <pmatilai@redhat.com>
|
|
Date: Mon, 14 Feb 2022 12:44:42 +0200
|
|
Subject: [PATCH] Return descriptor of created file from fsmMkfile()
|
|
|
|
Conflict:adapt context
|
|
Reference:https://github.com/rpm-software-management/rpm/commit/693d828c035848585b500dfde6f4e58cfb8d4de4
|
|
|
|
This will be needed for using fd-based metadata operations.
|
|
---
|
|
lib/fsm.c | 13 ++++++++-----
|
|
1 file changed, 8 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/lib/fsm.c b/lib/fsm.c
|
|
index b019f5711..7c4796f74 100644
|
|
--- a/lib/fsm.c
|
|
+++ b/lib/fsm.c
|
|
@@ -172,7 +172,8 @@ static int fsmUnpack(rpmfi fi, int fdno, rpmpsm psm, int nodigest)
|
|
|
|
static int fsmMkfile(int dirfd, rpmfi fi, struct filedata_s *fp, rpmfiles files,
|
|
rpmpsm psm, int nodigest,
|
|
- struct filedata_s ** firstlink, int *firstlinkfile)
|
|
+ struct filedata_s ** firstlink, int *firstlinkfile,
|
|
+ int *fdp)
|
|
{
|
|
int rc = 0;
|
|
int fd = -1;
|
|
@@ -204,9 +205,7 @@ static int fsmMkfile(int dirfd, rpmfi fi, struct filedata_s *fp, rpmfiles files,
|
|
*firstlinkfile = -1;
|
|
}
|
|
}
|
|
-
|
|
- if (fd != *firstlinkfile)
|
|
- fsmClose(&fd);
|
|
+ *fdp = fd;
|
|
|
|
return rc;
|
|
}
|
|
@@ -867,6 +866,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
|
|
fp = firstlink;
|
|
|
|
if (!fp->skip) {
|
|
+ int fd = -1;
|
|
/* Directories replacing something need early backup */
|
|
if (!fp->suffix && fp != firstlink) {
|
|
rc = fsmBackup(fi, fp->action);
|
|
@@ -910,7 +910,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
|
|
if (S_ISREG(fp->sb.st_mode)) {
|
|
if (rc == RPMERR_ENOENT) {
|
|
rc = fsmMkfile(di.dirfd, fi, fp, files, psm, nodigest,
|
|
- &firstlink, &firstlinkfile);
|
|
+ &firstlink, &firstlinkfile, &fd);
|
|
}
|
|
} else if (S_ISDIR(fp->sb.st_mode)) {
|
|
if (rc == RPMERR_ENOENT) {
|
|
@@ -946,6 +946,9 @@ setmeta:
|
|
rc = fsmSetmeta(fp->fpath, fi, plugins, fp->action,
|
|
&fp->sb, nofcaps);
|
|
}
|
|
+
|
|
+ if (fd != firstlinkfile)
|
|
+ fsmClose(&fd);
|
|
}
|
|
|
|
/* Notify on success. */
|
|
--
|
|
2.27.0
|
|
|