* usb + sysfs + udev problems once more
@ 2007-06-27 13:14 Andreas Jellinghaus
2007-06-27 14:35 ` Kay Sievers
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Andreas Jellinghaus @ 2007-06-27 13:14 UTC (permalink / raw)
To: linux-hotplug
I thought to try the latest ubuntu beta version to see if
kernel + usb + sysfs + udev work as expected, but they don't.
the kernel is 2.6.22-rc, udev is 111-0ubuntu5.
I'm posting here, as I guess this is not distribution specific.
the problem I see is this: when I plugin my usb smart card reader,
I see a number of events using "udevmonitor --kernel --environment".
of these I'm interested in these two:
UEVENT[1182947366.505829] add /devices/pci0000:00/0000:00:1d.2/usb3/3-1
(usb)
ACTIONd
DEVPATH=/devices/pci0000:00/0000:00:1d.2/usb3/3-1
SUBSYSTEM=usb
SEQNUM%49
MAJOR\x189
MINOR%8
DEVTYPE=usb_device
PHYSDEVBUS=usb
DEVICE=/proc/bus/usb/003/003
PRODUCTŽ6/3438/100
TYPE=0/0/0
BUSNUM\03
DEVNUM\03
and
UEVENT[1182947366.505908]
add /devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.0 (usb)
ACTIONd
DEVPATH=/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.0
SUBSYSTEM=usb
SEQNUM%51
DEVTYPE=usb_interface
PHYSDEVBUS=usb
INTERFACE\x11/0/0
MODALIAS=usb:v08E6p3438d0100dc00dsc00dp00ic0Bisc00ip00
the first is nice, as it has the DEVICE info. I need that one.
however, only the second is matched by the udev rule:
SYSFS{bInterfaceClass}="0b", SYSFS{bInterfaceSubClass}="00",
SYSFS{bInterfaceProtocol}="00" RUN+="/lib/udev/openct_usb"
so in the end my script is called only once, but without DEVICE.
how do I fix this?
or is this a kernel / sysfs problem that cannot be worked around?
and is there any chance udev will create events
for the /dev/bus/usb/ device files it creates?
thanks for your help.
Regards, Andreas
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: usb + sysfs + udev problems once more
2007-06-27 13:14 usb + sysfs + udev problems once more Andreas Jellinghaus
@ 2007-06-27 14:35 ` Kay Sievers
2007-06-27 15:27 ` Andreas Jellinghaus
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Kay Sievers @ 2007-06-27 14:35 UTC (permalink / raw)
To: linux-hotplug
On 6/27/07, Andreas Jellinghaus <aj@leogic.com> wrote:
> I thought to try the latest ubuntu beta version to see if
> kernel + usb + sysfs + udev work as expected, but they don't.
> the kernel is 2.6.22-rc, udev is 111-0ubuntu5.
>
> I'm posting here, as I guess this is not distribution specific.
>
> the problem I see is this: when I plugin my usb smart card reader,
> I see a number of events using "udevmonitor --kernel --environment".
> of these I'm interested in these two:
>
> UEVENT[1182947366.505829] add /devices/pci0000:00/0000:00:1d.2/usb3/3-1
> (usb)
> ACTIONd
> DEVPATH=/devices/pci0000:00/0000:00:1d.2/usb3/3-1
> SUBSYSTEM=usb
> SEQNUM%49
> MAJOR\x189
> MINOR%8
> DEVTYPE=usb_device
> PHYSDEVBUS=usb
> DEVICE=/proc/bus/usb/003/003
> PRODUCTŽ6/3438/100
> TYPE=0/0/0
> BUSNUM\03
> DEVNUM\03
>
>
> and
>
>
> UEVENT[1182947366.505908]
> add /devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.0 (usb)
> ACTIONd
> DEVPATH=/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.0
> SUBSYSTEM=usb
> SEQNUM%51
> DEVTYPE=usb_interface
> PHYSDEVBUS=usb
> INTERFACE\x11/0/0
> MODALIAS=usb:v08E6p3438d0100dc00dsc00dp00ic0Bisc00ip00
>
>
> the first is nice, as it has the DEVICE info. I need that one.
> however, only the second is matched by the udev rule:
> SYSFS{bInterfaceClass}="0b", SYSFS{bInterfaceSubClass}="00",
> SYSFS{bInterfaceProtocol}="00" RUN+="/lib/udev/openct_usb"
>
> so in the end my script is called only once, but without DEVICE.
>
> how do I fix this?
>
> or is this a kernel / sysfs problem that cannot be worked around?
>
> and is there any chance udev will create events
> for the /dev/bus/usb/ device files it creates?
The usb-interfaces (2nd event) do not have a device node. Only the
usb-device itself, but you match on interface properties. There is no
sane way for udev to match on an interface property and get the device
node name at the same time. You run into unsolvable timing problems,
or need to use weird hacks.
Also, usbfs proc device-nodes are not available on modern systems (can
not support ACL's). Udev creates /dev/bus/usb/*/* nodes and libusb
picks up the nodes from there, if the directory exists.
The kernel exports the devices nodes by the usb-device itself (2.6.22)
or (for older kernels) by usb_device-class devices. But also with that
setup, there is no convenient way to get interface properties to match
against, and device node access at the same time with simple udev
rules. There is support for all that in HAL, but not in udev.
The only reliable way for udev rules would be with kernel 2.6.22, not
using usb_device class devices and not using proc usbfs. With such a
setup, you could hook your RUN into the interface-event and the
program/script can query the device-node name from the parent device
of the interface.
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: usb + sysfs + udev problems once more
2007-06-27 13:14 usb + sysfs + udev problems once more Andreas Jellinghaus
2007-06-27 14:35 ` Kay Sievers
@ 2007-06-27 15:27 ` Andreas Jellinghaus
2007-06-27 16:02 ` Alexander E. Patrakov
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Jellinghaus @ 2007-06-27 15:27 UTC (permalink / raw)
To: linux-hotplug
Am Mittwoch, 27. Juni 2007 16:35 schrieb Kay Sievers:
> The usb-interfaces (2nd event) do not have a device node. Only the
> usb-device itself, but you match on interface properties. There is no
> sane way for udev to match on an interface property and get the device
> node name at the same time. You run into unsolvable timing problems,
> or need to use weird hacks.
if I remember correcty, with linux and hotplug this was possible, right?
so linux+sysfs+udev is a regression from linux+hotplug? an unfixable?
also with 2.6.21.2 plus udev 093 on ubuntu edgy it works for me.
is this a udev regression or kernel regression? why is there "no sane way"
if it works with older software? sorry, I'm puzzled.
> Also, usbfs proc device-nodes are not available on modern systems (can
> not support ACL's). Udev creates /dev/bus/usb/*/* nodes and libusb
> picks up the nodes from there, if the directory exists.
fine with me, how do I get udev to call me when a smart card reader is
plugged in and pass the device name in some variable? smart card reader
these days pretty much means CCID device, i.e. a device with 0b interface.
could be a combo device like a keyboard with an intergrated reader, I will
have a look at pick the right endpoint.
my last information was that there are no proper events for /dev/bus/usb
nodes, such they are a regression, while they offer some new features, they
also miss some older features.
> The kernel exports the devices nodes by the usb-device itself (2.6.22)
> or (for older kernels) by usb_device-class devices. But also with that
> setup, there is no convenient way to get interface properties to match
> against, and device node access at the same time with simple udev
> rules. There is support for all that in HAL, but not in udev.
I never found any useful information how to plug into hal.
is there anyone who can convert
https://www.opensc-project.org/openct/browser/trunk/etc/openct.udev
into a hal config file? not that I'm eager to move to a new software
which had no useful documentation the last time I looked at it. but maybe
that changed? still it would be an extra dependency some people don't want.
also I wonder: two years ago with linux + hotplug I was fine. when exactly
began this change that results in my application being broken? I thought
linux had very strict requirements not to change the kernel/userland interface
without proper announcement, migration plans and all that. but for
usb/udev/hotplug/sysfs I can't remember any announcement mentioning
incompatible kernel/userland changes.
> The only reliable way for udev rules would be with kernel 2.6.22, not
> using usb_device class devices and not using proc usbfs. With such a
> setup, you could hook your RUN into the interface-event and the
> program/script can query the device-node name from the parent device
> of the interface.
you mean like this?
ls -d /sys/$DEVPATH/../usb_device* |xargs basename |
sed -e "s/usb_device:usbdev//g" |sed -e "s/\./ /g" |xargs
printf /dev/bus/usb/%03d/%03d\\n
i.e. from the $DEVPATH ("interface"?) I go to .. then look for
usb_device:usbdev* files, which should be only one, get that name,
strip "usb_device:usbdev" and split the remainder (e.g. 3.8)
first into two numbers (3 8) and then format them into
/dev/bus/usb/%03d/%03d (e.g. /dev/bus/usb/003/008).
is this ok? will it work on older kernel and future kernels as well?
will it work with different versions of udev? could you think of any
hardware where this would't work?
thanks for your help.
Regards, Andreas
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: usb + sysfs + udev problems once more
2007-06-27 13:14 usb + sysfs + udev problems once more Andreas Jellinghaus
2007-06-27 14:35 ` Kay Sievers
2007-06-27 15:27 ` Andreas Jellinghaus
@ 2007-06-27 16:02 ` Alexander E. Patrakov
2007-06-27 16:22 ` Andreas Jellinghaus
2007-06-27 16:36 ` Kay Sievers
4 siblings, 0 replies; 6+ messages in thread
From: Alexander E. Patrakov @ 2007-06-27 16:02 UTC (permalink / raw)
To: linux-hotplug
Andreas Jellinghaus wrote:
> Am Mittwoch, 27. Juni 2007 16:35 schrieb Kay Sievers:
>> The usb-interfaces (2nd event) do not have a device node. Only the
>> usb-device itself, but you match on interface properties. There is no
>> sane way for udev to match on an interface property and get the device
>> node name at the same time. You run into unsolvable timing problems,
>> or need to use weird hacks.
>
> if I remember correcty, with linux and hotplug this was possible, right?
> so linux+sysfs+udev is a regression from linux+hotplug? an unfixable?
It was "possible" due to a lot of "sleep"s in hotplug scripts (aka
"unsolvable timing problem", because sleeps are not a solution).
--
Alexander E. Patrakov
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: usb + sysfs + udev problems once more
2007-06-27 13:14 usb + sysfs + udev problems once more Andreas Jellinghaus
` (2 preceding siblings ...)
2007-06-27 16:02 ` Alexander E. Patrakov
@ 2007-06-27 16:22 ` Andreas Jellinghaus
2007-06-27 16:36 ` Kay Sievers
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Jellinghaus @ 2007-06-27 16:22 UTC (permalink / raw)
To: linux-hotplug
Am Mittwoch, 27. Juni 2007 18:02 schrieb Alexander E. Patrakov:
> It was "possible" due to a lot of "sleep"s in hotplug scripts (aka
> "unsolvable timing problem", because sleeps are not a solution).
but that doesn't explain why udev 093 + kernel 2.6.21.2 work
where new udev and new kernel don't?
Regards, Andreas
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
* Re: usb + sysfs + udev problems once more
2007-06-27 13:14 usb + sysfs + udev problems once more Andreas Jellinghaus
` (3 preceding siblings ...)
2007-06-27 16:22 ` Andreas Jellinghaus
@ 2007-06-27 16:36 ` Kay Sievers
4 siblings, 0 replies; 6+ messages in thread
From: Kay Sievers @ 2007-06-27 16:36 UTC (permalink / raw)
To: linux-hotplug
On 6/27/07, Andreas Jellinghaus <aj@leogic.com> wrote:
> Am Mittwoch, 27. Juni 2007 16:35 schrieb Kay Sievers:
> > The usb-interfaces (2nd event) do not have a device node. Only the
> > usb-device itself, but you match on interface properties. There is no
> > sane way for udev to match on an interface property and get the device
> > node name at the same time. You run into unsolvable timing problems,
> > or need to use weird hacks.
>
> if I remember correcty, with linux and hotplug this was possible, right?
> so linux+sysfs+udev is a regression from linux+hotplug? an unfixable?
It worked sometimes. Just as you can make it work sometimes today.
> also with 2.6.21.2 plus udev 093 on ubuntu edgy it works for me.
> is this a udev regression or kernel regression? why is there "no sane way"
> if it works with older software? sorry, I'm puzzled.
No regression, you are just lucky, that it worked for you. I have tons
of bug reports, and that was the reason to export the node from the
usb-device directly. This allows us to solve the problem the proper
way.
> > Also, usbfs proc device-nodes are not available on modern systems (can
> > not support ACL's). Udev creates /dev/bus/usb/*/* nodes and libusb
> > picks up the nodes from there, if the directory exists.
>
> fine with me, how do I get udev to call me when a smart card reader is
> plugged in and pass the device name in some variable? smart card reader
> these days pretty much means CCID device, i.e. a device with 0b interface.
> could be a combo device like a keyboard with an intergrated reader, I will
> have a look at pick the right endpoint.
>
> my last information was that there are no proper events for /dev/bus/usb
> nodes, such they are a regression, while they offer some new features, they
> also miss some older features.
No. Nothing has changed, besides that you see a bug you haven't seen
before. It is a very old problem, nothing new today.
> > The kernel exports the devices nodes by the usb-device itself (2.6.22)
> > or (for older kernels) by usb_device-class devices. But also with that
> > setup, there is no convenient way to get interface properties to match
> > against, and device node access at the same time with simple udev
> > rules. There is support for all that in HAL, but not in udev.
>
> I never found any useful information how to plug into hal.
> is there anyone who can convert
> https://www.opensc-project.org/openct/browser/trunk/etc/openct.udev
> into a hal config file? not that I'm eager to move to a new software
> which had no useful documentation the last time I looked at it. but maybe
> that changed? still it would be an extra dependency some people don't want.
>
> also I wonder: two years ago with linux + hotplug I was fine. when exactly
> began this change that results in my application being broken? I thought
> linux had very strict requirements not to change the kernel/userland interface
> without proper announcement, migration plans and all that. but for
> usb/udev/hotplug/sysfs I can't remember any announcement mentioning
> incompatible kernel/userland changes.
Nothing has changed, it's just that you see a bug a lot of people
already had long time ago. Todays faster/SMP systems are just much
more likely to show these timing problems.
(Oh, and if you continue this attitude, I will not reply to any of
your mails anymore. I'm just too annoyed by this kind of comments.
Please, try to understand the problem before talking like the usual
complainers that don't have any clue what they are talking about.)
> > The only reliable way for udev rules would be with kernel 2.6.22, not
> > using usb_device class devices and not using proc usbfs. With such a
> > setup, you could hook your RUN into the interface-event and the
> > program/script can query the device-node name from the parent device
> > of the interface.
>
> you mean like this?
>
> ls -d /sys/$DEVPATH/../usb_device* |xargs basename |
> sed -e "s/usb_device:usbdev//g" |sed -e "s/\./ /g" |xargs
> printf /dev/bus/usb/%03d/%03d\\n
>
> i.e. from the $DEVPATH ("interface"?) I go to .. then look for
> usb_device:usbdev* files, which should be only one, get that name,
> strip "usb_device:usbdev" and split the remainder (e.g. 3.8)
> first into two numbers (3 8) and then format them into
> /dev/bus/usb/%03d/%03d (e.g. /dev/bus/usb/003/008).
>
> is this ok?
No, that doesn't work. usb_device-class will not exist on new systems,
it is replaced by the direct device nodes of the usb-device.
You need to find the parent device (strip the last part of the
devpath), and call udevinfo with the devpath to get the device node.
(Repeat that until you find the device with a node, as the kernel is
always free to insert additional devices in the chain devpath.)
> will it work on older kernel and future kernels as well?
No, it wouldn't work with older kernels.
You have to lookup sysfs in a different way and work with optimistic
sleeps here, and need to be lucky ...
> will it work with different versions of udev?
Yes, but as said, only with most recent kernels using the device nodes
exported by the usb-devicve itself. Everything else is just "hope it
works".
> could you think of any
> hardware where this would't work?
It will work with any usb device.
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 6+ messages in thread
end of thread, other threads:[~2007-06-27 16:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-27 13:14 usb + sysfs + udev problems once more Andreas Jellinghaus
2007-06-27 14:35 ` Kay Sievers
2007-06-27 15:27 ` Andreas Jellinghaus
2007-06-27 16:02 ` Alexander E. Patrakov
2007-06-27 16:22 ` Andreas Jellinghaus
2007-06-27 16:36 ` 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).