mdevd
Software
skarnet.org
The mdevd program
mdevd is a uevent manager. It reads a series of
uevents on its stdin; for every uevent it reads, it performs
actions according to its configuration file. Actions can
be inserting a kernel module, creating or modifying device
entries in /dev, etc.
mdevd's configuration file uses the exact same
format as
mdev.
The differences between mdevd and mdev are:
- mdev needs to be registered as a hotplug manager and the
kernel spawns an instance of mdev per uevent; for every uevent,
mdev has to parse its configuration file. By contrast, there
is only one instance of mdevd, reading a series of uevents and
performing actions without forking; the configuration file is
read and parsed only once.
- mdevd reads uevents on its stdin. It is not suitable as
a hotplug manager, and it does not connect to the netlink itself
either. It is meant to be used in conjunction with
mdevd-netlink, which reads
uevents from the netlink, or with
mdevd-coldplug, which generates
coldplug uevents.
Interface
mdevd [ -v verbosity ] [ -f conffile ] [ -n ] [ -s slashsys ] [ -d slashdev ] [ -F fwbase ]
- mdevd reads and parses its configuration file /etc/mdev.conf.
- It then reads its stdin, waiting for uevents.
- It exits when the stream of uevents ends. (EOF on stdin.)
Exit codes
- 0: EOF read on standard input
- 1: received an invalid event
- 2: syntax error in the configuration file
- 100: wrong usage
- 111: system call failed
Signals
mdevd reacts to the following signals:
- SIGHUP: re-read the configuration file
Options
- -v verbosity : be more or less verbose.
Default verbosity is 1. 0 will only print fatal error messages, 3 or more
is seriously verbose debugging.
- -n : dry run. mdevd will not create or delete
device nodes, and it will not spawn commands. Instead, it will print to stdout
the actions it would have performed.
- -f conffile : read the configuration
file from conffile. Default is /etc/mdev.conf.
conffile must be an absolute path.
- -s slashsys : assume the sysfs
pseudo-filesystem is mounted on slashsys. Default is /sys.
slashsys must be an absolute path.
- -d slashdev : assume the device nodes
are to be found in slashdev. Default is /dev.
slashdev must be an absolute path.
- -F fwbase : assume the firmware files, if any,
are to be found in fwbase. Default is /lib/firmware.
fwbase must be an absolute path.
Configuration file
mdevd uses mdev's configuration file format.
A good mdev.conf example is available
here.
If mdevd cannot find its configuration file, it will use a simple, basic default
configuration where it can create device nodes as root or delete them, and does
nothing else.
Notes
- Strictly speaking, mdevd is a short-lived program: it has
a normal exit condition, which is when it receives EOF on its stdin.
That allows it to work as a coldplug manager when paired with
mdevd-coldplug.
- However, when paired with mdevd-netlink,
it acts as a daemon, because mdev-netlink normally never exits until
the end of the machine lifetime and never closes its stdout, so
mdevd's stdin never receives EOF.
- The examples/ subdirectory of the mdevd package contains
examples on how to run mdevd under various init systems / supervisors.