diff mbox series

[3/3] handler: Print registered session & global handlers

Message ID E536A8E2-7126-4EAC-BDA1-23196243E936@siemens.com
State Accepted
Headers show
Series [1/3] Lua: Rename lua_init() to lua_session_init() | expand

Commit Message

Storm, Christian June 13, 2024, 4:12 p.m. UTC
With Lua handlers having become session handlers, print
them as well on SWUpdate startup.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 core/handler.c          | 8 +++++---
 core/swupdate.c         | 2 +-
 corelib/lua_interface.c | 1 +
 include/handler.h       | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/core/handler.c b/core/handler.c
index 74a211ac..f4789d82 100644
--- a/core/handler.c
+++ b/core/handler.c
@@ -98,16 +98,18 @@  void unregister_session_handlers(void)
 	}
 }
 
-void print_registered_handlers(void)
+void print_registered_handlers(bool global)
 {
 	unsigned int i;
 
 	if (!nr_installers)
 		return;
 
-	INFO("Registered handlers:");
+	INFO("Registered %s handlers:", global ? "global" : "session");
 	for (i = 0; i < nr_installers; i++) {
-		INFO("\t%s", supported_types[i].desc);
+		if (!global == supported_types[i].noglobal) {
+			INFO("\t%s", supported_types[i].desc);
+		}
 	}
 }
 
diff --git a/core/swupdate.c b/core/swupdate.c
index 009abbbc..8d6467b7 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -866,7 +866,7 @@  int main(int argc, char **argv)
 	if(!get_hw_revision(&swcfg.hw))
 		INFO("Running on %s Revision %s", swcfg.hw.boardname, swcfg.hw.revision);
 
-	print_registered_handlers();
+	print_registered_handlers(true);
 	if (swcfg.syslog_enabled) {
 		if (syslog_init()) {
 			ERROR("failed to initialize syslog notifier");
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index 8de2e3cd..6b425dd0 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -1603,6 +1603,7 @@  int lua_init(void)
 {
 	lua_State *L = luaL_newstate();
 	int res = lua_handlers_init(L);
+	print_registered_handlers(false);
 	unregister_session_handlers();
 	lua_close(L);
 	if (!gL) {
diff --git a/include/handler.h b/include/handler.h
index e100bd72..dc4bfe38 100644
--- a/include/handler.h
+++ b/include/handler.h
@@ -80,6 +80,6 @@  int unregister_handler(const char *desc);
 void unregister_session_handlers(void);
 
 struct installer_handler *find_handler(struct img_type *img);
-void print_registered_handlers(void);
+void print_registered_handlers(bool global);
 struct installer_handler *get_next_handler(void);
 unsigned int get_handler_mask(struct img_type *img);