summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cdrom.cc4
-rw-r--r--apt-pkg/contrib/fileutl.cc2
-rw-r--r--apt-pkg/contrib/mmap.cc16
-rw-r--r--apt-pkg/indexcopy.cc7
4 files changed, 16 insertions, 13 deletions
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 8462e8286..699f66fb3 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -413,8 +413,8 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf)
Out.close();
- if (FileExists(DFile) == true && link(DFile.c_str(),string(DFile + '~').c_str()) != 0)
- return _error->Errno("link", "Failed to link %s to %s~", DFile.c_str(), DFile.c_str());
+ if (FileExists(DFile) == true)
+ rename(DFile.c_str(), string(DFile + '~').c_str());
if (rename(NewFile.c_str(),DFile.c_str()) != 0)
return _error->Errno("rename","Failed to rename %s.new to %s",
DFile.c_str(),DFile.c_str());
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 119cd1974..90e49cbfa 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1748,13 +1748,11 @@ bool FileFd::Close()
/* */
bool FileFd::Sync()
{
-#ifdef _POSIX_SYNCHRONIZED_IO
if (fsync(iFd) != 0)
{
Flags |= Fail;
return _error->Errno("sync",_("Problem syncing the file"));
}
-#endif
return true;
}
/*}}}*/
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 3e6ef3520..a176da636 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -156,11 +156,10 @@ bool MMap::Close(bool DoSync)
/* This is done in syncronous mode - the docs indicate that this will
not return till all IO is complete */
bool MMap::Sync()
-{
+{
if ((Flags & UnMapped) == UnMapped)
return true;
-
-#ifdef _POSIX_SYNCHRONIZED_IO
+
if ((Flags & ReadOnly) != ReadOnly)
{
if (SyncToFd != NULL)
@@ -170,11 +169,12 @@ bool MMap::Sync()
}
else
{
+#ifdef _POSIX_SYNCHRONIZED_IO
if (msync((char *)Base, iSize, MS_SYNC) < 0)
return _error->Errno("msync", _("Unable to synchronize mmap"));
+#endif
}
}
-#endif
return true;
}
/*}}}*/
@@ -185,9 +185,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
{
if ((Flags & UnMapped) == UnMapped)
return true;
-
-#ifdef _POSIX_SYNCHRONIZED_IO
- unsigned long long PSize = sysconf(_SC_PAGESIZE);
+
if ((Flags & ReadOnly) != ReadOnly)
{
if (SyncToFd != 0)
@@ -198,11 +196,13 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
}
else
{
+#ifdef _POSIX_SYNCHRONIZED_IO
+ unsigned long long const PSize = sysconf(_SC_PAGESIZE);
if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
return _error->Errno("msync", _("Unable to synchronize mmap"));
+#endif
}
}
-#endif
return true;
}
/*}}}*/
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index e29e2819c..c97445326 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -810,9 +810,14 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
(*I).c_str() + CDROM.length());
string TargetF = _config->FindDir("Dir::State::lists") + "partial/";
TargetF += URItoFileName(S);
+ FileFd Target;
if (_config->FindB("APT::CDROM::NoAct",false) == true)
+ {
TargetF = "/dev/null";
- FileFd Target(TargetF,FileFd::WriteAtomic);
+ Target.Open(TargetF,FileFd::WriteExists);
+ } else {
+ Target.Open(TargetF,FileFd::WriteAtomic);
+ }
FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
if (_error->PendingError() == true)
return false;