chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
5523e9
--- rpm-4.11.3/lib/transaction.c.old	2019-01-02 13:14:10.304068576 +0100
5523e9
+++ rpm-4.11.3/lib/transaction.c	2019-02-28 11:03:32.164403544 +0100
5523e9
@@ -368,6 +368,11 @@
5523e9
     return rConflicts;
5523e9
 }
5523e9
 
5523e9
+static rpm_loff_t DivideHardlinkSize(int nlink, rpm_loff_t originalSize)
5523e9
+{
5523e9
+    return (originalSize / nlink) + 1;
5523e9
+}
5523e9
+
5523e9
 /**
5523e9
  * handleInstInstalledFiles.
5523e9
  * @param ts		transaction set
5523e9
@@ -384,6 +389,8 @@
5523e9
 {
5523e9
     rpmfs fs = rpmteGetFileStates(p);
5523e9
     int isCfgFile = ((rpmfiFFlagsIndex(otherFi, ofx) | rpmfiFFlagsIndex(fi, fx)) & RPMFILE_CONFIG);
5523e9
+    rpm_loff_t otherFileSize;
5523e9
+    int nlink;
5523e9
 
5523e9
     if (XFA_SKIPPING(rpmfsGetAction(fs, fx)))
5523e9
 	return;
5523e9
@@ -445,7 +452,15 @@
5523e9
 	action = rpmfiDecideFateIndex(otherFi, ofx, fi, fx, skipMissing);
5523e9
 	rpmfsSetAction(fs, fx, action);
5523e9
     }
5523e9
-    rpmfiSetFReplacedSizeIndex(fi, fx, rpmfiFSizeIndex(otherFi, ofx));
5523e9
+
5523e9
+    otherFileSize = rpmfiFSizeIndex(otherFi, ofx);
5523e9
+
5523e9
+    /* Only an appropriate fraction of the file size of a hardlink */
5523e9
+    nlink = rpmfiFNlinkIndex(otherFi, ofx);
5523e9
+    if (nlink > 1)
5523e9
+	otherFileSize = DivideHardlinkSize(nlink, otherFileSize);
5523e9
+
5523e9
+    rpmfiSetFReplacedSizeIndex(fi, fx, otherFileSize);
5523e9
 }
5523e9
 
5523e9
 /**
5523e9
@@ -470,6 +485,8 @@
5523e9
 	rpmfileAttrs FFlags;
5523e9
 	struct rpmffi_s * recs;
5523e9
 	int numRecs;
5523e9
+	rpm_loff_t fileSize;
5523e9
+	int nlink;
5523e9
 
5523e9
 	if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
5523e9
 	    continue;
5523e9
@@ -633,9 +650,15 @@
5523e9
 	    break;
5523e9
 	}
5523e9
 
5523e9
+	fileSize = rpmfiFSizeIndex(fi, i);
5523e9
+	nlink = rpmfiFNlinkIndex(fi, i);
5523e9
+	/* Only an appropriate fraction of the file sizeof a hardlink */
5523e9
+	if (nlink > 1)
5523e9
+	    fileSize = DivideHardlinkSize(nlink, fileSize);
5523e9
+
5523e9
 	/* Update disk space info for a file. */
5523e9
 	rpmtsUpdateDSI(ts, fpEntryDev(fpc, fiFps), fpEntryDir(fpc, fiFps),
5523e9
-		       rpmfiFSizeIndex(fi, i), rpmfiFReplacedSizeIndex(fi, i),
5523e9
+		       fileSize, rpmfiFReplacedSizeIndex(fi, i),
5523e9
 		       fixupSize, rpmfsGetAction(fs, i));
5523e9
 
5523e9
     }
5523e9
--- rpm-4.11.3/lib/rpmfi.h.old	2014-02-05 14:04:02.000000000 +0100
5523e9
+++ rpm-4.11.3/lib/rpmfi.h	2019-01-07 09:57:40.407787724 +0100
5523e9
@@ -396,7 +396,7 @@
5523e9
 
5523e9
 #define RPMFI_FLAGS_ERASE \
5523e9
     (RPMFI_NOFILECLASS | RPMFI_NOFILELANGS | \
5523e9
-     RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | RPMFI_NOFILEINODES | \
5523e9
+     RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | \
5523e9
      RPMFI_NOFILEVERIFYFLAGS)
5523e9
 
5523e9
 #define RPMFI_FLAGS_INSTALL \