blino's website

Free software developer and more

When multiple display modules matching the same device are loaded at startup by udev coldplug, we can get in a situation where X doesn't start (#32030). This can happen when different versions of nvidia modules (nvidia, , nvidia96xx, nvidia71xx) are installed, which is the case on our live CDs.

To prevent all these modules from being loaded by udev, we can explicitely exclude devices from the display PCI class, like we do for storage controllers:

# modprobe pci devices on cold plug except for:
#  PCI_BASE_CLASS_STORAGE          0x01
ACTION=="add", SUBSYSTEM=="pci", ENV{STARTUP}=="1", SYSFS{modalias}=="?*", \
        ATTRS{class}!="0x01*", \
        RUN+="/sbin/modprobe %s{modalias}"

But adding another match to exclude the display class (PCI_BASE_CLASS_DISPLAY is 0x03 in /usr/include/pci/header.h) did not always work: ATTRS{class}!="0x03*" fails on PCI-Express devices.

That's because the ATTRS{class}!="value" rule walks every parent devices to check that each of them has a class different from "value", while one could think it would match if only one of them has a different value. Thus, when the tested device has a parent device, like with PCI Express devices, the negative ATTRS check is likely to fail.

So, the solution is to use ATTR{class}!="value", which checks only the current device, without walking the parent tree.

To debug this, I built udev with DEBUG=true, and added a ENV{FOO}=BAR operation in the rule I tested, to know quickly if it mached (in the output of udevmonitor --env).

# udevd --daemon --debug-trace --verbose &>udevd-debug.log
# udevcontrol log_priority=debug
# udevcontrol env STARTUP=1
# udevmonitor --env

Then, testing the rule of my video adapter device is just a matter of writting in the uevent file in sysfs:

$ lspci | grep VGA
01:00.0 VGA compatible controller: ATI Technologies Inc Unknown device 94c3
# echo 1 > /sys/devices/pci0000:00/0000:01:00.0/uevent


For a few releases, auto-mount of LUKS devices has been broken in Mandriva (bugs #27259 and #30115), because we had the following udev rule as default:

KERNEL=="dm-[0-9]*", OPTIONS="ignore_device"

This rule existed because lvm2 setup got broken when udev tried to run vol_id on dm devices (see Let udev play with snapshots thread on linux-lvm ML). This has been fixed ages ago (in lvm2-2.02.13) with the following change: When adding snapshot leave cow LV mapped device active after zeroing (commit).

So, the "ignore dm devices" workaround has been removed from our udev rules, and LUKS devices should now be auto-mounted by default on modern desktops \o/ (GNOME users, enjoy)



Now that the Mandriva kernel has both legacy IDE and libata PATA drivers enabled (and modularized), we may experience some issues because of PCI coldplugging, which is enabled by default in Mandriva. It would load both IDE drivers, probably leading to strange things.

Thus, I've modified our udev rules to ignore IDE controllers at coldplug. These controllers can be matched by their PCI class (PCI_CLASS_STORAGE_IDE is 0x0101, from <pci/header.h>). To differentiate between coldplug and hotplug (ok, not very likely for IDE controllers), the STARTUP environment variable is set by /sbin/start_udev before calling /sbin/udevtrigger.

The new udev rule for automatic PCI modules loading looks this way:

# modprobe pci devices on cold plug except for:
#  PCI_CLASS_STORAGE_IDE           0x0101
ACTION=="add", SUBSYSTEM=="pci", ENV{STARTUP}=="1", SYSFS{modalias}=="?*", \
        SYSFS{class}!="0x0101*", \
        RUN+="/sbin/modprobe %s{modalias}"
# modprobe pci devices on hot plug
ACTION=="add", SUBSYSTEM=="pci", ENV{STARTUP}!="1", SYSFS{modalias}=="?*", \
        RUN+="/sbin/modprobe %s{modalias}"

It can be easily tested this way:

rmmod <some pci module>
/sbin/udevcontrol env STARTUP=1
udevtrigger
udevsettle
/sbin/udevcontrol env STARTUP=
head /proc/modules

For the record, here's the crazy command line I used to list IDE modules (requiring ide-core) and their matching class (from modaliases), just out of curiosity:

egrep
  `grep ide-core /lib/modules/$(uname -r)/modules.dep
   | perl -ne 'print join("|", map { m|([^/]*).ko| && $1 ne "generic" ? $1 : () } <>) . "\n"'`
  /lib/modules/$(uname -r)/modules.alias
| grep -v 'bc\*'

(yes, I'm insane)

It's a little step that was necessary for current Cooker, but it can also help to switch to PATA drivers in a simple way (by just modifying the driver in our pcitable). And we will probably do so soon, as Alan Cox's libata PATA status looks quite encouraging.



Our persistent network interfaces naming scripts break tap devices naming, since they kinda "remember" interfaces names based on the MAC address (bug #22748).

udev_net_name_helper, which handles interfaces naming, shouldn't be run for this kind of devices (it's run from /etc/udev/rules.d/62-create_persistent.rules).

Since udev_net_helper already has some interface types blacklist, the proper way to solve this issue would be to extract the blacklist in put in a common udev rules file.

SUBSYSTEM!="net", GOTO="mdv_net_end"
ENV{INTERFACE}=="", GOTO="mdv_net_end"

ENV{INTERFACE}=="ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|vmnet*", GOTO="mdv_net_end"
ENV{INTERFACE}=="tap*|tun*", GOTO="mdv_net_ifcfg_end"

# implement ethernet check here

ACTION!="add", GOTO="mdv_net_ifcfg_end"
SYSFS{address}=="?*", ENV{MDV_CONFIGURED}!="yes", PROGRAM="/bin/flock /sys/class/net /lib/udev/udev_net_name_helper %s{address}", NAME="%c
RUN+="net_ifcfg_helper"
LABEL="mdv_net_ifcfg_end"

ACTION=="add", RUN+="/sbin/ifup ENV{INTERFACE} daemon"
ACTION=="remove", RUN+="/sbin/ifdown ENV{INTERFACE} daemon"

LABEL="mdv_net_end"


Our udev rules now automatically modprobe IDE modules, using their modalias. This is mostly useful on coldplug, for example for IDE tapes.



/blog/mandriva/udev udev 094 Mon, 12 Jun 2006
  • New release 094
  • use modprobe to do input hotplugging
  • don't call input coldplug helper
  • remove old input helpers and patches
  • install new 60-persistent-input.rules
  • add back writeable function in udev_net_name_helper (-w won't tell what we need if the system is mounted ro)


/blog/mandriva/udev udev 093 Mon, 29 May 2006
  • New release 093
  • use firmware.sh instead of firmware_helper
  • from Andrey Borzenkov: fix more '=' vs. '==' in RESULT rules (#22762)


I've updated udev to the 091 release, and added a lot of interesting patches from Andrey Borzenkov, that mostly fix ethernet interfaces naming issues (the /eth1394 bug).

If rule files aren't writable in /etc/udev when the interface are renamed, rules are temporarily written in /dev/.udev, and moved back to /etc/udev once it's mounted read-write.

This required a small in the initscripts package.

I had to struggle a bit to make udevstart work again with udev-091, since a small change upstream broke my patch (and resulted in no /dev/mem or /dev/null devices...).

To ensure a smooth upgrade from the obsolete speedtouch and eagle-usb packages, I added Obsoletes tags in the udev package. I think it's the best place to do that, since it's the package that handles firmware hotplugging for these devices (and because the commercial packages that contain firmware files aren't necessarily installed in free edtions).

udev-091-1mdk

  • New release 091
  • Patch35: update for udev-090+ and simplify
  • Source2: remove udev_ieee1394_helper occurences, modalias rules will do fine for ieee1394 subsystem with kernel 2.6.14+
  • remove udev_ieee1394_helper (Source37)
  • package udevsettle
  • Source50: use -w test instead of custom writable function
  • obsolete speedtouch and eagle-usb packages (done in udev since they now use firmware hotplugging instead of old user space tools)
  • from Andrey Borzenkov:
    • Source50: create rules in dev.udev in /etc/udev isn't writable
    • Source53: use sed instead of tr so that udev_net_name_helper works even when /usr isn't mounted
    • Source54: helper to copy udev rules from dev.udev/ to /etc/udev

initscripts-8.33-3mdk

  • copy udev rules created while root was read-only (Andrey Borzenkov)
  • bump udev requires


As of kernel 2.6.14, the ieee1394 subsystem passes MODALIAS variables to kernel events (that are received by udev). This allows to get rid of the old hotplug-like agent that I used in udev in 2006.0, because we can now use modprobe $ENV{MODALIAS} instead of complicated and slow shell scripts.

So, we'll switch to a more classical way of handling hotplug events for ieee1394, and that will allow among others to use the blacklist keyword for eth1394 in /etc/modprobe.conf (even if it shouldn't be needed since our dynamic interface naming will be perfect).



  • don't create network configuration files for vmnet interfaces (#22257)
  • always use udev user db parser, not to hang at boot when user and group db are fetched from network (#19690)


symlink vol_id in /sbin (used by drakx)



  • skip pam_console_apply for devices without device nodes (from Andrey Borzenkov, #21874)
  • don't use MODALIAS anymore in rules (but use SYSFS{modalias} and %s{modalias} instead)
  • use flock to avoid race conditions in persistent rules creation (#21500)


/blog/mandriva/udev udev 089 Tue, 04 Apr 2006
  • 089
  • remove pie build options (it breaks volume_id build)
  • package volume_id library
  • move *_id programs to /lib/udev (to reflect upstream structure) and modifiy 50-mdk.rules accordingly
  • move helpers in /lib64/udev on 64 bits systems
  • move 5x-*.rules persistent helpers to 6x-*.rules, since they need 60-persistent-storage.rules to be run (#21720 again) (cooker users should delete their 51-*_config.rules files manually)


  • use 60-persistent-storage.rules from git (#21720)


blosxom Optimised for standards.
Olivier Blin (2005)