michal-grzedzicki / rpms / rpm

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