From: Michael Heimpold Date: Tue, 1 Jan 2019 23:44:57 +0000 (+0100) Subject: procd: add start-console support X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ba4c4dbbbd65ce45622d9f2a92e9322348ed12ef;p=oweals%2Fprocd.git procd: add start-console support This adds a hotplug function to (re-)start inittab entries with askfirst or respawn. At the moment the devices used with these actions must be present during boot otherwise such lines are skipped. However, this prevents having inittab entries with consoles for e.g. USB gadget devices which only appear after kernel module loading and after configuring them with configfs. While it was possible to only scan the inittab for the desired item to start, I assume the inittab to be short and re-running the whole list will be negligible. Signed-off-by: Michael Heimpold --- diff --git a/plug/hotplug.c b/plug/hotplug.c index fd29e62..c572ced 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -312,12 +312,27 @@ send_to_kernel: exit(-1); } +static void handle_start_console(struct blob_attr *msg, struct blob_attr *data) +{ + char *dev = blobmsg_get_string(blobmsg_data(data)); + + DEBUG(2, "Start console request for %s\n", dev); + + procd_inittab_run("respawn"); + procd_inittab_run("askfirst"); + + DEBUG(2, "Done starting console for %s\n", dev); + + exit(-1); +} + enum { HANDLER_MKDEV = 0, HANDLER_RM, HANDLER_EXEC, HANDLER_BUTTON, HANDLER_FW, + HANDLER_START_CONSOLE, }; static struct cmd_handler { @@ -351,6 +366,10 @@ static struct cmd_handler { .name = "load-firmware", .handler = handle_firmware, }, + [HANDLER_START_CONSOLE] = { + .name = "start-console", + .handler = handle_start_console, + }, }; static void queue_next(void)