* udev craze: need /dev/bus/usb rationale
@ 2006-01-25 20:37 Linus Walleij
2006-01-26 1:39 ` Kay Sievers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Linus Walleij @ 2006-01-25 20:37 UTC (permalink / raw)
To: linux-hotplug
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.)
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
However libusb has this code in linux.c row 336 or so:
if (!strchr("0123456789", entry->d_name[strlen(entry->d_name) - 1]))
Of course it could be fixed with a patch:
if (!strchr("0123456789ABCDEF", entry->d_name[strlen(entry->d_name) - 1]))
But we need a clear rationale:
* How shall /dev/bus/usb subdirs and device files be named?
* If they shall be all decimal figures, change all rules accordingly and
libusb will work fine as it is.
* If they shall be hex, make the above suggested change to libusb.
Yours,
Linus Walleij
P.S:
diff -ur libusb-0.1.11-orig/linux.c libusb-0.1.11/linux.c
--- libusb-0.1.11-orig/linux.c 2006-01-24 23:59:44.000000000 +0100
+++ libusb-0.1.11/linux.c 2006-01-25 20:24:25.000000000 +0100
@@ -334,7 +334,7 @@
if (entry->d_name[0] = '.')
continue;
- if (!strchr("0123456789", entry->d_name[strlen(entry->d_name) - 1]))
{
+ if (!strchr("0123456789ABCDEF", entry->d_name[strlen(entry->d_name) -
1])) {
if (usb_debug >= 2)
fprintf(stderr, "usb_os_find_busses: Skipping non bus directory
%s\n",
entry->d_name);
-------------------------------------------------------
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] 4+ messages in thread* Re: udev craze: need /dev/bus/usb rationale
2006-01-25 20:37 udev craze: need /dev/bus/usb rationale Linus Walleij
@ 2006-01-26 1:39 ` Kay Sievers
2006-01-26 8:12 ` Harald Hoyer
2006-01-26 12:14 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2006-01-26 1:39 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.)
I use:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; \
printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", NAME="%c", MOD E="0644"
> 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
Huh, my shell does not do this weird hex stuff and the numbers seems
pretty high for a USB bus :). It's may be caused by the "X"? The rule
above does the leading zeros, like /proc was, which is nicer too.
> However libusb has this code in linux.c row 336 or so:
>
> if (!strchr("0123456789", entry->d_name[strlen(entry->d_name) - 1]))
>
> Of course it could be fixed with a patch:
>
> if (!strchr("0123456789ABCDEF", entry->d_name[strlen(entry->d_name) - 1]))
>
> But we need a clear rationale:
>
> * How shall /dev/bus/usb subdirs and device files be named?
>
> * If they shall be all decimal figures, change all rules accordingly and
> libusb will work fine as it is.
>
> * If they shall be hex, make the above suggested change to libusb.
No, they should not change and be the same as they have been in /proc.
Thanks,
Kay
-------------------------------------------------------
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] 4+ messages in thread* Re: udev craze: need /dev/bus/usb rationale
2006-01-25 20:37 udev craze: need /dev/bus/usb rationale Linus Walleij
2006-01-26 1:39 ` Kay Sievers
@ 2006-01-26 8:12 ` Harald Hoyer
2006-01-26 12:14 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Harald Hoyer @ 2006-01-26 8:12 UTC (permalink / raw)
To: linux-hotplug
Kay Sievers wrote:
> I use:
> SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; \
> printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", NAME="%c", MOD E="0644"
>
Updated Fedora udev-078-8 to use this rule instead of the hex one...
-------------------------------------------------------
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] 4+ messages in thread* Re: udev craze: need /dev/bus/usb rationale
2006-01-25 20:37 udev craze: need /dev/bus/usb rationale Linus Walleij
2006-01-26 1:39 ` Kay Sievers
2006-01-26 8:12 ` Harald Hoyer
@ 2006-01-26 12:14 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2006-01-26 12:14 UTC (permalink / raw)
To: linux-hotplug
On Thu, Jan 26, 2006 at 09:12:12AM +0100, Harald Hoyer wrote:
> Kay Sievers wrote:
> >I use:
> > SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; \
> > printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", NAME="%c", MOD
> > E="0644"
> >
>
> Updated Fedora udev-078-8 to use this rule instead of the hex one...
Fine, but what created the weird hex numbers? The old rule was working fine for
me too.
Thanks,
Kay
-------------------------------------------------------
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] 4+ messages in thread
end of thread, other threads:[~2006-01-26 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-25 20:37 udev craze: need /dev/bus/usb rationale Linus Walleij
2006-01-26 1:39 ` Kay Sievers
2006-01-26 8:12 ` Harald Hoyer
2006-01-26 12:14 ` Kay Sievers
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).