Ludovic Rousseau wrote:
2006/12/7, Todd Denniston <[EMAIL PROTECTED]>:
have you looked at the inotify[1] infrastructure?

Not really. I was thinking about using inotify to avoid polling in the
pcscd/libpcsclite communication.

I don't know if inotify can be configured to check only USB devices
with InterfaceClass equal to 11 (CCID device) like it is possible with
udev with:
# generic CCID device
BUS=="usb", SYSFS{bInterfaceClass}=="0b", ACTION=="add",
RUN+="/usr/sbin/pcscd --hotplug"


I did not find a file in /sys/ that had it's creation|modification done based on InterfaceClass equal to 11, if you know of such a file that could be used.

What I was thinking was more along the lines of, pcscd could have a helper app that would A) always be running when pcscd was, B) could receive the signal from UDEV (which we know happens too soon), and C) because it is always using inotify to watch /dev it will know when the actual device node is created after the UDEV signal, and then issue the /usr/sbin/pcscd --hotplug.

i.e, when I run:
inotifywait -m -e create -e delete --format "%e (%f) " /dev/
then unplug and plug in my card reader (on an FC4 system), I get:
DELETE (usbdev2.8)
CREATE (usbdev2.9)
inotifywait comes from inotify-tools[1].

It is probably simpler to just put RUN+="sleep 1;/usr/sbin/pcscd --hotplug" in the UDEV config, but you still have the race of `can UDEV finish in sub one second`.
the following would probably introduce yet another race condition:
RUN+="inotifywait -e create /dev/ && /usr/sbin/pcscd --hotplug"
because inotifywait might not always be able to get itself setup before UDEV could get the device created.

Or (myself not having read enough UDEV info) does UDEV wait for the "RUN+=" line to finish before doing anything else? If it does then you could have 'pcscd --hotplug' (or similar) not return until they get their inotify watch setup for the now expected create event.



granted that may mean one more dependency that pcscd has, but at least it
seems small now.

pcscd does not depends on udev. You can trigger a rescan in pcscd
using udev or inotify or any other mechanism that can call
"/usr/sbin/pcscd --hotplug" when a reader is plugged/unplugged.
The problem with udev is that the action happens too early. One
solution (used by OpenCT) is to sleep(1) in pcscd but I really don't
like this.

Regards,


it is too bad you cant tell UDEV, "queue the following action to do, but only after you have created appropriate nodes".

[1] http://inotify-tools.sourceforge.net/

--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to