mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
Convert udevd to a regular system service
This patch, similar to the work done in the d-bus plugin, converts the udevd service from a non-monitored run_interactive() task that forks itself into the background, to a proper Finit monitored service. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
7a2667d34c
commit
34a15241ca
1 file changed
+25
-14
+25
-14
@@ -243,8 +243,7 @@ static void emergency_shell(void)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, udev = 0;
|
||||||
char *devfsd;
|
|
||||||
uev_ctx_t loop;
|
uev_ctx_t loop;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -347,19 +346,24 @@ int main(int argc, char* argv[])
|
|||||||
/* 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");
|
||||||
devfsd = "mdev -s";
|
|
||||||
} else {
|
|
||||||
if (whichp("udevd"))
|
|
||||||
devfsd = "udevd --daemon";
|
|
||||||
else
|
|
||||||
devfsd = "/lib/systemd/systemd-udevd --daemon";
|
|
||||||
}
|
|
||||||
|
|
||||||
run_interactive(devfsd, "Populating device tree");
|
run_interactive("mdev -s", "Populating device tree");
|
||||||
if (whichp("udevadm")) {
|
} else {
|
||||||
run("udevadm trigger --action=add --type=subsystems");
|
char *cmd;
|
||||||
run("udevadm trigger --action=add --type=devices");
|
char line[80];
|
||||||
run("udevadm settle --timeout=120");
|
|
||||||
|
cmd = which("udevd");
|
||||||
|
if (!cmd)
|
||||||
|
cmd = which("/lib/systemd/systemd-udevd");
|
||||||
|
if (cmd) {
|
||||||
|
udev = 1;
|
||||||
|
|
||||||
|
snprintf(line, sizeof(line), "[12345] %s -- Device event manager daemon", cmd);
|
||||||
|
if (service_register(SVC_TYPE_SERVICE, line, NULL)) {
|
||||||
|
_pe("Failed registering %s", cmd);
|
||||||
|
udev = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -413,6 +417,13 @@ int main(int argc, char* argv[])
|
|||||||
sm_init(&sm);
|
sm_init(&sm);
|
||||||
sm_step(&sm);
|
sm_step(&sm);
|
||||||
|
|
||||||
|
/* On udev systems we can now talk to udevd */
|
||||||
|
if (udev && whichp("udevadm")) {
|
||||||
|
run("udevadm trigger --action=add --type=subsystems");
|
||||||
|
run("udevadm trigger --action=add --type=devices");
|
||||||
|
run("udevadm settle --timeout=120");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Network stuff
|
* Network stuff
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in new issue
Block a user