unsigned idx = 0;
for_( it, result.begin(), result.end() )
{
- // Limit estimated waste (half block per file) as it does not apply to
- // btrfs, which reports up to 64K blocksize (bsc#974275,bsc#965322)
- static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / 2 / 1K; result value in K!
-
+ static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / (2 * 1K)
it->pkg_size = it->used_size // current usage
+ duchanges[idx].kbytes // package data size
- + ( duchanges[idx].files * ( it->fstype == "btrfs" ? 4096 : it->block_size ) / blockAdjust ); // half block per file
+ + ( duchanges[idx].files * it->block_size / blockAdjust ); // half block per file
++idx;
}
}
{
DiskUsageCounter::MountPointSet ret;
- typedef std::map<std::string, MountPoint> Btrfsfilter;
- Btrfsfilter btrfsfilter; // see btrfs hack below
-
std::ifstream procmounts( "/proc/mounts" );
if ( !procmounts ) {
//
const char * mpunwanted[] = {
"/mnt", "/media", "/mounts", "/floppy", "/cdrom",
- "/suse", "/tmp", "/var/tmp", "/var/adm/mount", "/var/adm/YaST",
+ "/suse", "/var/tmp", "/var/adm/mount", "/var/adm/YaST",
/*last*/0/*entry*/
};
//
// check for snapshotting btrfs
//
- bool btrfshack = false;
if ( words[2] == "btrfs" )
{
- btrfshack = true;
if ( geteuid() != 0 )
{
DBG << "Assume snapshots on " << words[1] << ": non-root user can't check" << std::endl;
DBG << "Filter zero-sized mount point : " << l << std::endl;
continue;
}
- if ( btrfshack )
- {
- // HACK:
- // Collect just the top/1st mountpoint of each btrfs volume
- // (by device). This filters away nested subvolumes
- // which otherwise break per package disk usage computation.
- // FIX: Computation must learn to handle multiple mount points
- // contributing to the same file system.
- MountPoint & bmp( btrfsfilter[words[0]] );
- if ( bmp.fstype.empty() ) // 1st occurance
- {
- bmp = DiskUsageCounter::MountPoint( mp, words[2], sb.f_bsize,
- ((long long)sb.f_blocks)*sb.f_bsize/1024,
- ((long long)(sb.f_blocks - sb.f_bfree))*sb.f_bsize/1024, 0LL, hints );
- }
- else if ( bmp.dir > mp )
- bmp.dir = mp;
- continue;
- }
ret.insert( DiskUsageCounter::MountPoint( mp, words[2], sb.f_bsize,
((long long)sb.f_blocks)*sb.f_bsize/1024,
((long long)(sb.f_blocks - sb.f_bfree))*sb.f_bsize/1024, 0LL, hints ) );
}
}
- // collect filtered btrfs volumes
- for ( auto && bmp : btrfsfilter )
- ret.insert( std::move(bmp.second) );
-
return ret;
}