Skip to content

mdevd

  • mdevd -n and mdevd -N allow dry runs and configuration file tests without actually running mdevd
  • mdevd deprecates s6-uevent-listener and s6-uevent-spawner
  • Check alpine’s patches
  • Start mdevd with -O4; this will make the daemon rebroadcast kernel uevents to libudev-zero
  • Readiness -D only works when mdevd is being called by s6 and not manually in an initramfs
  • A summary of what mdevd-coldplug and udevadm trigger do:
Terminal window
for i in $(find /sys -name uevent); do ( echo change > $i ) ; done
  • There is no test suite
  • yash does not specify PATH in initramfs which causes mdevd to not find its commands; this problem seems to not exist when using dash
  • mdev.conf syntax:
<device regex> <uid>:<gid> <permissions> [=path|>path|!] [@|$|*<command>]
- =path moves to path
- >path symlinks device to path
- ! prevents device from being created
- @ Run after creating the device.
- $ Run before removing the device.
- * Run both after creating and before removing the device.
  • The command is executed via the system() function (which means you’re giving a command to the shell), so make sure you have a shell installed at /bin/sh. You should also keep in mind that the kernel executes hotplug helpers with stdin, stdout, and stderr connected to /dev/null.
  • Use libudev helper in mdev.conf
  • Does mdevd work with udev directories and rules or should we delete them?
  • devices is the default value for udevadm trigger -t
  • with udevadm you have to udevadm hwdb --update
  • mdevd parses mdev.conf when a new device event occurs
  • /dev/audio and /dev/dsp have been replaced with newer drivers and naming conventions
  • /dev/core has been deprecated
  • /dev/dsp and /dev/adsp have been deprecated as modern systems don’t use OSS
  • /dev/fd0 has been deprecated
  • /dev/grsec has been deprecated since 4.14
  • /dev/hd{a,b,c} have been deprecated
  • /dev/hwrng has replaced /dev/hwrandom and /dev/hw_random
  • /dev/mixer and /dev/sequencer have been deprecated as modern systems don’t use OSS
  • /dev/psaux has been deprecated
  • /dev/pty has been deprecated since 2.6.4 (https://man7.org/linux/man-pages/man7/pty.7.html)
  • /dev/snd has replaced /dev/sound
  • /dev/sr0 has replaced /dev/cdrom
  • /dev/sda has replaced /dev/cciss and /dev/ida
  • handles ~10k devices (under one minute?)
  • parallel processing (worker queues) and not linear processing
  • cache regcomp() results for speed in large device trees
  • s6-uevent-listener (deprecated, see mdevd) provides standalone netlink monitoring
  • pipeline approach (listener > data gatherer > event dispatcher)
  • each process replaceable if same api
  • spawns per-event handlers (e.g. mdev instances)
  • use unix socket client-server model; single publisher, multiple subscribers
  • implement filters server-side: dispatcher only links unfiltered events to client directories
  • avoid dbus: simple client-server, not symmetrical peer messaging
  • server-side filtering prevents unnecessary client wake-ups
  • never lose events; filesystem storage ensures this
  • filter at kernel/server level when possible
  • maintain replaceable components
  • avoid technical debt of message bus dependencies
  • libudev:
    • udev_monitor_set_receive_buffer_size() irrelevant for filesystems as events persist
    • inefficient client-side filtering; wakes process for filtered events
    • current socketpair emulation loses filesystem advantage (events can be lost)