mirror of
https://github.com/troglobit/finit.git
synced 2026-11-29 21:08:21 +00:00
Refactor initial /dev popoulation
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
33916a2097
commit
00fe37174d
1 file changed
+22
-16
+22
-16
@@ -243,6 +243,8 @@ static void emergency_shell(void)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
char *path;
|
||||||
|
char cmd[256];
|
||||||
int ret, udev = 0;
|
int ret, udev = 0;
|
||||||
uev_ctx_t loop;
|
uev_ctx_t loop;
|
||||||
|
|
||||||
@@ -342,41 +344,45 @@ int main(int argc, char* argv[])
|
|||||||
/*
|
/*
|
||||||
* Populate /dev and prepare for runtime events from kernel.
|
* Populate /dev and prepare for runtime events from kernel.
|
||||||
*/
|
*/
|
||||||
if (whichp("mdev")) {
|
path = which("mdev");
|
||||||
|
if (path) {
|
||||||
/* Embedded Linux systems usually have BusyBox mdev */
|
/* Embedded Linux systems usually have BusyBox mdev */
|
||||||
if (log_is_debug())
|
if (log_is_debug())
|
||||||
touch("/dev/mdev.log");
|
touch("/dev/mdev.log");
|
||||||
|
|
||||||
run_interactive("mdev -s", "Populating device tree");
|
snprintf(cmd, sizeof(cmd), "%s -s", path);
|
||||||
} else {
|
} else {
|
||||||
char *cmd;
|
/* Desktop and server distros usually have a variant of udev */
|
||||||
char line[256];
|
path = which("udevd");
|
||||||
|
if (!path)
|
||||||
cmd = which("udevd");
|
path = which("/lib/systemd/systemd-udevd");
|
||||||
if (!cmd)
|
if (path) {
|
||||||
cmd = which("/lib/systemd/systemd-udevd");
|
|
||||||
if (cmd) {
|
|
||||||
udev = 1;
|
udev = 1;
|
||||||
|
|
||||||
snprintf(line, sizeof(line), "[12345] %s -- Device event manager daemon", cmd);
|
/* Register udevd as a monitored service, started much later */
|
||||||
if (service_register(SVC_TYPE_SERVICE, line, NULL)) {
|
snprintf(cmd, sizeof(cmd), "[12345] %s -- Device event manager daemon", path);
|
||||||
_pe("Failed registering %s", cmd);
|
if (service_register(SVC_TYPE_SERVICE, cmd, NULL)) {
|
||||||
|
_pe("Failed registering %s", path);
|
||||||
udev = 0;
|
udev = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Start a temporary udevd instance to populate /dev */
|
||||||
|
snprintf(cmd, sizeof(cmd), "%s --daemon", path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(line, sizeof(line), "%s --daemon", cmd);
|
if (path) {
|
||||||
run_interactive(line, "Populating device tree");
|
free(path);
|
||||||
|
|
||||||
|
run_interactive(cmd, "Populating device tree");
|
||||||
if (udev && whichp("udevadm")) {
|
if (udev && whichp("udevadm")) {
|
||||||
run("udevadm trigger --action=add --type=subsystems");
|
run("udevadm trigger --action=add --type=subsystems");
|
||||||
run("udevadm trigger --action=add --type=devices");
|
run("udevadm trigger --action=add --type=devices");
|
||||||
run("udevadm settle --timeout=120");
|
run("udevadm settle --timeout=120");
|
||||||
|
|
||||||
|
/* Tell temporary udevd to exit, we'll start a monitored instance later */
|
||||||
run("udevadm control --exit");
|
run("udevadm control --exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in new issue
Block a user