]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/mmap.cc
Clarify the --help for 'purge' (LP: #243948)
[apt.git] / apt-pkg / contrib / mmap.cc
index e395e6cc74f5c6741a4220cdbb19935e81d1457a..04a45811b63351a5fe00d4d7cd1466fcc88e65de 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/mmap.h"
-#endif 
-
 #define _BSD_SOURCE
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/error.h>
@@ -35,6 +31,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
+
+#include <cstring>
                                                                        /*}}}*/
 
 // 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;
    }