Fix Start udevd as a proper service
@@ -377,15 +377,19 @@ int main(int argc, char* argv[])
/* Desktop and server distros usually have a variant of udev */
udev = 1;
- /* Register udevd as a monitored service, started much later */
- snprintf(cmd, sizeof(cmd), "[12345] %s -- Device event manager daemon", path);
+ /* Register udevd as a monitored service */
+ snprintf(cmd, sizeof(cmd), "[S12345789] %s -- Device event manager daemon", path);
+ free(path);
if (service_register(SVC_TYPE_SERVICE, cmd, global_rlimit, NULL)) {
_pe("Failed registering %s", path);
udev = 0;
- }
+ } else {
+ snprintf(cmd, sizeof(cmd), "[S] udevadm trigger --action=add --type=subsystems -- ");
+ service_register(SVC_TYPE_RUN, cmd, global_rlimit, NULL);
- /* Start a temporary udevd instance to populate /dev */
- snprintf(cmd, sizeof(cmd), "%s --daemon", path);
+ snprintf(cmd, sizeof(cmd), "[S] udevadm trigger --action=add --type=devices -- ");
+ service_register(SVC_TYPE_RUN, cmd, global_rlimit, NULL);
+ }
} else {
path = which("mdev");
if (path) {
@@ -394,20 +398,9 @@ int main(int argc, char* argv[])
touch("/dev/mdev.log");
snprintf(cmd, sizeof(cmd), "%s -s", path);
- }
- }
-
- if (path) {
free(path);
run_interactive(cmd, "Populating device tree");
- if (udev && whichp("udevadm")) {
- run("udevadm trigger --action=add --type=subsystems");
- run("udevadm trigger --action=add --type=devices");
- run("udevadm settle --timeout=120");
-
- /* Tell temporary udevd to exit, we'll start a monitored instance later */
- run("udevadm control --exit");
}
}
@@ -428,10 +421,6 @@ int main(int argc, char* argv[])
#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");
-
/* Bootstrap conditions, needed for hooks */
cond_init();
@@ -471,6 +460,10 @@ int main(int argc, char* argv[])
sm_init(&sm);
sm_step(&sm);
+ /* Debian has this little script to copy generated rules while the system was read-only */
+ if (udev && fexist("/lib/udev/udev-finish"))
+ run_interactive("/lib/udev/udev-finish", "Finalizing udev");
+
/* Start new initctl API responder */
api_init(&loop);
umask(022);
