summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2017-10-26 20:18:35 -0400
committerPanu Matilainen <pmatilai@redhat.com>2018-03-28 14:09:16 +0300
commitd765baf3f0f9f237ca107cc9d733d40984fe30e3 (patch)
tree6897ceeac55a1fc9f9ee926722f054d917ac9050
parent1c6a151c3b5f42cec8c083ad915b7eeca61a1f25 (diff)
downloadrpm-d765baf3f0f9f237ca107cc9d733d40984fe30e3.tar.gz
Remove now redundant code and parameters from expandRegular()
The 'nocontent' parameter is now always 0, and the 'exclusive' parameter is now always 1 so they can be removed, along with the linkSane() helper which becomes unused here. (cherry picked from commit b58096e586fba3923c1ff6029b0e10ed02d6397d)
-rw-r--r--lib/fsm.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/lib/fsm.c b/lib/fsm.c
index efc675225..cfb9aba37 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -206,17 +206,6 @@ static int fsmSetFCaps(const char *path, const char *captxt)
return rc;
}
-/* Check dest is the same, empty and regular file with writeonly permissions */
-static int linkSane(FD_t wfd, const char *dest)
-{
- struct stat sb, lsb;
-
- return (fstat(Fileno(wfd), &sb) == 0 && sb.st_size == 0 &&
- (sb.st_mode & ~S_IFMT) == S_IWUSR &&
- lstat(dest, &lsb) == 0 && S_ISREG(lsb.st_mode) &&
- sb.st_dev == lsb.st_dev && sb.st_ino == lsb.st_ino);
-}
-
static void wfd_close(FD_t *wfdp)
{
if (wfdp && *wfdp) {
@@ -227,20 +216,14 @@ static void wfd_close(FD_t *wfdp)
}
}
-static int wfd_open(FD_t *wfdp, const char *dest, int exclusive)
+static int wfd_open(FD_t *wfdp, const char *dest)
{
int rc = 0;
/* Create the file with 0200 permissions (write by owner). */
{
mode_t old_umask = umask(0577);
- *wfdp = Fopen(dest, exclusive ? "wx.ufdio" : "a.ufdio");
+ *wfdp = Fopen(dest, "wx.ufdio");
umask(old_umask);
-
- /* If reopening, make sure the file is what we expect */
- if (!exclusive && *wfdp != NULL && !linkSane(*wfdp, dest)) {
- rc = RPMERR_OPEN_FAILED;
- goto exit;
- }
}
if (Ferror(*wfdp)) {
rc = RPMERR_OPEN_FAILED;
@@ -258,17 +241,16 @@ exit:
* Create file from payload stream.
* @return 0 on success
*/
-static int expandRegular(rpmfi fi, const char *dest, rpmpsm psm, int exclusive, int nodigest, int nocontent)
+static int expandRegular(rpmfi fi, const char *dest, rpmpsm psm, int nodigest)
{
FD_t wfd = NULL;
int rc;
- rc = wfd_open(&wfd, dest, exclusive);
+ rc = wfd_open(&wfd, dest);
if (rc != 0)
goto exit;
- if (!nocontent)
- rc = rpmfiArchiveReadToFilePsm(fi, wfd, nodigest, psm);
+ rc = rpmfiArchiveReadToFilePsm(fi, wfd, nodigest, psm);
wfd_close(&wfd);
exit:
return rc;
@@ -285,7 +267,7 @@ static int fsmMkfile(rpmfi fi, const char *dest, rpmfiles files,
/* Create first hardlinked file empty */
if (*firsthardlink < 0) {
*firsthardlink = rpmfiFX(fi);
- rc = wfd_open(firstlinkfile, dest, 1);
+ rc = wfd_open(firstlinkfile, dest);
} else {
/* Create hard links for others */
char *fn = rpmfilesFN(files, *firsthardlink);
@@ -300,7 +282,7 @@ static int fsmMkfile(rpmfi fi, const char *dest, rpmfiles files,
existing) file with content */
if (numHardlinks<=1) {
if (!rc)
- rc = expandRegular(fi, dest, psm, 1, nodigest, 0);
+ rc = expandRegular(fi, dest, psm, nodigest);
} else if (rpmfiArchiveHasContent(fi)) {
if (!rc)
rc = rpmfiArchiveReadToFilePsm(fi, *firstlinkfile, nodigest, psm);