summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2016-11-29 13:11:02 +0200
committerPanu Matilainen <pmatilai@redhat.com>2016-11-29 13:16:54 +0200
commitcefe4f6d30812e3dbed90afe3a83967aee1d3d8d (patch)
treee45fa9e7d842b46957252979b3105a78276b468c
parent6743ffb312461bd5a1021beef52534e63582d5cf (diff)
downloadrpm-cefe4f6d30812e3dbed90afe3a83967aee1d3d8d.tar.gz
Normalize dubiously large fs blocksizes to 4096
Some filesystems like NFS and ZFS report block sizes that have nothing to do with the original concept of a block size, and mess up rpms calculations big time. Normalize to these to 4k for a result that is closer to reality. SuseBug:894610, SuseBug:829717, SuseBug:965322, RhBug:847960, RhBug:1397569...
-rw-r--r--lib/transaction.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/transaction.c b/lib/transaction.c
index 7f0621133..79fb78665 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -136,6 +136,13 @@ static rpmDiskSpaceInfo rpmtsCreateDSI(const rpmts ts, dev_t dev,
dsi->iavail = !(sfb.f_ffree == 0 && sfb.f_files == 0)
? sfb.f_ffree : -1;
+ /* normalize block size to 4096 bytes if it is too big. */
+ if (dsi->bsize > 4096) {
+ uint64_t old_size = dsi->bavail * dsi->bsize;
+ dsi->bsize = 4096; /* Assume 4k block size */
+ dsi->bavail = old_size / dsi->bsize;
+ }
+
/* Find mount point belonging to this device number */
resolved_path = realpath(dirName, mntPoint);
if (!resolved_path) {