14#include <sys/statvfs.h>
22#include <zypp-core/base/DtorReset>
51 static const ::DUChanges _initdu = { 0, 0, 0, 0 };
52 std::vector< ::DUChanges> duchanges( result.size(), _initdu );
55 for_( it, result.begin(), result.end() )
57 duchanges[idx].path = it->dir.c_str();
59 duchanges[idx].flags |= DUCHANGES_ONLYADD;
64 ::pool_calc_duchanges( satpool.get(),
65 const_cast<Bitmap &
>(installedmap_r),
72 for_( it, result.begin(), result.end() )
78 it->pkg_size = it->used_size
79 + duchanges[idx].kbytes
80 + ( duchanges[idx].files * ( it->fstype ==
"btrfs" ? 4096 : it->block_size ) / blockAdjust );
100 if (
it->status().isInstalled() !=
it->status().transacts() )
133 typedef std::map<std::string, MountPoint>
Btrfsfilter;
139 WAR <<
"Unable to read /proc/mounts" << std::endl;
159 std::vector<std::string>
words;
162 if (
words.size() < 3 ) {
163 WAR <<
"Suspicious entry in /proc/mounts: " <<
l << std::endl;
170 if (
words[0].find(
'/' ) == std::string::npos ) {
171 DBG <<
"Discard mount point : " <<
l << std::endl;
176 if (
words[0] ==
"/proc")
178 DBG <<
"Discard /proc filesystem: " <<
l << std::endl;
187 if (
mp.compare( 0,
prfx.size(),
prfx ) != 0 ) {
189 DBG <<
"Unwanted mount point : " <<
l << std::endl;
193 mp.erase( 0,
prfx.size() );
196 }
else if (
mp[0] !=
'/' ) {
198 DBG <<
"Unwanted mount point : " <<
l << std::endl;
206 if (
words[2] ==
"iso9660" ) {
207 DBG <<
"Discard cdrom : " <<
l << std::endl;
213 MIL <<
words[1] <<
" contains ignored fs (" <<
words[2] <<
')' << std::endl;
221 "/mnt",
"/media",
"/mounts",
"/floppy",
"/cdrom",
222 "/suse",
"/tmp",
"/var/tmp",
"/var/adm/mount",
"/var/adm/YaST",
228 std::string pre( *
nomp );
229 if (
mp.compare( 0, pre.size(), pre ) == 0
230 && (
mp.size() == pre.size() ||
mp[pre.size()] ==
'/' ) ) {
235 DBG <<
"Filter mount point : " <<
l << std::endl;
242 MountPoint::HintFlags
hints;
244 std::vector<std::string> flags;
247 for (
unsigned i = 0;
i < flags.size(); ++
i ) {
248 if ( flags[
i] ==
"ro" ) {
254 DBG <<
"Filter ro mount point : " <<
l << std::endl;
262 if (
words[2] ==
"btrfs" )
267 DBG <<
"Assume snapshots on " <<
words[1] <<
": non-root user can't check" << std::endl;
275 std::string
line(
prog.receiveLine() );
276 if ( !
line.empty() )
278 DBG <<
"Found a snapshot on " <<
words[1] <<
": " <<
line;
290 WAR <<
"Unable to statvfs(" <<
words[1] <<
"); errno " <<
errno << std::endl;
298 if (
sb.f_blocks == 0 ||
sb.f_bsize == 0 )
300 DBG <<
"Filter zero-sized mount point : " <<
l << std::endl;
312 if (
bmp.fstype.empty() )
315 ((
long long)
sb.f_blocks)*
sb.f_bsize/1024,
316 ((
long long)(
sb.f_blocks -
sb.f_bfree))*
sb.f_bsize/1024, 0
LL,
hints );
318 else if (
bmp.dir >
mp )
323 ((
long long)
sb.f_blocks)*
sb.f_bsize/1024,
324 ((
long long)(
sb.f_blocks -
sb.f_bfree))*
sb.f_bsize/1024, 0
LL,
hints ) );
332 ret.insert( std::move(
bmp.second) );
346 str <<
"dir:[" <<
obj.dir <<
"] [ bs: " <<
obj.blockSize()
347 <<
" ts: " <<
obj.totalSize()
348 <<
" us: " <<
obj.usedSize()
349 <<
" (+-: " <<
obj.commitDiff()
350 <<
")" << (
obj.readonly?
"r":
"") << (
obj.growonly?
"g":
"") <<
" " <<
obj.fstype <<
"]";
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
static const Unit K
1024 Byte
static MountPointSet justRootPartition()
Only one entry for "/" to collect total sizes.
MountPointSet disk_usage(const ResPool &pool) const
Compute disk usage if the current transaction woud be commited.
static MountPointSet detectMountPoints(const std::string &rootdir="/")
Get mountpoints of system below rootdir If we happen to detect snapshotting btrfs partitions,...
std::set< MountPoint > MountPointSet
Assign a vaiable a certain value when going out of scope.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Libsolv (bit)Map wrapper.
size_type size() const
Size of the Map.
static constexpr PoolSizeType poolSize
An object indicating the bitmap should match the current pools capacity.
static Pool instance()
Singleton ctor.
A Solvable object within the sat Pool.
String related utilities and Regular expression matching.
std::string getline(std::istream &str, const Trim trim_r)
Return stream content up to (but not returning) the next newline.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Mount point description If block_size is set DiskUsageCoutner will assume half a block_size is wasted...
@ Hint_readonly
readonly partitions
@ Hint_growonly
growonly partitions (e.g. snapshotting btrfs)
To Solvable transform functor.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.