From ba4c4dbbbd65ce45622d9f2a92e9322348ed12ef Mon Sep 17 00:00:00 2001 From: Michael Heimpold Date: Wed, 2 Jan 2019 00:44:57 +0100 Subject: [PATCH] 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 --- plug/hotplug.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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) -- 2.30.2