diff mbox series

[03/13] image: create pointer to per install Lua state

Message ID 20240221082221.11997-4-stefano.babic@swupdate.org
State Accepted
Delegated to: Stefano Babic
Headers show
Series Extend Lua Environemnt and post-failure scripts | expand

Commit Message

Stefano Babic Feb. 21, 2024, 8:22 a.m. UTC
Add pointer to image structure to the global Lua state to allow handlers
to use it instead of creating a new one.

This allows to call Lua functions that were previously loaded by the
parser or by scripts, or loaded at the startup.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 include/swupdate_image.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--
2.34.1
diff mbox series

Patch

diff --git a/include/swupdate_image.h b/include/swupdate_image.h
index 592a886b..68d97a02 100644
--- a/include/swupdate_image.h
+++ b/include/swupdate_image.h
@@ -12,6 +12,7 @@ 
 #include "bsdqueue.h"
 #include "globals.h"
 #include "swupdate_dict.h"
+#include "lua_util.h"

 typedef enum {
 	FLASH,
@@ -60,7 +61,14 @@  struct img_type {
 	int is_script;
 	int is_partitioner;
 	struct dict properties;
-	struct dict *bootloader; /* pointer to swupdate_cfg's bootloader dict for handlers to modify */
+
+	/*
+	 * Pointers to global structures
+	 * that are alive during an installation. They can be used by handlers
+	 */
+	struct dict *bootloader;/* pointer to swupdate_cfg's bootloader dict for handlers to modify */
+	lua_State *L;		/* pointer to swupdate_cfg's LUa state created by parser */
+
 	long long partsize;
 	int fdin;	/* Used for streaming file */
 	off_t offset;	/* offset in cpio file */