diff options
| author | Julian Andres Klode <jak@debian.org> | 2026-01-05 21:48:15 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2026-01-05 21:48:15 +0000 |
| commit | 0e3fc4c113b46e720a0732d54ca08df7029132f7 (patch) | |
| tree | 47461aa7a0005dad23af26285160bf5ac3a22001 | |
| parent | fdbcc2e297ed6e097b30298996710a4c0ec7fbd6 (diff) | |
| parent | 68968d8af49500c949d679de184a2201d9e56cbe (diff) | |
Merge branch 'infinite-tmpfs' into 'main'
apt-private/private-download.cc: support unlimited space tmpfs
See merge request apt-team/apt!515
| -rw-r--r-- | apt-private/private-download.cc | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index e3d425283..60cdfc9ec 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -127,6 +127,7 @@ bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failu bool CheckFreeSpaceBeforeDownload(std::string const &Dir, unsigned long long FetchBytes)/*{{{*/ { uint32_t const RAMFS_MAGIC = 0x858458f6; + uint32_t const TMPFS_MAGIC = 0x01021994; /* Check for enough free space, but only if we are actually going to download */ if (_config->FindB("APT::Get::Print-URIs", false) == true || @@ -142,22 +143,21 @@ bool CheckFreeSpaceBeforeDownload(std::string const &Dir, unsigned long long Fet return _error->Errno("statvfs",_("Couldn't determine free space in %s"), Dir.c_str()); } - else - { - unsigned long long const FreeBlocks = _config->Find("APT::Sandbox::User").empty() ? Buf.f_bfree : Buf.f_bavail; - if (FreeBlocks < (FetchBytes / Buf.f_bsize)) - { - struct statfs Stat; - if (statfs(Dir.c_str(),&Stat) != 0 + unsigned long long const FreeBlocks = _config->Find("APT::Sandbox::User").empty() ? Buf.f_bfree : Buf.f_bavail; + if (FreeBlocks >= (FetchBytes / Buf.f_bsize)) + return true; + struct statfs Stat; + if (statfs(Dir.c_str(), &Stat) != 0) + return _error->Error(_("Couldn't determine filesystem statistics of %s."), Dir.c_str()); + #ifdef HAVE_STRUCT_STATFS_F_TYPE - || Stat.f_type != RAMFS_MAGIC + if (Stat.f_type == RAMFS_MAGIC) + return true; + // do not run out of space on a tmpfs without a size limit (size is zero) + if (Stat.f_type == TMPFS_MAGIC && Buf.f_blocks == 0) + return true; #endif - ) - return _error->Error(_("You don't have enough free space in %s."), - Dir.c_str()); - } - } - return true; + return _error->Error(_("You don't have enough free space in %s."), Dir.c_str()); } /*}}}*/ |
