diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-07-24 09:09:59 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-07-24 09:09:59 +0200 |
commit | 4b2de6720d65c9e7a2cfded0da7d04d758a8e1e2 (patch) | |
tree | 304f2cf2ecaffdaf613139e9066bcb9ca845d1bf /apt-pkg | |
parent | 3e2d7cce4febc923d4b9bcb363717dd161cbb856 (diff) | |
parent | eb162ff79b93ea98380f4555e0fe3116993241fb (diff) | |
download | apt-4b2de6720d65c9e7a2cfded0da7d04d758a8e1e2.tar.gz |
merge from the donkult branch
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/mmap.cc | 15 | ||||
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 20 |
2 files changed, 21 insertions, 14 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]; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index ffc8d7816..68180c702 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -372,7 +372,7 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver, // Link it to the end of the list map_ptrloc *Last = &Ver->FileList; - for (pkgCache::VerFileIterator V = Ver.FileList(); V != 0 && V.end() == false; V++) + for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++) Last = &V->NextFile; VF->NextFile = *Last; *Last = VF.Index(); @@ -428,7 +428,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc, // Link it to the end of the list map_ptrloc *Last = &Desc->FileList; - for (pkgCache::DescFileIterator D = Desc.FileList(); D != 0 && D.end() == false; D++) + for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++) Last = &D->NextFile; DF->NextFile = *Last; @@ -518,7 +518,7 @@ bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver, if (OldDepVer != Ver) { OldDepLast = &Ver->DependsList; - for (pkgCache::DepIterator D = Ver.DependsList(); D != 0 && D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) OldDepLast = &D->NextDepends; OldDepVer = Ver; } @@ -670,7 +670,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start, // Map it FileFd CacheF(CacheFile,FileFd::ReadOnly); - SPtr<MMap> Map = new MMap(CacheF,MMap::Public | MMap::ReadOnly); + SPtr<MMap> Map = new MMap(CacheF,0); pkgCache Cache(Map); if (_error->PendingError() == true || Map->Size() == 0) { @@ -854,7 +854,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, else { // Just build it in memory.. - Map = new DynamicMMap(MMap::Public,MapSize); + Map = new DynamicMMap(0,MapSize); } // Lets try the source cache. @@ -866,8 +866,9 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, // Preload the map with the source cache FileFd SCacheF(SrcCacheFile,FileFd::ReadOnly); unsigned long alloc = Map->RawAllocate(SCacheF.Size()); - if (alloc == 0 || SCacheF.Read((unsigned char *)Map->Data() + alloc, - SCacheF.Size()) == false) + if ((alloc == 0 && _error->PendingError()) + || SCacheF.Read((unsigned char *)Map->Data() + alloc, + SCacheF.Size()) == false) return false; TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end()); @@ -928,7 +929,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, if (CacheF != 0) { delete Map.UnGuard(); - *OutMap = new MMap(*CacheF,MMap::Public | MMap::ReadOnly); + *OutMap = new MMap(*CacheF,0); } else { @@ -950,8 +951,7 @@ bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) if (_system->AddStatusFiles(Files) == false) return false; - SPtr<DynamicMMap> Map; - Map = new DynamicMMap(MMap::Public,MapSize); + SPtr<DynamicMMap> Map = new DynamicMMap(0,MapSize); unsigned long CurrentSize = 0; unsigned long TotalSize = 0; |