From 81e2f2afc37b34697ecdc98cf44fef5b312297c6 Mon Sep 17 00:00:00 2001 From: Antoni Adaszkiewicz Date: Mon, 10 Oct 2022 11:31:13 +0200 Subject: [PATCH] upgrade-apply-deltafs: Stop opening log file if logs are redirected to stdout and assume current directory as log directory for host Change-Id: Iae411e68719b977e6941232b2f2c87b3ada552f1 --- src/upgrade-apply-deltafs/ua.c | 14 ++++++++------ src/upgrade-apply-deltafs/ua.h | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/upgrade-apply-deltafs/ua.c b/src/upgrade-apply-deltafs/ua.c index dd231bd..54dba8a 100755 --- a/src/upgrade-apply-deltafs/ua.c +++ b/src/upgrade-apply-deltafs/ua.c @@ -45,9 +45,13 @@ #include "engine/fota_tar.h" #include "engine/ua_types.h" +#ifndef HOST_BUILD +#define LOG_FILE_PATH "/opt/data/update/last_update.log" +#else +#define LOG_FILE_PATH "./last_update.log" +#endif + -#define SYSTEM_LOG_DIR "/opt/var/log" -#define TEMP_FOLDER "/tmp" // TODO //char ua_slot_mode = 0; int dm_verity_status = DM_VERITY_DISABLED; @@ -57,9 +61,7 @@ static char fota_result[MAX_FILE_PATH]; static char fota_cause[MAX_FILE_PATH]; static char delta_folder[MAX_FOLDER_PATH]; static char delta_path[MAX_FILE_PATH]; -static char log_folder[MAX_FOLDER_PATH]; static char result_folder[MAX_FOLDER_PATH]; -static char temp_folder[MAX_FOLDER_PATH]; static char log_path[MAX_FILE_PATH]; static char mnt_point[MAX_FILE_PATH]; @@ -476,6 +478,7 @@ int update_all() ----------------------------------------------------------------------------*/ void log_init(void) { +#ifndef DEBUG_STDOUT snprintf(log_path, sizeof(log_path), "%s", LOG_FILE_PATH); __log_out_file__ = fopen(log_path, "w"); @@ -483,6 +486,7 @@ void log_init(void) perror("file open error\n"); return; } +#endif get_time_stamp(); LOG("===== log start [%s] =====\n", ts); @@ -775,8 +779,6 @@ int main(int argc, char **argv) s_update_data.ua_delta_folder = strdup(delta_folder); s_update_data.ua_delta_path = strdup(delta_path); snprintf(mnt_point, sizeof(mnt_point)-1, "%s", my_opt.dest); - snprintf(temp_folder, sizeof(temp_folder)-1, "%s", TEMP_FOLDER); - snprintf(log_folder, sizeof(log_folder)-1, "%s", SYSTEM_LOG_DIR); snprintf(fota_result, sizeof(fota_result), "%s/%s", result_folder, "result"); diff --git a/src/upgrade-apply-deltafs/ua.h b/src/upgrade-apply-deltafs/ua.h index 4be40fd..94a6577 100755 --- a/src/upgrade-apply-deltafs/ua.h +++ b/src/upgrade-apply-deltafs/ua.h @@ -29,7 +29,6 @@ //#define USE_DELTA_DOWNLOAD //#define USE_DUALSBL -#define LOG_FILE_PATH "/opt/data/update/last_update.log" #define MAX_FILE_PATH 512 #define MAX_FOLDER_PATH 384 -- 2.7.4