From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aurelien Jarno Date: Thu, 26 Jan 2006 09:45:17 +0000 Subject: Re: [Libusb-devel] udev craze: need /dev/bus/usb rationale Message-Id: <20060126094517.GA4063@bode.aurel32.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Wed, Jan 25, 2006 at 09:37:09PM +0100, Linus Walleij wrote: > Having fun making packages for Fedora we have run into a coordination > issue between udev and libusb. > > As you know libusb programs (like SANE custom USB backends or my own pet > libnjb) use raw device nodes with no kernel drivers attached to them. A > suitable udev rule found in this mail: > > http://sourceforge.net/mailarchive/message.php?msg_id695893 > > looks like this: > > SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} > B=$${X%%%%.*} > D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK="%c" > > has been applied to most distributions set of default rules. (Well Debian > and Fedora atleast, I guess SuSE too.) Wrong! Debian uses the following rule: # usbfs-like devices SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", \ NAME="%c" with the following patch to libusb to open /dev/bus/usb prior to /proc/bus/usb: --- libusb-0.1.11.orig/linux.c +++ libusb-0.1.11/linux.c @@ -633,14 +633,11 @@ } if (!usb_path[0]) { - if (check_usb_vfs("/proc/bus/usb")) { - strncpy(usb_path, "/proc/bus/usb", sizeof(usb_path) - 1); - usb_path[sizeof(usb_path) - 1] = 0; - } else if (check_usb_vfs("/sys/bus/usb")) { /* 2.6 Kernel with sysfs */ - strncpy(usb_path, "/sys/bus/usb", sizeof(usb_path) -1); + if (check_usb_vfs("/dev/bus/usb")) { + strncpy(usb_path, "/dev/bus/usb", sizeof(usb_path) - 1); usb_path[sizeof(usb_path) - 1] = 0; - } else if (check_usb_vfs("/dev/usb")) { - strncpy(usb_path, "/dev/usb", sizeof(usb_path) - 1); + } else if (check_usb_vfs("/proc/bus/usb")) { + strncpy(usb_path, "/proc/bus/usb", sizeof(usb_path) - 1); usb_path[sizeof(usb_path) - 1] = 0; } else usb_path[0] = 0; /* No path, no USB support */ > This rule creates a dynamic device hierarchy belowe /dev/bus/usb similar > to the good 'ol /proc/bus/usb and everyone is happy. Libusb was patched > to support this device hierarchy. But wait. We found an inconsistency: > that script will create hex-named nodes: > > /dev/bus/usb/01AB1/01BCF On Debian, the names are in the form /dev/bus/usb/002/004, ie the same format as in /proc/bus/usb. > But we need a clear rationale: > > * How shall /dev/bus/usb subdirs and device files be named? As those names are exported to the application (via usb_bus.dirname and usb_device.filename), they should be named exactly the same way as in /proc/bus/usb to keep the compatibility. Otherwise, it would break some applications. Debian have used the /dev/bus/usb/%%i/%%i format (ie something like /dev/bus/usb/2/4), and it brokes some applications like openct. > * If they shall be all decimal figures, change all rules accordingly and > libusb will work fine as it is. IMHO, this is the way to go. > * If they shall be hex, make the above suggested change to libusb. In such case, the API of libusb should be changed to also export the full name of the device node, so that application can use them directly instead of using usb_bus.dirname and usb_device.filename). Bye, Aurelien -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel