Re: udev rule and libusb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bryan Kadzban wrote:
Michal Soltys wrote:
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c",
SYSFS{idProduct}=="0101", ENV{DEVICE}!="", \
NAME="dsiproII" SYMLINK+="dsiproII.%n" MODE="0666"
Hmm, is it exactly as in your files ? There's missing comma between
SYMLINK and MODE, both in single and double rule - maybe that's the
culprit.
And also between NAME and SYMLINK in this rule -- I suspect there's no
symlink anymore either with this rule.  :-)
That is exactly how it is. And there is a symlink. But, point taken, I've got an (at least technically) invalid rule that may not be working as it is supposed to.

So I fixed the line to include the comma:

# 1. Pre-renumeration IDs
# Meade DSI Pro II
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c", SYSFS{idProduct}=="0100", ENV{DEVICE}!="", \ RUN+="/sbin/fxload -t fx2 -D $ENV{DEVICE} -I /lib/firmware/meade-dsiproII.hex"

# 2. Post-renumeration IDs
# Meade DSI Pro II
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c", SYSFS{idProduct}=="0101", ENV{DEVICE}!="", \
SYMLINK+="dsiproII.%n", MODE="0666"

Same symptons, permissions on /dev/bus/... device are not set:

[root@aristarchus src]# ls -l /dev/dsi*
lrwxrwxrwx 1 root root 15 2008-06-01 13:25 /dev/dsiproII.5 -> bus/usb/001/022
[root@aristarchus src]# ls -lL /dev/dsi*
crw-r--r-- 1 root root 189, 21 2008-06-01 13:25 /dev/dsiproII.5

With this rule:

# 1. Pre-renumeration IDs
# Meade DSI Pro II
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c", SYSFS{idProduct}=="0100", ENV{DEVICE}!="", \ RUN+="/sbin/fxload -t fx2 -D $ENV{DEVICE} -I /lib/firmware/meade-dsiproII.hex"

# 2. Post-renumeration IDs
# Meade DSI Pro II
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="156c", SYSFS{idProduct}=="0101", ENV{DEVICE}!="", \
NAME="dsiproII", SYMLINK+="dsiproII.%n", MODE="0666"

I end up with the devices below, but my code cannot find the device when scanning all buses/devices.

[root@aristarchus src]# ls -lL /dev/dsi*
crw-rw-rw- 1 root root 189, 19 2008-06-01 13:22 /dev/dsiproII
crw-rw-rw- 1 root root 189, 19 2008-06-01 13:22 /dev/dsiproII.5
[root@aristarchus src]# ./dumper
No suitable devices found, aborting

(Also, FWIW: setting NAME means that the device node will not be created
at its default location.  NAME moves the node; it doesn't copy it or
anything like that.  That's why you don't get the /dev/bus/usb/*/* node
when this rule is present: because the NAME is set.  SYMLINK (as in your
first rule) is usually a better way to handle this.)
I can live with this and just use my first rule if I can get the permissions fixed. My other alternative for permission is to use a pam rule to change the owner to the console user. But I cant figure out how to set up SElinux to allow that one when in enforcing mode.

And I can live with the second ruleset if I can figure out how to open a device that I didn't find by iterating over bus->devices. What is the way to set up a usb device that isn't in the usual location. My code fragment to find the device is below. This doesn't work when I use NAME. How do I use usb_open() directly on a device node?

int main(int argc, char **argv)
{

   const int SIZE = 4096;
   char *data = new char[SIZE];

   usb_init();
   usb_find_busses();
   usb_find_devices();

   // This searches for the first initialized Meade DSI Pro II
   struct usb_device *dev = 0;
   struct usb_dev_handle *handle = 0;
for (struct usb_bus *bus = usb_get_busses(); bus != 0; bus = bus->next) {
       for (dev = bus->devices; dev != 0; dev = dev->next) {
           if ((  (dev->descriptor.idVendor = 0x156c))
               && ((  (dev->descriptor.idProduct == 0x0101))
                   || (0 == 1))) {

fprintf(stderr, "Found device %04x:%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
               handle = usb_open(dev);
               // XXX: The libusb docs say something about claiming the
               // interface.  I have no idea what that means and this is
               // working.
               if (handle == 0) {
                   fprintf(stderr, "Failed to open device, aborting\n");
                   exit(1);
               }
           }
           break;
       }
       if (handle != 0)
           break;
   }

   if (handle == 0) {
       fprintf(stderr, "No suitable devices found, aborting\n");
       exit(1);
   }
...

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIQUOHS5vET1Wea5wRA9OEAJ9Z76a4edn8FvXxa08BpLRHNDVyrgCfd1ql
sBkCyx54x1kOqgAst7PQYRs=
=Xbjw
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
		       PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
roland@xxxxxxxxxxx                            6818 Madeline Court
roland@xxxxxxxxxxxxx                           Brooklyn, NY 11220

--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux