]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/cdromutl.cc
Fixed ftp resume
[apt.git] / apt-pkg / contrib / cdromutl.cc
index 7f79e878a0d188ede4f8fe00d78dfaa9f81bd169..dae6f052848925287692a0d1ef5869f0d525cf0c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cdromutl.cc,v 1.7 1999/07/02 22:21:01 jgg Exp $
+// $Id: cdromutl.cc,v 1.11 1999/12/10 23:40:29 jgg Exp $
 /* ######################################################################
    
    CDROM Utilities - Some functions to manipulate CDROM mounts.
@@ -21,7 +21,7 @@
 
 #include <sys/wait.h>
 #include <sys/errno.h>
-#include <sys/vfs.h>
+#include <sys/statvfs.h>
 #include <dirent.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -93,18 +93,7 @@ bool UnmountCdrom(string Path)
    }
 
    // Wait for mount
-   int Status = 0;
-   while (waitpid(Child,&Status,0) != Child)
-   {
-      if (errno == EINTR)
-        continue;
-      return _error->Errno("waitpid","Couldn't wait for subprocess");
-   }
-   
-   // Check for an error code.
-   if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
-      return false;
-   return true;
+   return ExecWait(Child,"mount",true);
 }
                                                                        /*}}}*/
 // MountCdrom - Mount a cdrom                                          /*{{{*/
@@ -142,18 +131,7 @@ bool MountCdrom(string Path)
    }
 
    // Wait for mount
-   int Status = 0;
-   while (waitpid(Child,&Status,0) != Child)
-   {
-      if (errno == EINTR)
-        continue;
-      return _error->Errno("waitpid","Couldn't wait for subprocess");
-   }
-   
-   // Check for an error code.
-   if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
-      return false;
-   return true;
+   return ExecWait(Child,"mount",true);
 }
                                                                        /*}}}*/
 // IdentCdrom - Generate a unique string for this CD                   /*{{{*/
@@ -185,14 +163,14 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
 
       if (Version <= 1)
       {
-        sprintf(S,"%lu",Dir->d_ino);
+        sprintf(S,"%lu",(unsigned long)Dir->d_ino);
       }
       else
       {
         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);
@@ -205,8 +183,8 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
    // Some stats from the fsys
    if (_config->FindB("Debug::identcdrom",false) == false)
    {
-      struct statfs Buf;
-      if (statfs(CD.c_str(),&Buf) != 0)
+      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