summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-09-10 13:57:49 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-09-10 13:57:49 +0200
commit14fe2f61665952d167141b979b8a1a653a56ec2d (patch)
treea34e08c1abd2174cc8e36eadb0325b3568a59aae /apt-pkg
parent1244ef2b9e0c35c0aa263e6740ca153e5800e7d6 (diff)
parent4dc7b4a76ee7344c2c7743ab8dd070b85bf6935a (diff)
merged from lp:~mvo/apt/mvo
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/cdromutl.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 129e4a9f6..68b980407 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -156,15 +156,18 @@ bool MountCdrom(string Path, string DeviceName)
bool IdentCdrom(string CD,string &Res,unsigned int Version)
{
MD5Summation Hash;
+ bool writable_media = false;
// if we are on a writable medium (like a usb-stick) that is just
// used like a cdrom don't use "." as it will constantly change,
// use .disk instead
- if (access(CD.c_str(), W_OK) == 0 && DirectoryExists(CD+string("/.disk"))) {
- CD = CD+string("/.disk");
+ if (access(CD.c_str(), W_OK) == 0 && DirectoryExists(CD+string("/.disk")))
+ {
+ writable_media = true;
+ CD = CD.append("/.disk");
if (_config->FindB("Debug::aptcdrom",false) == true)
- std::clog << "Found writable cdrom, using alternative path: "
- << CD.c_str() << std::endl;
+ std::clog << "Found writable cdrom, using alternative path: " << CD
+ << std::endl;
}
string StartDir = SafeGetCWD();
@@ -212,10 +215,15 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
struct statvfs Buf;
if (statvfs(CD.c_str(),&Buf) != 0)
return _error->Errno("statfs",_("Failed to stat the cdrom"));
-
+
// We use a kilobyte block size to advoid overflow
- sprintf(S,"%lu %lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)),
- (long)(Buf.f_bfree*(Buf.f_bsize/1024)));
+ if (writable_media)
+ {
+ sprintf(S,"%lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)));
+ } else {
+ sprintf(S,"%lu %lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)),
+ (long)(Buf.f_bfree*(Buf.f_bsize/1024)));
+ }
Hash.Add(S);
sprintf(S,"-%u",Version);
}