Hello community, here is the log from the commit of package libzypp for openSUSE:Factory checked in at 2014-09-17 17:41:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libzypp (Old) and /work/SRC/openSUSE:Factory/.libzypp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libzypp" Changes: -------- --- /work/SRC/openSUSE:Factory/libzypp/libzypp.changes 2014-09-10 17:02:23.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.libzypp.new/libzypp.changes 2014-09-17 17:42:14.000000000 +0200 @@ -1,0 +2,7 @@ +Tue Sep 16 10:45:39 CEST 2014 - [email protected] + +- DiskUsageCounter: Support setting 'growonly' partition hint + (bnc#896176) +- version 14.29.0 (29) + +------------------------------------------------------------------- Old: ---- libzypp-14.28.0.tar.bz2 New: ---- libzypp-14.29.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libzypp.spec ++++++ --- /var/tmp/diff_new_pack.EroQ38/_old 2014-09-17 17:42:15.000000000 +0200 +++ /var/tmp/diff_new_pack.EroQ38/_new 2014-09-17 17:42:15.000000000 +0200 @@ -23,7 +23,7 @@ Summary: Package, Patch, Pattern, and Product Management License: GPL-2.0+ Group: System/Packages -Version: 14.28.0 +Version: 14.29.0 Release: 0 Source: %{name}-%{version}.tar.bz2 Source1: %{name}-rpmlintrc @@ -73,7 +73,7 @@ BuildRequires: pkg-config %endif -BuildRequires: libsolv-devel >= 0.4.2 +BuildRequires: libsolv-devel >= 0.6.5 %if 0%{?suse_version} >= 1100 %requires_eq libsolv-tools %else ++++++ libzypp-14.28.0.tar.bz2 -> libzypp-14.29.0.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/VERSION.cmake new/libzypp-14.29.0/VERSION.cmake --- old/libzypp-14.28.0/VERSION.cmake 2014-09-05 12:49:26.000000000 +0200 +++ new/libzypp-14.29.0/VERSION.cmake 2014-09-16 10:49:10.000000000 +0200 @@ -59,10 +59,10 @@ # See './mkChangelog -h' for help. # SET(LIBZYPP_MAJOR "14") -SET(LIBZYPP_COMPATMINOR "28") -SET(LIBZYPP_MINOR "28") +SET(LIBZYPP_COMPATMINOR "29") +SET(LIBZYPP_MINOR "29") SET(LIBZYPP_PATCH "0") # -# LAST RELEASED: 14.28.0 (28) +# LAST RELEASED: 14.29.0 (29) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/libzypp.spec.cmake new/libzypp-14.29.0/libzypp.spec.cmake --- old/libzypp-14.28.0/libzypp.spec.cmake 2014-07-01 11:30:28.000000000 +0200 +++ new/libzypp-14.29.0/libzypp.spec.cmake 2014-09-16 15:20:17.000000000 +0200 @@ -73,7 +73,7 @@ BuildRequires: pkg-config %endif -BuildRequires: libsolv-devel >= 0.4.2 +BuildRequires: libsolv-devel >= 0.6.5 %if 0%{?suse_version} >= 1100 %requires_eq libsolv-tools %else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/package/libzypp.changes new/libzypp-14.29.0/package/libzypp.changes --- old/libzypp-14.28.0/package/libzypp.changes 2014-09-05 12:49:26.000000000 +0200 +++ new/libzypp-14.29.0/package/libzypp.changes 2014-09-16 10:49:10.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Sep 16 10:45:39 CEST 2014 - [email protected] + +- DiskUsageCounter: Support setting 'growonly' partition hint + (bnc#896176) +- version 14.29.0 (29) + +------------------------------------------------------------------- Fri Sep 5 12:46:57 CEST 2014 - [email protected] - Make Repository::isUpdateRepo also check for being referenced diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/CMakeLists.txt new/libzypp-14.29.0/tests/repo/CMakeLists.txt --- old/libzypp-14.28.0/tests/repo/CMakeLists.txt 2014-07-01 11:30:28.000000000 +0200 +++ new/libzypp-14.29.0/tests/repo/CMakeLists.txt 2014-09-16 10:49:10.000000000 +0200 @@ -4,4 +4,4 @@ # to find the KeyRingTest receiver INCLUDE_DIRECTORIES( ${LIBZYPP_SOURCE_DIR}/tests/zypp ) -ADD_TESTS(RepoVariables ExtendedMetadata PluginServices MirrorList) +ADD_TESTS(RepoVariables ExtendedMetadata PluginServices MirrorList DUdata) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/DUdata_test.cc new/libzypp-14.29.0/tests/repo/DUdata_test.cc --- old/libzypp-14.28.0/tests/repo/DUdata_test.cc 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/DUdata_test.cc 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,113 @@ +#include <iostream> +#include <sstream> +#include <fstream> +#include <list> +#include <string> + +#include <boost/test/auto_unit_test.hpp> + +#include "zypp/base/Logger.h" +#include "zypp/base/Exception.h" +#include "zypp/RepoManager.h" +#include "zypp/ResPool.h" +#include "zypp/sat/Pool.h" +#include "zypp/PoolQuery.h" + +#include "KeyRingTestReceiver.h" +#include "TestSetup.h" + +using boost::unit_test::test_case; + +using namespace std; +using namespace zypp; +using namespace zypp::repo; +using namespace zypp::filesystem; + +#define TEST_DIR TESTS_SRC_DIR "/repo/susetags/data/dudata" + +PoolItem piFind( const std::string & name_r, const std::string & ver_r, bool installed_r = false ) +{ + PoolQuery q; + q.addDependency( sat::SolvAttr::name, name_r, Rel::EQ, Edition(ver_r) ); + q.setStatusFilterFlags( installed_r ? PoolQuery::INSTALLED_ONLY : PoolQuery::UNINSTALLED_ONLY ); + if ( q.size() != 1 ) + ZYPP_THROW(Exception(q.size()?"Ambiguous!":"Missing!")); + return PoolItem( *q.begin() ); +} + +typedef std::pair<ByteCount,ByteCount> ByteSet; +namespace std +{ + inline std::ostream & operator<<( std::ostream & str, const ByteSet & obj ) + { return str << "<" << obj.first << "," << obj.second << ">"; } +} + +inline ByteSet mkByteSet( const DiskUsageCounter::MountPointSet & mps_r ) +{ return ByteSet( mps_r.begin()->commitDiff(), (++mps_r.begin())->commitDiff() ); } + +inline ByteSet mkByteSet( int grow_r , int norm_r ) +{ return ByteSet( ByteCount( grow_r, ByteCount::K ), ByteCount( norm_r, ByteCount::K ) ); } + +inline ByteSet getSize( const DiskUsageCounter & duc_r, const PoolItem & pi_r ) +{ return mkByteSet( duc_r.disk_usage( pi_r ) ); } + +inline ByteSet getSize( const DiskUsageCounter & duc_r, const ResPool & pool_r ) +{ return mkByteSet( duc_r.disk_usage( pool_r ) ); } + +inline void XLOG( const DiskUsageCounter & duc_r, const ResPool & pool_r ) +{ + for( const auto & pi : pool_r ) + { + USR << pi << endl; + } + WAR << duc_r.disk_usage( pool_r ) << endl; +} + +BOOST_AUTO_TEST_CASE(dudata) +{ + //KeyRingTestReceiver rec; + // rec.answerAcceptUnknownKey(true); + //rec.answerAcceptUnsignedFile(true); + // rec.answerImportKey(true); + + Pathname repodir( TEST_DIR ); + TestSetup test( Arch_x86_64 ); + test.loadTargetRepo( repodir/"system" ); + test.loadRepo( repodir/"repo", "repo" ); + + ResPool pool( ResPool::instance() ); + PoolItem ins( piFind( "dutest", "1.0", true ) ); + PoolItem up1( piFind( "dutest", "1.0" ) ); + PoolItem up2( piFind( "dutest", "2.0" ) ); + PoolItem up3( piFind( "dutest", "3.0" ) ); + + DiskUsageCounter duc( { DiskUsageCounter::MountPoint( "/grow", DiskUsageCounter::MountPoint::Hint_growonly ), + DiskUsageCounter::MountPoint( "/norm" ) } ); + //XLOG( duc, pool ); + + BOOST_CHECK_EQUAL( getSize( duc, ins ), mkByteSet( 5, 5 ) ); + BOOST_CHECK_EQUAL( getSize( duc, up1 ), mkByteSet( 15, 15 ) ); + BOOST_CHECK_EQUAL( getSize( duc, up2 ), mkByteSet( 45, 45 ) ); + BOOST_CHECK_EQUAL( getSize( duc, up3 ), mkByteSet( 0, 0 ) ); + + // delete installed size 5 g n + ins.status().setTransact( true, ResStatus::USER ); + BOOST_CHECK_EQUAL( getSize( duc, pool ), mkByteSet( 0, -5 ) ); + ins.status().setTransact( false, ResStatus::USER ); + + // install known DU size 15 g n + up1.status().setTransact( true, ResStatus::USER ); + BOOST_CHECK_EQUAL( getSize( duc, pool ), mkByteSet( 15, 15 ) ); // (multi)install (old stays) + ins.status().setTransact( true, ResStatus::USER ); + BOOST_CHECK_EQUAL( getSize( duc, pool ), mkByteSet( 15, 10 ) ); // update (old goes) + ins.status().setTransact( false, ResStatus::USER ); + up1.status().setTransact( false, ResStatus::USER ); + + // install unknown DU size 0/installed g n + up3.status().setTransact( true, ResStatus::USER ); + BOOST_CHECK_EQUAL( getSize( duc, pool ), mkByteSet( 5, 0 ) ); // (multi)install (n could be 5 too, but satsolver does not know about multinstall) + ins.status().setTransact( true, ResStatus::USER ); + BOOST_CHECK_EQUAL( getSize( duc, pool ), mkByteSet( 5, 0 ) ); // update (old goes) + ins.status().setTransact( false, ResStatus::USER ); + up3.status().setTransact( false, ResStatus::USER ); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/content new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/content --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/content 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/content 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,2 @@ +META SHA1 b75eeb1b3d231ccb6322c91417050520f992949c packages +META SHA1 cb96552f7a57eb21f3279310c1c339e6b22924d8 packages.DU diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/media.1/media new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/media.1/media --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/media.1/media 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/media.1/media 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,3 @@ +SUSE Linux Products GmbH +20070705102239 +1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,8 @@ +=Ver: 2.0 +##---------------------------------------- +=Pkg: dutest 1.0 1 x86_64 +##---------------------------------------- +=Pkg: dutest 2.0 1 x86_64 +##---------------------------------------- +=Pkg: dutest 3.0 1 x86_64 +##---------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages.DU new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages.DU --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages.DU 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/repo/suse/setup/descr/packages.DU 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,16 @@ +=Ver: 2.0 +##---------------------------------------- +## / localK subK localF subF +##---------------------------------------- +=Pkg: dutest 1.0 1 x86_64 ++Dir: +/norm 15 0 1 0 +/grow 15 0 1 0 +-Dir: +##---------------------------------------- +=Pkg: dutest 2.0 1 x86_64 ++Dir: +/norm 45 0 1 0 +/grow 45 0 1 0 +-Dir: +##---------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/content new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/content --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/content 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/content 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,2 @@ +META SHA1 95a347a40f621834a870e10b8914c9442c2dc355 packages +META SHA1 7d11955486b049be5f601b82acc18bfc73c22f39 packages.DU diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/media.1/media new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/media.1/media --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/media.1/media 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/media.1/media 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,3 @@ +SUSE Linux Products GmbH +20070705102239 +1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,4 @@ +=Ver: 2.0 +##---------------------------------------- +=Pkg: dutest 1.0 1 x86_64 +##---------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages.DU new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages.DU --- old/libzypp-14.28.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages.DU 1970-01-01 01:00:00.000000000 +0100 +++ new/libzypp-14.29.0/tests/repo/susetags/data/dudata/system/suse/setup/descr/packages.DU 2014-09-16 10:49:10.000000000 +0200 @@ -0,0 +1,10 @@ +=Ver: 2.0 +##---------------------------------------- +## / localK subK localF subF +##---------------------------------------- +=Pkg: dutest 1.0 1 x86_64 ++Dir: +/norm 5 0 1 0 +/grow 5 0 1 0 +-Dir: +##---------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/zypp/DiskUsageCounter.cc new/libzypp-14.29.0/zypp/DiskUsageCounter.cc --- old/libzypp-14.28.0/zypp/DiskUsageCounter.cc 2014-07-01 11:30:28.000000000 +0200 +++ new/libzypp-14.29.0/zypp/DiskUsageCounter.cc 2014-09-16 15:20:17.000000000 +0200 @@ -23,6 +23,7 @@ #include "zypp/base/String.h" #include "zypp/DiskUsageCounter.h" +#include "zypp/ExternalProgram.h" #include "zypp/sat/Pool.h" #include "zypp/sat/detail/PoolImpl.h" @@ -47,17 +48,18 @@ sat::Pool satpool( sat::Pool::instance() ); // init libsolv result vector with mountpoints - static const ::DUChanges _initdu = { 0, 0, 0 }; + static const ::DUChanges _initdu = { 0, 0, 0, 0 }; std::vector< ::DUChanges> duchanges( result.size(), _initdu ); { unsigned idx = 0; for_( it, result.begin(), result.end() ) { duchanges[idx].path = it->dir.c_str(); + if ( it->growonly ) + duchanges[idx].flags |= DUCHANGES_ONLYADD; ++idx; } } - // now calc... ::pool_calc_duchanges( satpool.get(), const_cast<Bitmap &>(installedmap_r), @@ -140,12 +142,12 @@ if ( !(procmounts.fail() || procmounts.bad()) ) { // data to consume - // rootfs / rootfs rw 0 0 + // rootfs / rootfs rw 0 0 // /dev/root / reiserfs rw 0 0 - // proc /proc proc rw 0 0 - // devpts /dev/pts devpts rw 0 0 + // proc /proc proc rw 0 0 + // devpts /dev/pts devpts rw 0 0 // /dev/hda5 /boot ext2 rw 0 0 - // shmfs /dev/shm shm rw 0 0 + // shmfs /dev/shm shm rw 0 0 // usbdevfs /proc/bus/usb usbdevfs rw 0 0 std::vector<std::string> words; @@ -231,28 +233,54 @@ // // Check whether mounted readonly // - bool ro = false; + MountPoint::HintFlags hints; + std::vector<std::string> flags; str::split( words[3], std::back_inserter(flags), "," ); for ( unsigned i = 0; i < flags.size(); ++i ) { if ( flags[i] == "ro" ) { - ro = true; + hints |= MountPoint::Hint_readonly; break; } } - if ( ro ) { + if ( hints.testFlag( MountPoint::Hint_readonly ) ) { DBG << "Filter ro mount point : " << l << std::endl; continue; } // + // check for snapshotting btrfs + // + if ( words[2] == "btrfs" ) + { + if ( geteuid() != 0 ) + { + DBG << "Assume snapshots on " << words[1] << ": non-root user can't check" << std::endl; + hints |= MountPoint::Hint_growonly; + } + else + { + // For now just check whether there is + // at least one snapshot on the volume: + ExternalProgram prog({"btrfs","subvolume","list","-s",words[1]}); + std::string line( prog.receiveLine() ); + if ( ! line.empty() ) + { + DBG << "Found a snapshot on " << words[1] << ": " << line; // has trailing std::endl + hints |= MountPoint::Hint_growonly; + } + prog.kill(); + } + } + + // // statvfs (full path!) and get the data // struct statvfs sb; if ( statvfs( words[1].c_str(), &sb ) != 0 ) { WAR << "Unable to statvfs(" << words[1] << "); errno " << errno << std::endl; - ret.insert( DiskUsageCounter::MountPoint( mp ) ); + ret.insert( DiskUsageCounter::MountPoint( mp, words[2], 0LL, 0LL, 0LL, 0LL, hints ) ); } else { @@ -264,9 +292,9 @@ DBG << "Filter zero-sized mount point : " << l << std::endl; continue; } - ret.insert( DiskUsageCounter::MountPoint( mp, sb.f_bsize, + 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, ro ) ); + ((long long)(sb.f_blocks - sb.f_bfree))*sb.f_bsize/1024, 0LL, hints ) ); } } } @@ -288,10 +316,13 @@ << " ts: " << obj.totalSize() << " us: " << obj.usedSize() << " (+-: " << obj.commitDiff() - << ")]"; + << ")" << (obj.readonly?"r":"") << (obj.growonly?"g":"") << " " << obj.fstype << "]"; return str; } + std::ostream & operator<<( std::ostream & str, const DiskUsageCounter::MountPointSet & obj ) + { return dumpRange( str, obj.begin(), obj.end() ); } + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-14.28.0/zypp/DiskUsageCounter.h new/libzypp-14.29.0/zypp/DiskUsageCounter.h --- old/libzypp-14.28.0/zypp/DiskUsageCounter.h 2014-07-01 11:30:28.000000000 +0200 +++ new/libzypp-14.29.0/zypp/DiskUsageCounter.h 2014-09-16 15:20:17.000000000 +0200 @@ -18,6 +18,7 @@ #include "zypp/ResPool.h" #include "zypp/Bitmap.h" +#include "zypp/base/Flags.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -40,25 +41,101 @@ /////////////////////////////////////////////////////////////////// struct MountPoint { + friend std::ostream & operator<<( std::ostream & str, const MountPoint & obj ); std::string dir; ///< Directory name + std::string fstype; ///< Filesystem type (provided by \ref detectMountPoints) long long block_size; ///< Block size of the filesystem in B (0 if you don't care) long long total_size; ///< Total size of the filesystem in KiB (0 if you don't care) long long used_size; ///< Used size of the filesystem in KiB (0 if you don't care) mutable long long pkg_size; ///< Used size after installation in KiB (computed by \ref DiskUsageCoutner) - bool readonly; ///< hint for readonly partitions + // hint bits: + bool readonly:1; ///< hint for readonly partitions + bool growonly:1; ///< hint for growonly partitions (e.g. snapshotting btrfs) + + + /** HinFlags for ctor */ + enum Hint + { + NoHint = 0, + Hint_readonly = (1<<0), ///< readonly partitions + Hint_growonly = (1<<1), ///< growonly partitions (e.g. snapshotting btrfs) + }; + ZYPP_DECLARE_FLAGS(HintFlags,Hint); + + /** Ctor initialize directory, fstype and sizes */ + MountPoint( const std::string & d = "/", + const std::string & f = std::string(), + long long bs = 0LL, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, + HintFlags hints = NoHint ) + : dir(d), fstype(f) + , block_size(bs), total_size(total), used_size(used), pkg_size(pkg) + , readonly(hints.testFlag(Hint_readonly)) + , growonly(hints.testFlag(Hint_growonly)) + {} + /** \overload <tt>const char *</tt> to allow e.g. initiailzer lists + * \code + * MountPointSet( { "/", "/usr", "/var" } ) + * \endcode + */ + MountPoint( const char * d, + const std::string & f = std::string(), + long long bs = 0LL, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, + HintFlags hints = NoHint ) + : MountPoint( std::string(d?d:""), f, bs, total, used, pkg, hints ) + {} + /** Ctor initialize directory and sizes */ - MountPoint( const std::string & d = "/", long long bs = 0LL, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, bool ro=false) - : dir(d), block_size(bs), total_size(total), used_size(used), pkg_size(pkg), readonly(ro) + MountPoint( const std::string & d, + long long bs, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, + HintFlags hints = NoHint ) + : MountPoint( d, std::string(), bs, total, used, pkg, hints ) + {} + /** \overload <tt>const char *</tt> */ + MountPoint( const char * d, + long long bs, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, + HintFlags hints = NoHint ) + : MountPoint( std::string(d?d:""), bs, total, used, pkg, hints ) + {} + + + /** Ctor just name and hints, all sizes 0 */ + MountPoint( const std::string & d, HintFlags hints ) + : MountPoint( d, std::string(), 0LL, 0LL, 0LL, 0LL, hints ) + {} + /** \overload <tt>const char *</tt> */ + MountPoint( const char * d, HintFlags hints ) + : MountPoint( std::string(d?d:""), hints ) + {} + /** \overload to prevent propagation Hint -> long long */ + MountPoint( const std::string & d, Hint hint ) + : MountPoint( d, HintFlags(hint) ) {} - /** \overload to allow e.g. initiailzer lists + /** \overload to prevent propagation Hint -> long long */ + MountPoint( const char * d, Hint hint ) + : MountPoint( std::string(d?d:""), HintFlags(hint) ) + {} + + + /** \deprecated Use HintFlags instead of a trailing 'bool ro' argument. * \code - * MountPointSet( { "/", "/usr", "/var" } ) + * - MountPoint( "/usr", ..., true ); // readonly + * + MountPoint( "/usr", ..., MountPoint::Hint_readonly ); * \endcode */ - MountPoint( const char * d, long long bs = 0LL, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, bool ro=false) - : dir(d?d:""), block_size(bs), total_size(total), used_size(used), pkg_size(pkg), readonly(ro) + ZYPP_DEPRECATED MountPoint( const std::string & d, long long bs, long long total, long long used, long long pkg, bool ro ) + : MountPoint( d, bs, total, used, pkg, HintFlags(ro?Hint_readonly:NoHint) ) {} + /** \deprecated Use HintFlags instead of a trailing 'bool ro' argument. + * \code + * - MountPoint( "/usr", ..., true ); // readonly + * + MountPoint( "/usr", ..., MountPoint::Hint_readonly ); + * \endcode + */ + ZYPP_DEPRECATED MountPoint( const char * d, long long bs, long long total, long long used, long long pkg, bool ro ) + : MountPoint( d, bs, total, used, pkg, HintFlags(ro?Hint_readonly:NoHint) ) + {} + /** Sort by directory name */ bool operator<( const MountPoint & rhs ) const @@ -112,8 +189,11 @@ const MountPointSet & getMountPoints() const { return _mps; } - - /** Get mountpoints of system below \a rootdir */ + /** Get mountpoints of system below \a rootdir + * If we happen to detect snapshotting btrfs partitions, the MountPoint::growonly + * hint is set. Disk usage computation will assume that deleted packages will not + * free any space (kept in a snapshot). + */ static MountPointSet detectMountPoints( const std::string & rootdir = "/" ); /** Only one entry for "/" to collect total sizes */ @@ -150,9 +230,18 @@ }; /////////////////////////////////////////////////////////////////// + ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags); + /** \relates DiskUsageCounter::MountPoint Stream output */ std::ostream & operator<<( std::ostream & str, const DiskUsageCounter::MountPoint & obj ); + /** \relates DiskUsageCounter::MountPointSet Stream output */ + std::ostream & operator<<( std::ostream & str, const DiskUsageCounter::MountPointSet & obj ); + + /** \relates DiskUsageCounter Stream output */ + inline std::ostream & operator<<( std::ostream & str, const DiskUsageCounter & obj ) + { return str << obj.getMountPoints(); } + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
