linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [Libusb-devel] udev craze: need /dev/bus/usb rationale
@ 2006-01-26  9:45 Aurelien Jarno
  2006-01-26 10:16 ` Linus Walleij
                   ` (30 more replies)
  0 siblings, 31 replies; 32+ messages in thread
From: Aurelien Jarno @ 2006-01-26  9:45 UTC (permalink / raw)
  To: linux-hotplug

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_id\x12695893
> 
> 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&kid\x103432&bid#0486&dat\x121642
_______________________________________________
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

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2006-02-07  0:23 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-26  9:45 [Libusb-devel] udev craze: need /dev/bus/usb rationale Aurelien Jarno
2006-01-26 10:16 ` Linus Walleij
2006-01-27  2:08 ` Johannes Erdfelt
2006-01-27  2:17 ` Kay Sievers
2006-01-27  2:25 ` Greg KH
2006-01-27  2:26 ` Johannes Erdfelt
2006-01-27  3:01 ` Kay Sievers
2006-01-27  3:17 ` Greg KH
2006-01-27  3:38 ` Charles Lepple
2006-01-27  3:51 ` Kay Sievers
2006-01-27  3:53 ` Kay Sievers
2006-01-27  4:01 ` Andrey Borzenkov
2006-01-27  4:05 ` Andrey Borzenkov
2006-01-27  4:11 ` Kay Sievers
2006-01-27  4:20 ` Greg KH
2006-01-27  4:21 ` Greg KH
2006-01-27  4:23 ` Greg KH
2006-01-27  7:50 ` Linus Walleij
2006-01-27 11:56 ` Olivier Blin
2006-01-27 17:04 ` David Zeuthen
2006-01-27 17:15 ` Olivier Blin
2006-01-27 17:28 ` Darren Salt
2006-01-27 17:33 ` Bill Nottingham
2006-01-27 19:29 ` Johannes Erdfelt
2006-01-27 19:39 ` Linus Walleij
2006-01-27 19:44 ` Johannes Erdfelt
2006-01-27 20:45 ` Greg KH
2006-01-28  0:12 ` Greg KH
2006-02-06 23:29 ` Johannes Erdfelt
2006-02-06 23:53 ` Greg KH
2006-02-07  0:00 ` Johannes Erdfelt
2006-02-07  0:23 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).