From e07df72a9a02fe760732b69255cf35e74f91f885 Mon Sep 17 00:00:00 2001 From: Antoni Adaszkiewicz Date: Thu, 1 Sep 2022 15:36:01 +0200 Subject: [PATCH] upgrade-apply-deltafs: Drop legacy code Change-Id: I92f09fe0eaf2556db36ebda7c0d9308f7c13fdee --- src/upgrade-apply-deltafs/CMakeLists.txt | 1 - .../engine/SS_FSUpdate.c | 15 - src/upgrade-apply-deltafs/engine/SS_UPI.c | 511 ++---------------- src/upgrade-apply-deltafs/engine/SS_UPI.h | 3 - .../engine/fota_common.h | 23 - src/upgrade-apply-deltafs/engine/fota_log.c | 86 +-- src/upgrade-apply-deltafs/engine/fota_log.h | 3 +- src/upgrade-apply-deltafs/fota_cfg.c | 32 -- src/upgrade-apply-deltafs/fota_cfg.h | 41 -- src/upgrade-apply-deltafs/ua.c | 45 +- src/upgrade-apply-deltafs/ua.h | 4 - 11 files changed, 52 insertions(+), 712 deletions(-) delete mode 100755 src/upgrade-apply-deltafs/fota_cfg.c delete mode 100755 src/upgrade-apply-deltafs/fota_cfg.h diff --git a/src/upgrade-apply-deltafs/CMakeLists.txt b/src/upgrade-apply-deltafs/CMakeLists.txt index 7944b59..a7e335e 100644 --- a/src/upgrade-apply-deltafs/CMakeLists.txt +++ b/src/upgrade-apply-deltafs/CMakeLists.txt @@ -2,7 +2,6 @@ ADD_DEFINITIONS("-DFEATURE_SUPPORT_CAPABILITY") ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64") SET(SRCS - fota_cfg.c fota_util.c ua.c engine/SS_Common.c diff --git a/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c b/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c index 78ca0f3..1cb3211 100755 --- a/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c +++ b/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c @@ -1059,10 +1059,6 @@ SS_GetAvailableFreeSpace(const char *partition_name, return 0; } -#ifdef HEAP_PROFILING - int max_mem; - int cur_mem; -#endif /*******[ Multiprocess API sample implementation ]******/ void *SS_Malloc(SS_UINT32 size) { @@ -1070,23 +1066,12 @@ void *SS_Malloc(SS_UINT32 size) if (p) memset(p, 0, size); -#ifdef HEAP_PROFILING - cur_mem += size; - if (cur_mem > max_mem) { - max_mem = cur_mem; - LOGL(LOG_SSENGINE, "New chunk [%d] assigned making heap [%d]\n", size, cur_mem); - } -#endif return p; } void SS_Free(void *pMemBlock) { -#ifdef HEAP_PROFILING - cur_mem -= malloc_usable_size(pMemBlock); - LOGL(LOG_SSENGINE, "Old chunk [%d] removed making heap [%d]\n", malloc_usable_size(pMemBlock), cur_mem); -#endif if (pMemBlock) free(pMemBlock); } diff --git a/src/upgrade-apply-deltafs/engine/SS_UPI.c b/src/upgrade-apply-deltafs/engine/SS_UPI.c index b6f5ec8..4e013fe 100755 --- a/src/upgrade-apply-deltafs/engine/SS_UPI.c +++ b/src/upgrade-apply-deltafs/engine/SS_UPI.c @@ -48,74 +48,6 @@ int gvalid_session = 0; //used as fail-safe in case device is turmed off or ba fs_list *headptr_list; tar_Data_t *tar_cfg_data = NULL; -#ifdef MEM_PROFILING -/* - Description: - Create script file , set it executable, execute script in child process - Only works if valid delta.tar is present for upgrade - Summary: - If MEM_PROFILING is activated, - we can see the result of memory profiling after delta upgrade - in file defined by macro - SS_MEMORY_PROFILING_SCRIPT -*/ -int mem_profiling_start = 0; -int SS_Do_Memory_Profiling() -{ - int ret = -1; - pid_t pid; - char memory_usage_script[1024] = "#!/bin/bash\nlog_file=$1\npid=$2\nmaxmem=0\nwhile [[ -d \"/proc/${pid}\" ]]; do\n\ - mem=`cat /proc/${pid}/smaps | grep Pss | grep -v Swap|awk '{print $2}'|awk '{s+=$1} END {print s}'`\n\ - if [[ ${mem} -gt ${maxmem} ]]; then\nmaxmem=${mem}\n\ - echo -e \"Memory usage till now is: ${maxmem} KB.\" >> $log_file\n fi\n sleep 0.01\ndone\n\ - echo -e \"Max was : ${maxmem} KB.\" >> $log_file\n"; - char cmd[1024] = { 0, }; - - //Open a file and write the script contents in it - FILE *fp = fopen(SS_MEMORY_PROFILING_SCRIPT, "w+"); - fwrite(memory_usage_script, strlen(memory_usage_script), 1, fp); - fclose(fp); - //make the file executable - Octal 495 is 757 decimal - if (chmod(SS_MEMORY_PROFILING_SCRIPT, 495) < 0) { - LOGE("Error in chmod(%s, 495) - %d (%s)\n", SS_MEMORY_PROFILING_SCRIPT, errno, strerror(errno)); - return E_SS_FAILURE; - } - //calling mem_use.sh - //Usage : - pid = getpid(); - snprintf(cmd, sizeof(cmd) - 1, "%s %s %d", SS_MEMORY_PROFILING_SCRIPT, SS_MEMORY_USAGE_LOG, pid); - ret = _system_cmd_nowait(cmd); - sleep(1); - LOG("ret for memory profiling cmd is %d\n", ret); - if (ret == 0) { - mem_profiling_start = 1; - return S_SS_SUCCESS; - } else { - LOGE("Could not start Memory Profiling\n"); - return E_SS_FAILURE; - } -} -#endif -#ifdef TIME_PROFILING -static char ts1[256]; -static double ts2; -double t1; -double t2; -double fast_tar_get_item_size_time = 0.0; -double SS_LoadFile_time = 0.0; -double SS_FSBuildNodes_time = 0.0; - -static void get_time_stamp1(void) -{ - struct timeval tv; - int sec, msec; - - gettimeofday(&tv, NULL); - sec = (int)tv.tv_sec; - msec = (int)(tv.tv_usec / 1000); - snprintf(ts1, 256, "%06d.%03d", sec % 100000, msec); -} -#endif - //Check SS function if available int file_exist(char *filename) { @@ -129,88 +61,6 @@ int file_exist(char *filename) return (ret >= 0) ? (1) : (0); } -#ifdef POWER_FAIL_TEST - -static int SS_Get_power_fail_flag(void) -{ - int fd; - char buf[256]; - char *ptr = NULL; - int result = 0; - int ret_val = 0; - - if (file_exist(SS_POWER_FAIL_TEST_FLAG) == 0) { - LOGE("No exist file!!\n"); - return -1; - } - - fd = open(SS_POWER_FAIL_TEST_FLAG, O_RDWR, S_IRWXU); - if (fd == -1) { - LOGE("Could not open status file!!\n"); - return -1; - } - - result = SS_ReadFile(fd, 0, buf, sizeof(buf)); - if (result != 0) { - LOGE("SS_ReadFile failed!!\n"); - return -1; - } - - ret_val = atoi(buf); - - result = SS_CloseFile(fd); - if (result != 0) - LOGE("SS_CloseFile failed!!\n"); - - return ret_val; -} - -static void SS_Set_power_fail_flag(int del_type) -{ - int fd; - int result = 0; - char num_str[16]; - LOG("del_type:[%d]\n", del_type); - - fd = open(SS_POWER_FAIL_TEST_FLAG, O_RDWR | O_CREAT, S_IRWXU); - if (fd == -1) { - LOGE("Could not open status file!!\n"); - return; - } - - sprintf(num_str, "%d", del_type); - result = SS_WriteFile(fd, 0, num_str, strlen(num_str)); - if (result != 0) - LOGE("SS_WriteFile failed!!\n"); - - result = SS_CloseFile(fd); - if (result != 0) - LOGE("SS_CloseFile failed!!\n"); - - sync(); - -} - -int SS_Do_Power_fail_test(int del_type) -{ - int ret = -1; - char cmd[1024] = { 0, }; - - SS_Set_power_fail_flag(del_type); - - snprintf(cmd, sizeof(cmd) - 1, "%s", "/usr/sbin/reboot fota"); - ret = _system_cmd_nowait(cmd); - sleep(1); - LOG("ret for SS_Do_Power_fail_test cmd is %d\n", ret); - if (ret == 0) { - return S_SS_SUCCESS; - } else { - LOGE("Could not start Memory Profiling\n"); - return E_SS_FAILURE; - } -} -#endif - int SS_GetProgressResolution(int ultotalFSCnt) { if (ultotalFSCnt < DISPLAYRESOLUTION_SIZE) @@ -231,78 +81,6 @@ int SS_GetUpgradeState() return FS_UpgradeState; } -int SS_Get_last_update_status(int* last_update_status, int* del_type, char* status_path) -{ - int fd; - unsigned char buf[257]; - char *ptr = NULL; - char *saveptr = NULL; - int result = 0; - - if (file_exist(status_path) == 0) { - LOG("No exist file!! - File_path:[%s]\n", status_path); - return -1; - } - - fd = open(status_path, O_RDWR, S_IRWXU); - if (fd == -1) { - LOGE("Could not open status file!!, File_path:[%s]\n", status_path); - return -1; - } - - result = SS_ReadFile(fd, 0, buf, sizeof(buf)-1); - if (result != 0) { - LOGE("SS_ReadFile failed!!\n"); - result = SS_CloseFile(fd); - if (result != 0) - LOGE("SS_CloseFile failed!!\n"); - return -1; - } - - ptr = strtok_r((char *)buf, " ", &saveptr); - - if (ptr != NULL) { - *last_update_status = atoi(ptr); - ptr = strtok_r(NULL, " ", &saveptr); - } - - if (ptr != NULL) { - *del_type = atoi(ptr); - } - - result = SS_CloseFile(fd); - if (result != 0) - LOGE("SS_CloseFile failed!!\n"); - - return 0; -} - -void SS_Set_last_update_status(int last_update_status, int del_type, char *status_path) -{ - int fd; - int result = 0; - char num_str[16]; - LOG("last_update_status:[%d], del_type:[%d]\n", last_update_status, del_type); - - fd = open(status_path, O_RDWR | O_CREAT, S_IRWXU); - if (fd == -1) { - LOGE("Could not open status file!!, File_path:[%s]\n", status_path); - return; - } - - snprintf(num_str, sizeof(num_str), "%d %d", last_update_status, del_type); - result = SS_WriteFile(fd, 0, (unsigned char *)num_str, strlen(num_str)); - if (result != 0) - LOGE("SS_WriteFile failed!!\n"); - - result = SS_CloseFile(fd); - if (result != 0) - LOGE("SS_CloseFile failed!!\n"); - - sync(); - -} - int SS_rename1(const char *old_file_name, const char *new_file_name) { int result = E_SS_FAILURE; @@ -1367,12 +1145,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f case DIFFS: { LOGL(LOG_SSENGINE, "DIFFS mode start\n"); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, "DIFFS mode start time = [%lf]\n", - t1); -#endif tar_open(ua_dataSS->update_data->ua_delta_path); while (pFsNode) { //LOGL(LOG_SSENGINE, "DIFFS update Index: [%d] \n", ulFileIndex++); @@ -1417,13 +1189,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f } LOGL(LOG_SSENGINE, "DIFFS : Total index = [%d]\n", ulFileIndex - 1); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "DIFFS mode end time = [%lf], diff = [%lf]\n", t2, - (t2 - t1)); -#endif tar_close(); LOGL(LOG_SSENGINE, "DIFFS mode end\n"); } @@ -1431,13 +1196,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f case MOVES: { LOGL(LOG_SSENGINE, "MOVES mode start\n"); - -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, "MOVES mode start time = [%lf]\n", - t1); -#endif while (pFsNode) { //LOGL(LOG_SSENGINE, "MOVES update Index: [%d] \n", ulFileIndex++); int skip_flag = 0; @@ -1513,13 +1271,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f } LOGL(LOG_SSENGINE, "MOVES : Total index = [%d]\n", ulFileIndex - 1); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "MOVES mode end time = [%lf], diff = [%lf]\n", t2, - (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "MOVES mode end\n"); } break; @@ -1528,12 +1279,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f LOGL(LOG_SSENGINE, "DELETES mode start\n"); int ulFiletype = 0; -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, "DELETES mode start time = [%lf]\n", - t1); -#endif while (pFsNode) { if (pFsNode->type == DELETES) { //LOGL(LOG_SSENGINE, "DELETES update Index: [%d] \n", ulFileIndex++); @@ -1554,13 +1299,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f } LOGL(LOG_SSENGINE, "DELETES : Total index = [%d]\n", ulFileIndex - 1); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "DELETES mode end time = [%lf], diff = [%lf]\n", - t2, (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "DELETES mode end\n"); } break; @@ -1569,12 +1307,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f LOGL(LOG_SSENGINE, "DELETE_END mode start\n"); int ulFiletype = 0; -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, - "DELETE_END mode start time = [%lf]\n", t1); -#endif while (pFsNode) { if (pFsNode->type == DELETE_END) { LOGL(LOG_SSENGINE, "DELETE_END update Index: [%d] \n", ulFileIndex++); @@ -1594,13 +1326,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f } LOGL(LOG_SSENGINE, "DELETE_END : Total index = [%d]\n", ulFileIndex - 1); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "DELETE_END mode start time = [%lf], diff = [%lf]\n", - t2, (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "DELETE_END mode end\n"); } break; @@ -1608,13 +1333,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f case NEWFILES: { LOGL(LOG_SSENGINE, "NEWFILES mode start\n"); - -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, "NEWFILES mode start time = [%lf]\n", - t1); -#endif LOGL(LOG_SSENGINE, "Starting New file upgrade for [%s]\n", patch_path); if (tar_extract_file(ua_dataSS->update_data->ua_delta_path, (char *)patch_path, new_compressed_path) >= 0) @@ -1625,26 +1343,12 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f else LOGL(LOG_SSENGINE, "tar extraction error for %s\n", ua_dataSS->parti_info->ua_parti_name); SS_DeleteFile(new_compressed_path); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "NEWFILES mode end time = [%lf], diff = [%lf]\n", - t2, (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "NEWFILES mode end\n"); } break; case SYMDIFFS: { LOGL(LOG_SSENGINE, "SYMDIFFS mode start\n"); - -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, "SYMDIFFS mode start time = [%lf]\n", - t1); -#endif while (pFsNode) { //LOGL(LOG_SSENGINE, "SYMDIFFS update Index: [%d] \n", ulFileIndex++); //LOG("Sym Diff file paths: [Linkname - %s] [reference file name- %s][]\n", pFsNode->file_path,pFsNode->patch_name); @@ -1666,13 +1370,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f } LOGL(LOG_SSENGINE, "SYMDIFFS : Total index = [%d]\n", ulFileIndex - 1); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "SYMDIFFS mode end time = [%lf], diff = [%lf]\n", - t2, (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "SYMDIFFS mode end\n"); } break; @@ -1682,12 +1379,7 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f fs_params *head_node; int retry_count = 0, do_retry = 0; -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, - "SYMNEWFILES mode start time = [%lf]\n", t1); -#endif + SYMLINK_CREATE: head_node = pFsNode; while (head_node) { @@ -1722,26 +1414,12 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f //SS_SetUpgradeState(E_SS_FSUPDATEFAILED); break; } -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "SYMNEWFILES mode end time = [%lf], diff = [%lf]\n", - t2, (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "SYMNEWFILES mode end\n"); } break; case HARDDIFFS: { LOGL(LOG_SSENGINE, "HARDDIFFS mode start\n"); - -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, "HARDDIFFS mode start time = [%lf]\n", - t1); -#endif while (pFsNode) { //LOGL(LOG_SSENGINE, "SYMDIFFS update Index: [%d] \n", ulFileIndex++); //LOG("Sym Diff file paths: [Linkname - %s] [reference file name- %s][]\n", pFsNode->file_path,pFsNode->patch_name); @@ -1763,26 +1441,12 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f } LOGL(LOG_SSENGINE, "HARDDIFFS : Total index = [%d]\n", ulFileIndex - 1); -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "HARDDIFFS mode end time = [%lf], diff = [%lf]\n", - t2, (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "HARDDIFFS mode end\n"); } break; case HARDNEWFILES: { LOGL(LOG_SSENGINE, "HARDNEWFILES mode start\n"); - -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t1 = atof(ts1); - LOGL(LOG_SSENGINE, - "HARDNEWFILES mode start time = [%lf]\n", t1); -#endif fs_params *head_node = pFsNode; while (head_node) { //LOGL(LOG_SSENGINE, "SYMNEWS update Index: [%d] \n", ulFileIndex++); @@ -1800,14 +1464,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f } LOGL(LOG_SSENGINE, "HARDNEWFILES : Total index = [%d]\n", ulFileIndex - 1); - -#ifdef TIME_PROFILING - get_time_stamp1(); //total time capturing - t2 = atof(ts1); - LOGL(LOG_SSENGINE, - "HARDNEWFILES mode end time = [%lf], diff = [%lf]\n", - t2, (t2 - t1)); -#endif LOGL(LOG_SSENGINE, "HARDNEWFILES mode end\n"); } @@ -1818,10 +1474,6 @@ int SS_FSUpdateFile(int ubFileType, ua_dataSS_t * ua_dataSS, int ulPatchCount, f return ulResult; } -#ifdef MEM_PROFILING -extern int max_mem; -extern int cur_mem; -#endif /*! ********************************************************************************* * SS_FSUpdatemain @@ -1842,14 +1494,9 @@ extern int cur_mem; int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) { int ulResult = S_SS_SUCCESS; - int last_update_status = 0; - int del_type = 0; + fs_list *head_ptr_node = NULL; - char new_patch_path[SS_MAX_FILE_PATH] = { - 0 - }; - char status_path[MAX_FILE_PATH]; - snprintf(status_path, MAX_FILE_PATH, "%s/%s",ua_dataSS->update_data->ua_delta_folder, SS_UPDATE_STATUS_PATH); + char new_patch_path[SS_MAX_FILE_PATH] = {0}; if (!ua_dataSS) return E_SS_BAD_PARAMS; // Set error ?? @@ -1867,104 +1514,56 @@ int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) LOGL(LOG_SSENGINE, "FS Update Entry\n"); -#ifdef POWER_FAIL_TEST - int fail_test_flag = 0; - fail_test_flag = SS_Get_power_fail_flag(); - LOGL(LOG_SSENGINE, "fail_test_flag: [%d]\n", fail_test_flag); -#endif - - if(SS_Get_last_update_status(&last_update_status, &del_type, status_path) == -1) - LOGE("SS_Get_last_update_status failed!!\n"); - - LOGL(LOG_SSENGINE, "last_update_status: [%d], del_type: [%d]\n", last_update_status, del_type); - - // for now, we don't want to read last del_type as the logic doesn't work - del_type = 0; - if (head_ptr_node->del_ref == NULL) { LOGL(LOG_SSENGINE, "No DEL header\n"); } else if (ulResult == S_SS_SUCCESS) { - if (del_type < DELETES) { - ulResult = SS_FSUpdateFile(DELETES, ua_dataSS, head_ptr_node->ulPatchCount, head_ptr_node->del_ref, - ua_dataSS->update_delta->ua_patch_path); - if (ulResult == S_SS_SUCCESS) { - LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DELETES success!!\n"); + ulResult = SS_FSUpdateFile(DELETES, ua_dataSS, head_ptr_node->ulPatchCount, head_ptr_node->del_ref, + ua_dataSS->update_delta->ua_patch_path); + if (ulResult == S_SS_SUCCESS) { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DELETES success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < DELETES) { - if (SS_Do_Power_fail_test(DELETES) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif - SS_Set_last_update_status(0, DELETES, status_path); - } } else { - LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DELETES already applied!!\n"); + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DELETES fail!!\n"); } } if (head_ptr_node->dif_ref == NULL) { LOGL(LOG_SSENGINE, "No DIFF header\n"); } else if (ulResult == S_SS_SUCCESS) { - ulResult = - SS_FSUpdateFile(DIFFS, ua_dataSS, head_ptr_node->ulPatchCount, head_ptr_node->dif_ref, - ua_dataSS->update_delta->ua_patch_path); + ulResult = SS_FSUpdateFile(DIFFS, ua_dataSS, head_ptr_node->ulPatchCount, head_ptr_node->dif_ref, + ua_dataSS->update_delta->ua_patch_path); if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DIFFS success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < DIFFS) { - if (SS_Do_Power_fail_test(DIFFS) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif + + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DIFFS fail!!\n"); } } if (head_ptr_node->move_ref == NULL) { LOGL(LOG_SSENGINE, "No MOVE header\n"); } else if (ulResult == S_SS_SUCCESS) { - if (del_type < MOVES) { - ulResult = - SS_FSUpdateFile(MOVES, ua_dataSS, head_ptr_node->ulPatchCount, head_ptr_node->move_ref, - ua_dataSS->update_delta->ua_patch_path); - if (ulResult == S_SS_SUCCESS) { + ulResult = SS_FSUpdateFile(MOVES, ua_dataSS, head_ptr_node->ulPatchCount, head_ptr_node->move_ref, + ua_dataSS->update_delta->ua_patch_path); + if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - MOVES success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < MOVES) { - if (SS_Do_Power_fail_test(MOVES) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif - SS_Set_last_update_status(0, MOVES, status_path); + + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - MOVES fail!!\n"); } - } else { - LOGL(LOG_SSENGINE, "SS_FSUpdateFile - MOVES already applied!!\n"); - } } if (head_ptr_node->del_ref == NULL) { LOGL(LOG_SSENGINE, "No DEL header\n"); } else if (ulResult == S_SS_SUCCESS) { - if (del_type < DELETE_END) { ulResult = SS_FSUpdateFile(DELETE_END, ua_dataSS, head_ptr_node->ulPatchCount, head_ptr_node->del_ref, ua_dataSS->update_delta->ua_patch_path); if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DELETE_END success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < DELETE_END) { - if (SS_Do_Power_fail_test(DELETE_END) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif - SS_Set_last_update_status(0, DELETE_END, status_path); + + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DELETE_END fail!!\n"); } - } else { - LOGL(LOG_SSENGINE, "SS_FSUpdateFile - DELETE_END already applied!!\n"); - } } if (ulResult == S_SS_SUCCESS) { @@ -1976,6 +1575,8 @@ int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) //new file extraction end if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - NEWFILES success!!\n"); + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - NEWFILES fail!!\n"); } } @@ -1987,13 +1588,9 @@ int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) ua_dataSS->update_delta->ua_patch_path); if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - SYMDIFFS success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < SYMDIFFS) { - if (SS_Do_Power_fail_test(SYMDIFFS) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif + + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - SYMDIFFS fail!!\n"); } } @@ -2005,13 +1602,9 @@ int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) ua_dataSS->update_delta->ua_patch_path); if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - SYMNEWFILES success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < SYMNEWFILES) { - if (SS_Do_Power_fail_test(SYMNEWFILES) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif + + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - SYMNEWFILES fail!!\n"); } } @@ -2023,13 +1616,9 @@ int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) ua_dataSS->update_delta->ua_patch_path); if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - HARDNEWFILES success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < HARDNEWFILES) { - if (SS_Do_Power_fail_test(HARDNEWFILES) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif + + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - HARDNEWFILES fail!!\n"); } } @@ -2041,13 +1630,9 @@ int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) ua_dataSS->update_delta->ua_patch_path); if (ulResult == S_SS_SUCCESS) { LOGL(LOG_SSENGINE, "SS_FSUpdateFile - HARDDIFFs success!!\n"); -#ifdef POWER_FAIL_TEST - if (fail_test_flag < HARDDIFFS) { - if (SS_Do_Power_fail_test(HARDDIFFS) == E_SS_FAILURE) { - LOGE("SS_Do_Power_fail_test failed!!\n"); - } - } -#endif + + } else { + LOGL(LOG_SSENGINE, "SS_FSUpdateFile - HARDDIFFs fail!!\n"); } } @@ -2063,16 +1648,10 @@ int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS) if (ulResult == S_SS_SUCCESS) { SS_UpdateUIProgress(ua_dataSS, 0, 1); //fix WGID : 51963, When all updates are done to FS , patchcount is not needed, passing 1 to 3rd arg is enough - SS_Set_last_update_status(0, DEL_TYPE_MAX, status_path); } LOGL(LOG_SSENGINE, "FS update Complete\n"); -#ifdef MEM_PROFILING - LOGL(LOG_SSENGINE, "Stats are : Cur Max : [%d] Global Max : [%d]\n", cur_mem, max_mem); -#endif -#ifdef POWER_FAIL_TEST - unlink(SS_POWER_FAIL_TEST_FLAG); -#endif + if (ulResult == S_SS_SUCCESS) return ulResult; else @@ -2128,21 +1707,12 @@ int SS_FSVerifyPartition(ua_dataSS_t * ua_dataSS) return E_SS_FAILURE; } -#ifdef MEM_PROFILING - if (!mem_profiling_start) - if (!(S_SS_SUCCESS == SS_Do_Memory_Profiling())) - return E_SS_FAILURE; -#endif SS_GetPartition_LocDetails(ua_dataSS); LOGL(LOG_SSENGINE, "FS Verification Start\n"); if (ua_dataSS->ua_operation == UI_OP_SCOUT) gvalid_session = 1; // (shd b true if called during verification) headptr_list = SS_FSBuildNodes(ua_dataSS); -#ifdef TIME_PROFILING - LOGL(LOG_SSENGINE, "fast_tar_get_item_size_time :[%lf]\n", fast_tar_get_item_size_time); - LOGL(LOG_SSENGINE, "SS_LoadFile_time :[%lf]\n", SS_LoadFile_time); - LOGL(LOG_SSENGINE, "SS_FSBuildNodes_time :[%lf]\n", SS_FSBuildNodes_time); -#endif + if (!headptr_list) { LOGE("FS Verification Failed\n"); SS_FSClearNodes(); @@ -2196,11 +1766,6 @@ long SS_GetUPIVersion(unsigned char *ver_str) { if (ver_str) { strncpy((char *)ver_str, SS_TOTA_VERSION, MAX_PATH); -#ifdef MEM_PROFILING - if (!mem_profiling_start) - if (!(S_SS_SUCCESS == SS_Do_Memory_Profiling())) - LOGE("Unable to start Memory_Profiling\n"); -#endif return S_SS_SUCCESS;//wgid: 2456 } else return E_SS_FAILURE; diff --git a/src/upgrade-apply-deltafs/engine/SS_UPI.h b/src/upgrade-apply-deltafs/engine/SS_UPI.h index b9cb744..5968ab9 100755 --- a/src/upgrade-apply-deltafs/engine/SS_UPI.h +++ b/src/upgrade-apply-deltafs/engine/SS_UPI.h @@ -85,7 +85,4 @@ extern int _7zdecompress(char *path); extern void tar_free_cfg_table(tar_Data_t ** delta_tar); extern long SS_GetFileType(char *pLinkName, enumFileType * fileType); -extern int SS_Get_last_update_status(int* last_update_status, int* del_type, char *status_path); -extern void SS_Set_last_update_status(int last_update_status, int del_type, char *status_path); - #endif //_SS_UPI_H_ diff --git a/src/upgrade-apply-deltafs/engine/fota_common.h b/src/upgrade-apply-deltafs/engine/fota_common.h index 38a6ec9..e93e28e 100755 --- a/src/upgrade-apply-deltafs/engine/fota_common.h +++ b/src/upgrade-apply-deltafs/engine/fota_common.h @@ -30,19 +30,6 @@ typedef u32 size_t; #define MAX_FILE_PATH 512 -#ifndef TIME_PROFILING - //#define TIME_PROFILING -#endif -#ifndef HEAP_PROFILING - //#define HEAP_PROFILING; -#endif -#ifndef MEM_PROFILING - //#define MEM_PROFILING -#endif -#ifndef POWER_FAIL_TEST - //#define POWER_FAIL_TEST -#endif - #define UNUSED(x) (void)(x) #define SS_TOTA_VERSION "1.0.19" @@ -55,7 +42,6 @@ typedef u32 size_t; #define SS_PATCHFILE_SOURCE "/patchfile.file" //define in common place #define SS_PATCHLIST_BKUPLOC "/patchlist.txt" #define SS_NEW_COMPRESSED_FILE "/system.7z" -#define SS_UPDATE_STATUS_PATH "/UP.STATUS" #define SS_PATCHLISTFORMAT ".txt" #define SS_PATCH_ATTR_FORMAT "_attr.txt" @@ -85,15 +71,6 @@ typedef u32 size_t; #define SS_COMMON_WORKSPACE "/run/upgrade-sysroot/opt/usr/data/fota" -#ifdef MEM_PROFILING -#define SS_MEMORY_USAGE_LOG SS_COMMON_WORKSPACE "/log_memory" -#define SS_MEMORY_PROFILING_SCRIPT SS_COMMON_WORKSPACE "/mem_use.sh" -#endif - -#ifdef POWER_FAIL_TEST -#define SS_POWER_FAIL_TEST_FLAG SS_COMMON_WORKSPACE "/power_fail_test_flag" -#endif - struct tar_Data { int itemSize; int itemOffset; diff --git a/src/upgrade-apply-deltafs/engine/fota_log.c b/src/upgrade-apply-deltafs/engine/fota_log.c index 93c42ed..e4e6923 100755 --- a/src/upgrade-apply-deltafs/engine/fota_log.c +++ b/src/upgrade-apply-deltafs/engine/fota_log.c @@ -1,7 +1,7 @@ /* * upgrade-apply-deltafs * - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 - 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ #include #include -#define LOG_SIZE_OPT_PATH "/opt/data/recovery/.ua_log_size" #define DEF_MAX_LOG_SIZE (2*1024*1024) #define MAX_FILE_PATH 512 @@ -35,89 +34,6 @@ long next_offset = 0; long backup_offset = 0; long max_logfile_size = DEF_MAX_LOG_SIZE; -/*----------------------------------------------------------------------------- - __check_existence - ----------------------------------------------------------------------------*/ -static long __check_existence(const char *file_path) -{ - struct stat statbuf; - char filename[MAX_FILE_PATH]; - - if (strncpy(filename, file_path, strlen(file_path) + 1) == NULL) - return 0; - if (stat(filename, &statbuf)) { - if (ENOENT == errno) - return 0; - } - return statbuf.st_size; -} - -/*----------------------------------------------------------------------------- - __read_from_file - ----------------------------------------------------------------------------*/ -static int __read_from_file(const char *path, char *buf, size_t size) -{ - int fd; - ssize_t count; - - if (!path) - return -1; - - if (size == 0) - return 0; - - fd = open(path, O_RDONLY, 0); - if (fd == -1) - return -1; - - count = read(fd, buf, size); - if (count > 0) { - count = (count < (ssize_t)size) ? count : ((ssize_t)size - 1); - while (count > 0 && buf[count - 1] == '\n') - count--; - buf[count] = '\0'; - } else { - buf[0] = '\0'; - } - - close(fd); - - return (int)count; -} - -/*----------------------------------------------------------------------------- - get_opt_logfile_size - ----------------------------------------------------------------------------*/ -static int get_opt_logfile_size(void) -{ - /* - if status file does not exist, status = UP_START_NONE. - if status file exist, read status from file. - */ - char buf[256]; - - if (__check_existence(LOG_SIZE_OPT_PATH) == 0) - return -1; - - if (__read_from_file(LOG_SIZE_OPT_PATH, buf, sizeof(buf)) < 0) - return -1; - - return atoi(buf); -} - -/*----------------------------------------------------------------------------- - set_max_logfile_size - ----------------------------------------------------------------------------*/ -void set_max_logfile_size(void) -{ - int size = get_opt_logfile_size(); - - if (size <= 0) - size = DEF_MAX_LOG_SIZE; - - max_logfile_size = size; -} - /*----------------------------------------------------------------------------- log_printf ----------------------------------------------------------------------------*/ diff --git a/src/upgrade-apply-deltafs/engine/fota_log.h b/src/upgrade-apply-deltafs/engine/fota_log.h index 3828241..08c0972 100755 --- a/src/upgrade-apply-deltafs/engine/fota_log.h +++ b/src/upgrade-apply-deltafs/engine/fota_log.h @@ -1,7 +1,7 @@ /* * upgrade-apply-deltafs * - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 - 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ extern unsigned int __log_level__; extern FILE *__log_out_file__; extern int log_printf(FILE* log_fp, char* format_str, ...); -extern void set_max_logfile_size(void); #define LOG_INFO (1<<8) #define LOG_ENGINE (1<<7) diff --git a/src/upgrade-apply-deltafs/fota_cfg.c b/src/upgrade-apply-deltafs/fota_cfg.c deleted file mode 100755 index 803b37f..0000000 --- a/src/upgrade-apply-deltafs/fota_cfg.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * upgrade-apply-deltafs - * - * Copyright (c) 2017 - 2022 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "fota_cfg.h" - -char fota_cfg_str[EN_CFG_MAX][CFG_MAX_LEN]; - -void fota_cfg_str_load(void) -{ - strncpy(fota_cfg_str[EN_CFG_SUPPORT_FB], "1", CFG_MAX_LEN-1); - strncpy(fota_cfg_str[EN_CFG_SUPPORT_DRM], "0", CFG_MAX_LEN-1); - strncpy(fota_cfg_str[EN_CFG_DEV_FB], "/dev/fb0", CFG_MAX_LEN-1); - strncpy(fota_cfg_str[EN_CFG_DEV_DRM_NAME], "exynos", CFG_MAX_LEN-1); -} - diff --git a/src/upgrade-apply-deltafs/fota_cfg.h b/src/upgrade-apply-deltafs/fota_cfg.h deleted file mode 100755 index a72fb32..0000000 --- a/src/upgrade-apply-deltafs/fota_cfg.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * upgrade-apply-deltafs - * - * Copyright (c) 2017 -2022 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __FOTA_CFG_H__ -#define __FOTA_CFG_H__ - -#define CFG_MAX_LEN 1024 - -enum { - EN_CFG_SUPPORT_FB, - EN_CFG_SUPPORT_DRM, - EN_CFG_DEV_FB, - EN_CFG_DEV_DRM_NAME, - EN_CFG_MAX -}; - -extern char fota_cfg_str[EN_CFG_MAX][CFG_MAX_LEN]; - - -extern void fota_cfg_str_load(void); - - - -#endif /* __FOTA_FB_H__ */ - - diff --git a/src/upgrade-apply-deltafs/ua.c b/src/upgrade-apply-deltafs/ua.c index 678214b..0f62be2 100755 --- a/src/upgrade-apply-deltafs/ua.c +++ b/src/upgrade-apply-deltafs/ua.c @@ -35,7 +35,6 @@ #include -#include "fota_cfg.h" #include "ua.h" #include "fota_util.h" #include "engine/SS_Common.h" @@ -347,12 +346,7 @@ int update_all() { int ret = OK; int cause = 0, item_size = 0; - int last_update_status = UP_START_NONE; - int update_status = UP_START_NONE; unsigned long ui32Operation = UI_OP_SCOUT; - int del_type = 0; // TODO, for clarity - char status_path[MAX_FILE_PATH]; - snprintf(status_path, MAX_FILE_PATH, "%s/%s",s_update_data.ua_delta_folder, SS_UPDATE_STATUS_PATH); item_size = tar_get_item_size(s_update_data.ua_delta_path, s_part_info.ua_subject_name); if (item_size > 0) @@ -381,30 +375,19 @@ int update_all() s_update_data.ua_delta_path, s_part_info.ua_subject_name); - if (SS_Get_last_update_status(&last_update_status, &del_type, status_path) == -1) - LOG("No last_update_status. Go normal update scenario.\n"); - else - LOG("Get last_update_status. Go Power safe update scenario.\n"); - - LOG("last_update_status: [%d], del_type: [%d] \n", last_update_status, del_type); - /* Verify */ - if (last_update_status == UP_START_NONE) { - - if (s_update_data.data_size > 0) { - get_time_stamp(); - LOG("[%s] Verify %s ..............................................................\n", ts, - s_part_info.ua_parti_name); - - ret = verify_Delta_FS(); - LOG("return form verify : %d\n", ret); - if (ret != OK) { - cause = ret; - ret = UPI_VERIFY_ERROR; - LOG("%s verify fail\n", s_part_info.ua_parti_name); - goto CleanUp; - } - } + if (s_update_data.data_size > 0) { + get_time_stamp(); + LOG("[%s] Verify %s ..............................................................\n", ts, + s_part_info.ua_parti_name); + ret = verify_Delta_FS(); + LOG("return form verify : %d\n", ret); + if (ret != OK) { + cause = ret; + ret = UPI_VERIFY_ERROR; + LOG("%s verify fail\n", s_part_info.ua_parti_name); + goto CleanUp; + } } get_time_stamp(); @@ -419,8 +402,6 @@ int update_all() LOG("[%s] Update %s ..............................................................\n", ts, s_part_info.ua_parti_name); - SS_Set_last_update_status(update_status, del_type, status_path); // i have to look into what it does - ret = update_Delta_FS(ui32Operation); LOG("return form update : %d\n", ret); if (ret != OK) { @@ -605,7 +586,6 @@ int fota_path_init(void) } snprintf(s_update_data.ua_delta_path, MAX_FILE_PATH, "%s/%s", delta_folder, DEFAULT_DELTA_NAME); snprintf(fota_cause, sizeof(fota_cause), "%s/%s", result_folder, "cause"); - snprintf(fota_status_path, sizeof(fota_status_path), "%s/%s", result_folder, UP_STATUS_FILE); LOG("s_part_info[UA_%s].ua_delta_path=%s\n", s_part_info.ua_parti_name, @@ -773,7 +753,6 @@ int main(int argc, char **argv) snprintf(log_folder, sizeof(log_folder)-1, "%s", SYSTEM_LOG_DIR); snprintf(fota_result, sizeof(fota_result), "%s/%s", result_folder, "result"); - fota_cfg_str_load(); if (check_dm_verity_status() < 0) { // to be removed LOG("check_dm_verity_status fail\n"); diff --git a/src/upgrade-apply-deltafs/ua.h b/src/upgrade-apply-deltafs/ua.h index 347159c..635129e 100755 --- a/src/upgrade-apply-deltafs/ua.h +++ b/src/upgrade-apply-deltafs/ua.h @@ -65,10 +65,6 @@ #define UPI_PARTINFO_ERROR UPI_ERROR(ED) #define DEFAULT_DELTA_NAME "delta.tar" -#define UPDATTE_CFG_FILE "update.cfg" - -#define UP_STATUS_FILE "UP.STATUS" -#define UP_START_NONE 0 enum { UA_OP_MODE_FG = 0, -- 2.34.1