- struct statfs Buf;
- if (statfs(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,"%u %u",Buf.f_blocks*(Buf.f_bsize/1024),
- Buf.f_bfree*(Buf.f_bsize/1024));
- Hash.Add(S);
-
- Res = Hash.Result().Value();
- return true;
+ std::string S;
+ if (_config->FindB("Debug::identcdrom",false) == false)
+ {
+ 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
+ if (writable_media)
+ {
+ strprintf(S, "%lu", (unsigned long)(Buf.f_blocks*(Buf.f_bsize/1024)));
+ } else {
+ 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.c_str());
+ strprintf(S, "-%u", Version);
+ }
+ else
+ strprintf(S, "-%u.debug", Version);
+
+ Res = Hash.Result().Value() + S;
+ return true;
+}
+ /*}}}*/
+// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/
+string FindMountPointForDevice(const char *devnode)
+{
+ // this is the order that mount uses as well
+ std::vector<std::string> const mounts = _config->FindVector("Dir::state::MountPoints", "/etc/mtab,/proc/mount");
+
+ for (std::vector<std::string>::const_iterator m = mounts.begin(); m != mounts.end(); ++m)
+ if (FileExists(*m) == true)
+ {
+ char * line = NULL;
+ size_t line_len = 0;
+ FILE * f = fopen(m->c_str(), "r");
+ while(getline(&line, &line_len, f) != -1)
+ {
+ char * out[] = { NULL, NULL, NULL };
+ TokSplitString(' ', line, out, 3);
+ if (out[2] != NULL || out[1] == NULL || out[0] == NULL)
+ continue;
+ if (strcmp(out[0], devnode) != 0)
+ continue;
+ fclose(f);
+ // unescape the \0XXX chars in the path
+ string mount_point = out[1];
+ free(line);
+ return DeEscapeString(mount_point);
+ }
+ fclose(f);
+ free(line);
+ }
+
+ return string();