[OpenWrt-Devel] [PATCH 5/7] procd: add start-console support

Michael Heimpold mhei at heimpold.de
Tue Jan 1 18:44:57 EST 2019


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 <mhei at heimpold.de>
---
 plug/hotplug.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/plug/hotplug.c b/plug/hotplug.c
index 80e6e4d..6b5960a 100644
--- a/plug/hotplug.c
+++ b/plug/hotplug.c
@@ -297,12 +297,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 {
@@ -336,6 +351,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.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list