diff mbox series

[6/9] Use new swupdate.cfg API to read sw versions

Message ID 20210126131412.3567-7-michael.adler@siemens.com
State Changes Requested
Headers show
Series Overhaul swupdate.cfg handling | expand

Commit Message

Michael Adler Jan. 27, 2021, 2:04 p.m. UTC
Signed-off-by: Michael Adler <michael.adler@siemens.com>
Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 core/artifacts_versions.c | 6 +++---
 core/swupdate.c           | 9 +++++----
 include/util.h            | 3 ++-
 3 files changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/core/artifacts_versions.c b/core/artifacts_versions.c
index cba45b7..6074c33 100644
--- a/core/artifacts_versions.c
+++ b/core/artifacts_versions.c
@@ -129,7 +129,7 @@  static int versions_settings(void *setting, void *data)
 	return 0;
 }
 
-void get_sw_versions(char *cfgname, struct swupdate_cfg *sw)
+void get_sw_versions(swupdate_cfg_handle *handle, struct swupdate_cfg *sw)
 {
 	int ret = -EINVAL;
 
@@ -138,8 +138,8 @@  void get_sw_versions(char *cfgname, struct swupdate_cfg *sw)
 	 * If not found, fall back to a legacy file
 	 * in the format "<image name> <version>"
 	 */
-	if (cfgname)
-		ret = read_module_settings(cfgname, "versions",
+	if (handle != NULL)
+		ret = swupdate_cfg_read_module_settings(handle, "versions",
 						versions_settings,
 						sw);
 
diff --git a/core/swupdate.c b/core/swupdate.c
index 37eda4c..a76e670 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -581,7 +581,12 @@  int main(int argc, char **argv)
 		(void)swupdate_cfg_read_module_settings(&handle, "processes",
 					   read_processes_settings, &swcfg);
 
+
+		get_sw_versions(&handle, &swcfg);
+
 		swupdate_cfg_destroy(&handle);
+	} else {
+		get_sw_versions(NULL, &swcfg);
 	}
 
 	/*
@@ -826,15 +831,11 @@  int main(int argc, char **argv)
 		}
 	}
 
-
 	if (strlen(swcfg.globals.default_software_set) > 0 && strlen(swcfg.globals.default_running_mode) > 0) {
 		INFO("software set: %s mode: %s", swcfg.globals.default_software_set,
 				swcfg.globals.default_running_mode);
 	}
 
-	/* Read sw-versions */
-	get_sw_versions(cfgfname, &swcfg);
-
 	/*
 	 *  Start daemon if just a check is required
 	 *  SWUpdate will exit after the check
diff --git a/include/util.h b/include/util.h
index a0edd3e..ad2e90c 100644
--- a/include/util.h
+++ b/include/util.h
@@ -17,6 +17,7 @@ 
 #endif
 #include "swupdate.h"
 #include "swupdate_status.h"
+#include "swupdate_settings.h"
 #include "compat.h"
 
 #define NOTIFY_BUF_SIZE 	2048
@@ -208,7 +209,7 @@  char *substring(const char *src, int first, int len);
 size_t snescape(char *dst, size_t n, const char *src);
 void freeargs (char **argv);
 int get_hw_revision(struct hw_type *hw);
-void get_sw_versions(char *cfgfname, struct swupdate_cfg *sw);
+void get_sw_versions(swupdate_cfg_handle *handle, struct swupdate_cfg *sw);
 int compare_versions(const char* left_version, const char* right_version);
 int hwid_match(const char* rev, const char* hwrev);
 int check_hw_compatibility(struct swupdate_cfg *cfg);