]> git.saurik.com Git - apt.git/commitdiff
cherry pick (2) from lp:~mvo/apt/mvo
authorMichael Vogt <michael.vogt@ubuntu.com>
Wed, 9 Mar 2011 11:16:12 +0000 (12:16 +0100)
committerMichael Vogt <michael.vogt@ubuntu.com>
Wed, 9 Mar 2011 11:16:12 +0000 (12:16 +0100)
apt-pkg/cdrom.cc
apt-pkg/contrib/cdromutl.cc
apt-pkg/contrib/cdromutl.h

index 86fe45fbe11c57b95f9eaa6b7f4e81503c7b02d2..1e084bfb52685e26b31628ac09a043826bc6167a 100644 (file)
@@ -895,8 +895,13 @@ pkgUdevCdromDevices::Scan()                                             /*{{{*/
       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);
 
       if (_config->FindB("Debug::Acquire::cdrom", false))
@@ -904,7 +909,7 @@ pkgUdevCdromDevices::Scan()                                             /*{{{*/
 
       // fill in the struct
       cdrom.DeviceName = string(devnode);
-      if (mountpath) {
+      if (mountpath != "") {
         cdrom.MountPath = mountpath;
         string s = string(mountpath);
         cdrom.Mounted = IsMounted(s);
index cf1c0c29bf02edaa476988f680f029701892df00..83c324f543bfdadf035ef21dda531eb2c49a41e1 100644 (file)
@@ -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();
 }
 
 
index 4f0f903477dbd32a8c0240271dfd64fdfba482bd..38ed2996ee79d0a3a4b8815c37a525bcaae39476 100644 (file)
@@ -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