summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-07-24 09:09:59 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-07-24 09:09:59 +0200
commit4b2de6720d65c9e7a2cfded0da7d04d758a8e1e2 (patch)
tree304f2cf2ecaffdaf613139e9066bcb9ca845d1bf /apt-pkg/contrib
parent3e2d7cce4febc923d4b9bcb363717dd161cbb856 (diff)
parenteb162ff79b93ea98380f4555e0fe3116993241fb (diff)
merge from the donkult branch
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/mmap.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 229b18037..917466c2f 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -137,7 +137,6 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
}
/*}}}*/
- /*}}}*/
// DynamicMMap::DynamicMMap - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -173,11 +172,19 @@ DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long WorkSpace) :
return;
#ifdef _POSIX_MAPPED_FILES
+ // Set the permissions.
+ int Prot = PROT_READ;
+ int Map = MAP_PRIVATE | MAP_ANONYMOUS;
+ if ((Flags & ReadOnly) != ReadOnly)
+ Prot |= PROT_WRITE;
+ if ((Flags & Public) == Public)
+ Map = MAP_SHARED | MAP_ANONYMOUS;
+
// use anonymous mmap() to get the memory
- Base = (unsigned char*) mmap(0, WorkSpace, PROT_READ|PROT_WRITE,
- MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ Base = (unsigned char*) mmap(0, WorkSpace, Prot, Map, -1, 0);
+
if(Base == MAP_FAILED)
- return;
+ _error->Errno("DynamicMMap",_("Couldn't make mmap of %lu bytes"),WorkSpace);
#else
// fallback to a static allocated space
Base = new unsigned char[WorkSpace];