Prefer udev to handle /dev if mdev is also available on the system

Some systems, usually those built around BusyBox, have mdev installed
but have an option to install udev.  In those cases the user likely
prefers to use udev over mdev and this patch addresses that.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2018-02-17 16:06:22 +01:00
1 parent 93a21197ab
commit dedf885b92
1 file changed
+10 -9
+10 -9
View File
@@ -374,20 +374,13 @@ int main(int argc, char* argv[])
/* /*
* Populate /dev and prepare for runtime events from kernel. * Populate /dev and prepare for runtime events from kernel.
* Prefer udev if mdev is also available on the system.
*/ */
path = which("mdev");
if (path) {
/* Embedded Linux systems usually have BusyBox mdev */
if (log_is_debug())
touch("/dev/mdev.log");
snprintf(cmd, sizeof(cmd), "%s -s", path);
} else {
/* Desktop and server distros usually have a variant of udev */
path = which("udevd"); path = which("udevd");
if (!path) if (!path)
path = which("/lib/systemd/systemd-udevd"); path = which("/lib/systemd/systemd-udevd");
if (path) { if (path) {
/* Desktop and server distros usually have a variant of udev */
udev = 1; udev = 1;
/* Register udevd as a monitored service, started much later */ /* Register udevd as a monitored service, started much later */
@@ -399,6 +392,14 @@ int main(int argc, char* argv[])
/* Start a temporary udevd instance to populate /dev */ /* Start a temporary udevd instance to populate /dev */
snprintf(cmd, sizeof(cmd), "%s --daemon", path); snprintf(cmd, sizeof(cmd), "%s --daemon", path);
} else {
path = which("mdev");
if (path) {
/* Embedded Linux systems usually have BusyBox mdev */
if (log_is_debug())
touch("/dev/mdev.log");
snprintf(cmd, sizeof(cmd), "%s -s", path);
} }
} }