// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cdromutl.cc,v 1.10 1999/12/10 06:30:42 jgg Exp $
+// $Id: cdromutl.cc,v 1.12 2001/02/20 07:03:17 jgg Exp $
/* ######################################################################
CDROM Utilities - Some functions to manipulate CDROM mounts.
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/cdromutl.h"
-#endif
#include <apt-pkg/cdromutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/configuration.h>
+#include <apti18n.h>
+
#include <sys/wait.h>
#include <sys/errno.h>
#include <sys/statvfs.h>
struct stat Buf,Buf2;
if (stat(Path.c_str(),&Buf) != 0 ||
stat((Path + "../").c_str(),&Buf2) != 0)
- return _error->Errno("stat","Unable to stat the mount point %s",Path.c_str());
+ return _error->Errno("stat",_("Unable to stat the mount point %s"),Path.c_str());
if (Buf.st_dev == Buf2.st_dev)
return false;
}
// Wait for mount
- return ExecWait(Child,"mount",true);
+ return ExecWait(Child,"umount",true);
}
/*}}}*/
// MountCdrom - Mount a cdrom /*{{{*/
// ---------------------------------------------------------------------
/* We fork mount and drop all messages */
-bool MountCdrom(string Path)
+bool MountCdrom(string Path, string DeviceName)
{
if (IsMounted(Path) == true)
return true;
{
const char *Args[10];
Args[0] = "mount";
- Args[1] = Path.c_str();
- Args[2] = 0;
+ if (DeviceName == "")
+ {
+ Args[1] = Path.c_str();
+ Args[2] = 0;
+ } else {
+ Args[1] = DeviceName.c_str();
+ Args[2] = Path.c_str();
+ Args[3] = 0;
+ }
execvp(Args[0],(char **)Args);
_exit(100);
}
string StartDir = SafeGetCWD();
if (chdir(CD.c_str()) != 0)
- return _error->Errno("chdir","Unable to change to %s",CD.c_str());
+ return _error->Errno("chdir",_("Unable to change to %s"),CD.c_str());
DIR *D = opendir(".");
if (D == 0)
- return _error->Errno("opendir","Unable to read %s",CD.c_str());
+ return _error->Errno("opendir",_("Unable to read %s"),CD.c_str());
/* 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
struct stat Buf;
if (stat(Dir->d_name,&Buf) != 0)
continue;
- sprintf(S,"%lu",Buf.st_mtime);
+ sprintf(S,"%lu",(unsigned long)Buf.st_mtime);
}
Hash.Add(S);
Hash.Add(Dir->d_name);
};
- chdir(StartDir.c_str());
+ if (chdir(StartDir.c_str()) != 0)
+ return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
closedir(D);
// Some stats from the fsys
{
struct statvfs Buf;
if (statvfs(CD.c_str(),&Buf) != 0)
- return _error->Errno("statfs","Failed to stat the cdrom");
+ 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)),