Hello !

Jim Paris wrote:
> Yes, with pmount 0.9.14-1, I see this problem.
> 
>   psychosis:~$ uname -a
>   Linux psychosis 2.6.20.4 #1 SMP Wed Mar 28 13:59:31 EDT 2007 x86_64 
> GNU/Linux
>   psychosis:~$ zgrep CONFIG_SYSFS_DEPRECATED /proc/config.gz 
>   # CONFIG_SYSFS_DEPRECATED is not set
> 
> The "bus" attribute is never filled in the sysfs_device structure, as
> indicated by the debug logs posted by BenoƮt -- note the "bus )" in
> the find_bus_ancestry errors.  So pmount never realizes that the device is 
> a USB disk.

  I think I now understand what is the problem... I've just written a
fix that could work. Can you try the attached patch (against 0.9.14) ?
The problem is that I can't test it in 'real conditions' as my devices
are all reported as 'removable' by the kernel. However, from the tests,
I think it should work.

  Alternatively, you can get the latest development version using bzr with

bzr branch http://pmount.alioth.debian.org/bzr/pmount

  It is pretty much the same as 0.9.14 + patch.

  Thanks !

        Vincent
=== modified file 'src/policy.c'
--- src/policy.c        2007-06-16 09:54:15 +0000
+++ src/policy.c        2007-06-25 23:18:59 +0000
@@ -41,6 +41,8 @@
 int
 find_bus_ancestry( struct sysfs_device* dev, char** buses ) {
     char **i;
+    struct sysfs_bus * bus;
+    struct sysfs_device * found;
 
     if( !buses ) {
         debug ( "find_bus_ancestry: no buses to check, fail\n" );
@@ -59,13 +61,58 @@
             return 1;
         }
     }
+    /* Try the hard way */
+    if(find_device_in_buses(dev, buses))
+      return 1;
 
-    debug ( "find_bus_ancestry: device %s (path %s, bus %s) does not match, 
trying parent\n", 
+    debug ( "find_bus_ancestry: device '%s' (path '%s', bus '%s') "
+           "does not match, trying parent\n", 
             dev->name, dev->path, dev->bus );
+/*     debug ( "find_bus_ancestry: extra info: name %s\tpath %s\t" */
+/*         "bus %s\tbus-id %s", dev->name, dev->path, dev->bus, */
+/*         dev->bus_id); */
     return find_bus_ancestry( sysfs_get_device_parent( dev ), buses );
 }
 
 /**
+ * Check whether a particular device is found in a list of buses.
+ * @param dev sysfs device
+ * @param buses NULL-terminated array of bus names to scan for
+ * @return 0 if not found, 1 if found
+ */
+
+int
+find_device_in_buses( struct sysfs_device * dev, char** buses) {
+  struct sysfs_bus * bus;
+  struct sysfs_device * found;
+  char ** i;
+
+  for(i = buses; *i; ++i) 
+    {
+      bus = sysfs_open_bus(*i);
+      if(bus)
+       {
+         debug("find_device_in_buses : "
+               "successfully opened bus '%s' path '%s'\n",
+               bus->name, bus->path);
+         found = sysfs_get_bus_device(bus,dev->bus_id);
+         if(found)
+           {
+             debug("find_device_in_buses : "
+                   "found '%s' in bus '%s'\n",
+                   dev->name, *i);
+             sysfs_close_bus(bus);
+             return 1;         /* We found  it !*/
+           }
+         sysfs_close_bus(bus);
+       }
+    }
+  return 0;
+}
+
+
+
+/**
  * Find sysfs node that matches the major and minor device number of the given
  * device. Exit the process immediately on errors.
  * @param dev device node to search for (e. g. /dev/sda1)

Reply via email to