X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/5e9d46df79517125d0fd72e7671f5e0995746677..6e7c6c3f58193fd5db3d9d598ac65a1571522a58:/apt-pkg/contrib/mmap.cc diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index e395e6cc7..04a45811b 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -21,10 +21,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/mmap.h" -#endif - #define _BSD_SOURCE #include #include @@ -35,6 +31,8 @@ #include #include #include + +#include /*}}}*/ // MMap::MMap - Constructor /*{{{*/ @@ -119,7 +117,7 @@ bool MMap::Sync() #ifdef _POSIX_SYNCHRONIZED_IO if ((Flags & ReadOnly) != ReadOnly) - if (msync((char *)Base,iSize,MS_SYNC) != 0) + if (msync((char *)Base,iSize,MS_SYNC) < 0) return _error->Errno("msync","Unable to write mmap"); #endif return true; @@ -136,7 +134,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) #ifdef _POSIX_SYNCHRONIZED_IO unsigned long PSize = sysconf(_SC_PAGESIZE); if ((Flags & ReadOnly) != ReadOnly) - if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) != 0) + if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0) return _error->Errno("msync","Unable to write mmap"); #endif return true; @@ -194,7 +192,8 @@ DynamicMMap::~DynamicMMap() unsigned long EndOfFile = iSize; iSize = WorkSpace; Close(false); - ftruncate(Fd->Fd(),EndOfFile); + if(ftruncate(Fd->Fd(),EndOfFile) < 0) + _error->Errno("ftruncate", _("Failed to truncate file")); } /*}}}*/ // DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space /*{{{*/ @@ -211,7 +210,8 @@ unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln) // Just in case error check if (Result + Size > WorkSpace) { - _error->Error("Dynamic MMap ran out of room"); + _error->Error(_("Dynamic MMap ran out of room. Please increase the size " + "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace); return 0; } @@ -273,7 +273,8 @@ unsigned long DynamicMMap::WriteString(const char *String, // Just in case error check if (Result + Len > WorkSpace) { - _error->Error("Dynamic MMap ran out of room"); + _error->Error(_("Dynamic MMap ran out of room. Please increase the size " + "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace); return 0; }