summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/cdromutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2015-06-23 12:17:35 +0100
committerMichael Vogt <mvo@debian.org>2015-06-23 12:17:35 +0100
commit245dde96193702f7f51389d3583dee547f8ba366 (patch)
tree6cf8c191641c760bcc6a6c08fb0ff65d27e0cffd /apt-pkg/contrib/cdromutl.cc
parent5530255b5f3ad7de2e23dfcb39ce325001126501 (diff)
parentc8a4ce6cbed57ae108dc955d4a850f9b129a0693 (diff)
Merge remote-tracking branch 'donkult/debian/experimental' into debian/experimental
Diffstat (limited to 'apt-pkg/contrib/cdromutl.cc')
-rw-r--r--apt-pkg/contrib/cdromutl.cc31
1 files changed, 16 insertions, 15 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 936e377fb..6eb917457 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -207,7 +207,6 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
/* Run over the directory, we assume that the reader order will never
change as the media is read-only. In theory if the kernel did
some sort of wacked caching this might not be true.. */
- char S[300];
for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
{
// Skip some files..
@@ -215,30 +214,32 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
strcmp(Dir->d_name,"..") == 0)
continue;
+ std::string S;
if (Version <= 1)
{
- sprintf(S,"%lu",(unsigned long)Dir->d_ino);
+ strprintf(S, "%lu", (unsigned long)Dir->d_ino);
}
else
{
struct stat Buf;
if (stat(Dir->d_name,&Buf) != 0)
continue;
- sprintf(S,"%lu",(unsigned long)Buf.st_mtime);
+ strprintf(S, "%lu", (unsigned long)Buf.st_mtime);
}
-
- Hash.Add(S);
+
+ Hash.Add(S.c_str());
Hash.Add(Dir->d_name);
};
-
+
if (chdir(StartDir.c_str()) != 0) {
_error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
closedir(D);
return false;
}
closedir(D);
-
+
// Some stats from the fsys
+ std::string S;
if (_config->FindB("Debug::identcdrom",false) == false)
{
struct statvfs Buf;
@@ -248,19 +249,19 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
// We use a kilobyte block size to advoid overflow
if (writable_media)
{
- sprintf(S,"%lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)));
+ strprintf(S, "%lu", (unsigned 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)));
+ strprintf(S, "%lu %lu", (unsigned long)(Buf.f_blocks*(Buf.f_bsize/1024)),
+ (unsigned long)(Buf.f_bfree*(Buf.f_bsize/1024)));
}
- Hash.Add(S);
- sprintf(S,"-%u",Version);
+ Hash.Add(S.c_str());
+ strprintf(S, "-%u", Version);
}
else
- sprintf(S,"-%u.debug",Version);
-
+ strprintf(S, "-%u.debug", Version);
+
Res = Hash.Result().Value() + S;
- return true;
+ return true;
}
/*}}}*/
// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/