diff --git a/lib/rpmfiles.h b/lib/rpmfiles.h index 9b15d1a95..797b77bc8 100644 --- a/lib/rpmfiles.h +++ b/lib/rpmfiles.h @@ -156,7 +156,7 @@ typedef rpmFlags rpmfiFlags; #define RPMFI_FLAGS_ERASE \ (RPMFI_NOFILECLASS | RPMFI_NOFILELANGS | \ - RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | RPMFI_NOFILEINODES | \ + RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | \ RPMFI_NOFILEVERIFYFLAGS) #define RPMFI_FLAGS_INSTALL \ diff --git a/lib/transaction.c b/lib/transaction.c index 01b57a51d..6aab1957f 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -412,6 +412,9 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfiles fi, int fx { rpmfs fs = rpmteGetFileStates(p); int isCfgFile = ((rpmfilesFFlags(otherFi, ofx) | rpmfilesFFlags(fi, fx)) & RPMFILE_CONFIG); + rpm_loff_t otherFileSize; + int nlink; + const int *links; if (XFA_SKIPPING(rpmfsGetAction(fs, fx))) return; @@ -481,8 +484,15 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfiles fi, int fx } } + otherFileSize = rpmfilesFSize(otherFi, ofx); + + /* Only account for the last file of a hardlink set */ + nlink = rpmfilesFLinks(otherFi, ofx, &links); + if (nlink > 1 && links[nlink - 1] != ofx) + otherFileSize = 0; + /* Add one to make sure the size is not zero */ - rpmfilesSetFReplacedSize(fi, fx, rpmfilesFSize(otherFi, ofx) + 1); + rpmfilesSetFReplacedSize(fi, fx, otherFileSize + 1); } /** @@ -507,6 +517,9 @@ static void handleOverlappedFiles(rpmts ts, fingerPrintCache fpc, rpmte p, rpmfi rpmfileAttrs FFlags; struct rpmffi_s * recs; int numRecs; + rpm_loff_t fileSize; + int nlink; + const int *links; if (XFA_SKIPPING(rpmfsGetAction(fs, i))) continue; @@ -677,9 +690,16 @@ assert(otherFi != NULL); } rpmfilesFree(otherFi); + fileSize = rpmfilesFSize(fi, i); + nlink = rpmfilesFLinks(fi, i, &links); + if (nlink > 1 && links[nlink - 1] != i) { + /* Only account for the last file of a hardlink set */ + fileSize = 0; + fixupSize = fixupSize ? 1 : 0; + } /* Update disk space info for a file. */ rpmtsUpdateDSI(ts, fpEntryDev(fpc, fiFps), fpEntryDir(fpc, fiFps), - rpmfilesFSize(fi, i), rpmfilesFReplacedSize(fi, i), + fileSize, rpmfilesFReplacedSize(fi, i), fixupSize, rpmfsGetAction(fs, i)); }