Hi Ludovic! Since this is a quite long mail, here a résumé: IMHO the udev rule problem is not specific to libccid/pcscd, but it's a general one.
On Sun, 20 Jan 2008 15:20:00 +0100, Ludovic Rousseau wrote: > Luca Capello a écrit : >> I finally found how to detect both events (insertion/removal): >> >> >> MODALIAS=="pcmcia:m0157c0100f02fn00pfn00pa0981590FpbE9010D26pcDDC63BD8pd00000000", >> \ >> RUN+="/usr/sbin/pcscd --hotplug" > > Great. > > Where does the value "m0157c0...00000" comes from? I discovered it with udevtest (check the 'import_uevent_var' lines) and then found that these values are stores in the uvent file in the sysfs directory for the device (where there's also a modalias file). It seems that it's generated per the values stored in the following files: [bus]:m[manf_id]c[card_id]f[func_id]fn[function]pfn[]pa[]pb[]pc[]pd[] The last four p* values could reflects the prod_id* ones, but I couldn't find what the pfn one means. In general, the MODALIAS value is the one used to autoload a kernel module and indeed it matches one of `modinfo serial_cs` aliases: pcmcia:m*c*f02fn*pfn*pa*pb*pc*pd* However, by a test script [1] I also discovered that the MODALIAS rule is executed three times, as the udevmonitor output also revealed: - insertion UEVENT[1201474907.689914] add /devices/pci0000:00/0000:00:1e.0/0000:15:00.0/0.0 (pcmcia) UEVENT[1201474907.736811] remove /class/tty/ttyS0 (tty) UEVENT[1201474907.737026] add /class/tty/ttyS0 (tty) UDEV [1201474907.737622] add /devices/pci0000:00/0000:00:1e.0/0000:15:00.0/0.0 (pcmcia) UDEV [1201474907.740664] remove /class/tty/ttyS0 (tty) UDEV [1201474907.804776] add /class/tty/ttyS0 (tty) - removal1 UEVENT[1201474918.209887] remove /class/tty/ttyS0 (tty) UEVENT[1201474918.210021] add /class/tty/ttyS0 (tty) UEVENT[1201474918.210039] remove /devices/pci0000:00/0000:00:1e.0/0000:15:00.0/0.0 (pcmcia) UDEV [1201474918.212646] remove /class/tty/ttyS0 (tty) UDEV [1201474918.214675] add /class/tty/ttyS0 (tty) UDEV [1201474918.216665] remove /devices/pci0000:00/0000:00:1e.0/0000:15:00.0/0.0 (pcmcia) This because of 85-pcmcia.rules (without the following rule, however, the serial port is not brought up): # However, the "weak" matching by func_id is only allowed _after_ modprobe # returns, so that "strong" matches have a higher priority. SUBSYSTEM=="pcmcia", ENV{MODALIAS}=="?*", \ RUN+="/bin/sh -c 'echo 1 > /sys/$devpath/allow_func_id_match'" > Does it contain a serial number of your device or something like that > or does it work with any GemPC Card reader? For the reasons above, I'd say it doesn't contain any serial number. >> I think this bug is the sum of three different bugs: >> >> 1) pcscd init scripts can set the debug level (option $DAEMON_ARGS), but >> there's no easy way to do it (e.g. in /etc/default/pcscd). > > I can add a documentation about $DAEMON_ARGS in the pcscd init script > and include /etc/default/pcscd if present. > Do you need something else? No, a proper documentation with inclusion of /etc/default/pcscd into the init script should be enough. >> 2) libccid ships udev rules that depend on pcscd, which is only >> recommended by libccid. I'd suggest to ship these rules in pcscd, >> instead, since the latter depends on libccid anyway. > > I don't see the problem that would be solved. This won't solve any upstream problem, only a Debian one: the libccid udev rule contains a call to /usr/sbin/pcscd, which is not in the libccid package. This means that either libccid should depends on pcscd or the udev rule should be shipped in the pcscd package instead. I'm in favor of the latter, since the udev rule is pcscd-specific. > The udev rule file should disappear in the future (at least for USB > readers). AFAIK, I'm afraid the rules should stay there for PCMCIA readers :-( >> 3) an udev rules to detect PCMCIA card readers insertion/removal would >> be nice. > > Sure. If your rule above works for any GemPC Card reader I will add > it. As explained above, the MODALIAS rule is surely an improvement, but I'd say that it's a workaround and not the solution. Thx, bye, Gismo / Luca Footnotes: [1] #!/bin/sh VALUE=`cat /root/gemplus.$ACTION` echo `expr $VALUE + 1` >/root/gemplus.$ACTION exit 0