Explorar el Código

apt-pkg/contrib/cdromutl.{cc,h}: return string for mountpath; apt-pkg/cdrom.cc: use string

Michael Vogt hace 15 años
padre
commit
02aa6f6736
Se han modificado 3 ficheros con 12 adiciones y 7 borrados
  1. 8 3
      apt-pkg/cdrom.cc
  2. 3 3
      apt-pkg/contrib/cdromutl.cc
  3. 1 1
      apt-pkg/contrib/cdromutl.h

+ 8 - 3
apt-pkg/cdrom.cc

@@ -907,13 +907,18 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly)
       if (udevice == NULL)
 	 continue;
       const char* devnode = udev_device_get_devnode(udevice);
-      const char* mountpath = udev_device_get_property_value(udevice, "FSTAB_DIR");
-      if (mountpath == NULL)
+
+      // try fstab_dir first
+      string mountpath;
+      const char* mp = udev_device_get_property_value(udevice, "FSTAB_DIR");
+      if (mp)
+         mountpath = string(mp);
+      else
          mountpath = FindMountPointForDevice(devnode);
 
       // fill in the struct
       cdrom.DeviceName = string(devnode);
-      if (mountpath) {
+      if (mountpath != "") {
 	 cdrom.MountPath = mountpath;
 	 string s = string(mountpath);
 	 cdrom.Mounted = IsMounted(s);

+ 3 - 3
apt-pkg/contrib/cdromutl.cc

@@ -237,7 +237,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
 									/*}}}*/
 
 // FindMountPointForDevice - Find mountpoint for the given device      /*{{{*/
-char* FindMountPointForDevice(const char *devnode)
+string FindMountPointForDevice(const char *devnode)
 {
    char buf[255];
    char *out[10];
@@ -254,14 +254,14 @@ char* FindMountPointForDevice(const char *devnode)
          while ( fgets(buf, sizeof(buf), f) != NULL) {
             if (strncmp(buf, devnode, strlen(devnode)) == 0) {
                if(TokSplitString(' ', buf, out, 10))
-                  return strdup(out[1]);
+                  return string(out[1]);
             }
          }
          fclose(f);
       }
    }
    
-   return NULL;
+   return string();
 }
 
 

+ 1 - 1
apt-pkg/contrib/cdromutl.h

@@ -19,6 +19,6 @@ bool MountCdrom(string Path, string DeviceName="");
 bool UnmountCdrom(string Path);
 bool IdentCdrom(string CD,string &Res,unsigned int Version = 2);
 bool IsMounted(string &Path);
-char *FindMountPointForDevice(const char *device);
+string FindMountPointForDevice(const char *device);
 
 #endif