From dedf885b92a90f5bf42ff744ae06bd24c1052b82 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sat, 17 Feb 2018 16:00:25 +0100 Subject: [PATCH] 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 --- src/finit.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/finit.c b/src/finit.c index af6021e1..8d4feca7 100644 --- a/src/finit.c +++ b/src/finit.c @@ -374,31 +374,32 @@ int main(int argc, char* argv[]) /* * Populate /dev and prepare for runtime events from kernel. + * Prefer udev if mdev is also available on the system. */ - path = which("mdev"); + path = which("udevd"); + if (!path) + path = which("/lib/systemd/systemd-udevd"); 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"); - if (!path) - path = which("/lib/systemd/systemd-udevd"); + udev = 1; + + /* Register udevd as a monitored service, started much later */ + snprintf(cmd, sizeof(cmd), "[12345] %s -- Device event manager daemon", path); + if (service_register(SVC_TYPE_SERVICE, cmd, global_rlimit, NULL)) { + _pe("Failed registering %s", path); + udev = 0; + } + + /* Start a temporary udevd instance to populate /dev */ + snprintf(cmd, sizeof(cmd), "%s --daemon", path); + } else { + path = which("mdev"); if (path) { - udev = 1; + /* Embedded Linux systems usually have BusyBox mdev */ + if (log_is_debug()) + touch("/dev/mdev.log"); - /* Register udevd as a monitored service, started much later */ - snprintf(cmd, sizeof(cmd), "[12345] %s -- Device event manager daemon", path); - if (service_register(SVC_TYPE_SERVICE, cmd, global_rlimit, NULL)) { - _pe("Failed registering %s", path); - udev = 0; - } - - /* Start a temporary udevd instance to populate /dev */ - snprintf(cmd, sizeof(cmd), "%s --daemon", path); + snprintf(cmd, sizeof(cmd), "%s -s", path); } }