diff --git a/configure.ac b/configure.ac index 876ac246..4a97dab9 100644 --- a/configure.ac +++ b/configure.ac @@ -37,11 +37,8 @@ PKG_CHECK_MODULES([uev], [libuev >= 1.4.0]) PKG_CHECK_MODULES([lite], [libite >= 1.5.0]) # Check for configured Finit features -AC_ARG_ENABLE(embedded, - AS_HELP_STRING([--enable-embedded], [Embedded defaults, BusBox getty, mdev etc.])) - AC_ARG_ENABLE(rw-rootfs, - AS_HELP_STRING([--enable-rw-rootfs], [Remount / as read-write at boot, not for embedded])) + AS_HELP_STRING([--enable-rw-rootfs], [Remount / R/W at boot, usually not for embedded])) AC_ARG_ENABLE(silent, AS_HELP_STRING([--enable-silent], [Completely silent operation, not even boot messages])) @@ -120,12 +117,6 @@ AC_ARG_WITH(random-seed, ### Enable features ########################################################################### # Create config.h from selected features and fallback defautls -AS_IF([test "x$enable_embedded" = "xyes"],[ - AC_DEFINE(EMBEDDED_SYSTEM, 1, [Target an embedded system with BusyBox]) - AC_DEFINE(SETUP_DEVFS, "/sbin/mdev -s", [Command to populate /dev]) - ],[ - AC_DEFINE(SETUP_DEVFS, "/sbin/udevd --daemon", [Command to populate /dev])]) - AS_IF([test "x$enable_rw_rootfs" = "xyes"],[ AC_DEFINE(REMOUNT_ROOTFS, 1, [Remount / as rw at boot])]) diff --git a/finit.c b/finit.c index 3a1a7236..2dc2776e 100644 --- a/finit.c +++ b/finit.c @@ -205,6 +205,7 @@ static int fismnt(char *dir) int main(int argc, char* argv[]) { int err; + char *devfsd; uev_ctx_t loop; /* @@ -247,12 +248,14 @@ int main(int argc, char* argv[]) mount("none", "/proc/bus/usb", "usbfs", 0, NULL); mount("none", "/sys", "sysfs", 0, NULL); -#ifndef EMBEDDED_SYSTEM + /* + * Some non-embedded systems without an initramfs may not have /dev mounted yet + * If they do, check if system has udevadm and perform cleanup from initramfs + */ if (!fismnt("/dev")) mount("udev", "/dev", "devtmpfs", MS_RELATIME, "size=10%,nr_inodes=61156,mode=755"); - else + else if (fexist("/sbin/udevadm")) run_interactive("/sbin/udevadm info --cleanup-db", "Cleaning up udev db"); -#endif /* Some systems use /dev/pts */ makedir("/dev/pts", 0755); @@ -278,11 +281,18 @@ int main(int argc, char* argv[]) /* * Populate /dev and prepare for runtime events from kernel. */ -#ifdef EMBEDDED_SYSTEM - if (debug) - touch("/dev/mdev.log"); -#endif - run_interactive(SETUP_DEVFS, "Populating device tree"); + if (fexist("/sbin/mdev")) { + /* Embedded Linux systems usually have BusyBox mdev */ + if (debug) + touch("/dev/mdev.log"); + devfsd = "/sbin/mdev -s"; + } else { + if (fexist("/sbin/udevd")) + devfsd = "/sbin/udevd --daemon"; + else + devfsd = "/lib/systemd/systemd-udevd --daemon"; + } + run_interactive(devfsd, "Populating device tree"); /* * Load plugins first, finit.conf may contain references to @@ -311,9 +321,9 @@ int main(int argc, char* argv[]) mount(SYSROOT, "/", NULL, MS_MOVE, NULL); #endif -#ifndef EMBEDDED_SYSTEM - run_interactive("/lib/udev/udev-finish", "Finalizing udev"); -#endif + /* Debian has this little script to copy generated rules while the system was read-only */ + if (fexist("/lib/udev/udev-finish")) + run_interactive("/lib/udev/udev-finish", "Finalizing udev"); _d("Root FS up, calling hooks ..."); plugin_run_hooks(HOOK_ROOTFS_UP);