Software
skarnet.org
mdevd
What is it ?
mdevd is a small daemon managing kernel hotplug events, similarly to udevd.
It uses the same configuration file as
mdev,
which is a hotplug manager integrated in the
Busybox suite of tools.
However, mdev needs to be registered in
/proc/sys/kernel/hotplug, and the kernel forks
an instance of mdev for every event; by contrast, mdevd is a daemon
and does not fork.
The point of mdevd is to provide a drop-in replacement to mdev
that does not fork, so it can handle large influxes of events
at boot time without a performance drop. mdevd is designed to be
entirely compatible with advanced mdev usage such as
mdev-like-a-boss.
Comparison with mdev -d
Recent versions of mdev
have a -d option that allow it to run as a daemon. However,
mdevd still has advantages over mdev -d:
- Better log management: mdev -d logs to a fixed text file, with
all the issues it implies (need for the filesystem to be read-write,
uncontrollable log file growth). By contrast, mdevd logs to stderr and its
messages can be handled by any log infrastructure such as the one provided
by a supervision suite.
- Better memory efficiency: mdev -d uses its own environment
(via putenv()
and unsetenv())
to store uevent data for each event. This implies repeated allocations of
heap memory. By contrast, mdevd does not use its own environment - it
only uses heap memory to compile its regular expressions, which only happens
at start and when you reload its configuration file. All the rest of the
memory it uses is committed in the stack, and it will never require more.
mdevd cannot fail due to lack of memory while it is processing events.
- Better speed: mdev -d parses its config file for every
event it receives, and has to perform expensive operations such as
getpwnam()
every time it receives an event (which can add up to hundreds of times at boot!).
By contrast, mdevd only parses its config file when it starts - or when
it is told to read it again by a SIGHUP; the event processing is
streamlined, it does not involve any parsing or any kind of expensive
operation - so it is significantly faster. Additionally, unlike mdev,
mdevd does not fork its helper scripts — it uses
posix_spawn
instead, which is a lot faster.
- Independence from busybox: mdev is part of the
busybox software. It is an advantage
when busybox is also used to provide other functionality, such as
coreutils or util-linux equivalents. However, most distributions find
that functionality lacking in compatibility (for instance, the busybox
implementation of POSIX utilities is often non-conformant), and choose to
use alternatives to busybox instead. In that case, having to use the whole
busybox configuration and build process just for mdev is a drawback, and
the code that gets included in the mdev binary is bigger than it needs to be.
mdevd, on the other hand, is independent software, and building it is simple
and does not pull in any unnecessary code.
Installation
Requirements
- A Linux-based system with a standard C development environment.
The Linux kernel must be 2.6.10 or later.
- GNU make, version 3.81 or later
- skalibs version
2.14.3.0 or later. It's a build-time requirement. It's also a run-time
requirement if you link against the shared version of the skalibs
library.
- Optionally: nsss
version 0.2.0.5 or later. It's a build-time and run-time requirement, if
you use the --enable-nsss option to configure; but you would
only do that if you're replacing nsswitch on your whole system, and most
people are not.
- Optionally: execline
version 2.9.6.1 or later. It's a only a run-time requirement, and only
if your mdev.conf file contains +, - or
& command directives.
Licensing
mdevd is free software. It is available under the
ISC license.
Download
Compilation
- See the enclosed INSTALL file for installation details.
Upgrade notes
- This page lists the differences to be aware of between
the previous versions of mdevd and the current one.
Reference
Commands
Related resources
- mdevd is discussed on the
skaware mailing-list.