Add delta.ua - a binary to apply an upgrade of DELTA_FS type.
[platform/core/system/upgrade.git] / src / delta-ua / engine / fota_common.h
1 /*
2  * delta-ua
3  *
4  * Copyright (c) 2017 - 2022 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __FOTA_COMMON_H__
20 #define __FOTA_COMMON_H__
21
22 #include <stdio.h>
23 #include "fota_log.h"
24
25 typedef unsigned int u32;
26 #ifndef __size_t /* typedef check for x86 env: stddef.h */
27 #define __size_t
28 typedef u32 size_t;
29 #endif /* __size_t */
30
31 #define MAX_FILE_PATH           512
32
33 #ifndef TIME_PROFILING
34         //#define TIME_PROFILING
35 #endif
36 #ifndef HEAP_PROFILING
37         //#define HEAP_PROFILING;
38 #endif
39 #ifndef MEM_PROFILING
40         //#define MEM_PROFILING
41 #endif
42 #ifndef POWER_FAIL_TEST
43         //#define POWER_FAIL_TEST
44 #endif
45
46 #define UNUSED(x) (void)(x)
47
48 #define SS_TOTA_VERSION                 "1.0.19"
49 #define BSDIFF                          "BSDIFF40"
50 #define IMGDIFF                         "IMGDIFF2"
51 #define SECTOR_SIZE                     512F
52 #define SS_KERNEL_DELTA_HEADER          128
53
54 #define SS_BACKUP_SOURCE                 "/saved.file"       //How to make sure there is SPACE
55 #define SS_PATCHFILE_SOURCE              "/patchfile.file"   //define in common place
56 #define SS_PATCHLIST_BKUPLOC             "/patchlist.txt"
57 #define SS_NEW_COMPRESSED_FILE           "/system.7z"
58 #define SS_UPDATE_STATUS_PATH            "/UP.STATUS"
59
60 #define SS_PATCHLISTFORMAT              ".txt"
61 #define SS_PATCH_ATTR_FORMAT            "_attr.txt"
62 #define SS_FSCOUNT_MAGIC_KEY            "PaTcHCoUnT:"
63 #define SS_FSCOUNT_MAGIG_KEYLEN         (11)    //length of  SS_FSCOUNT_MAGIC_KEY
64
65 #define SS_TOKEN_SPACE                  " "
66 #define SS_TOKEN_NEWLINE                "\n"
67 #define SS_TOEKN_COLON                  ":"
68 #define SS_FWSLASH                      "/"
69 #define SS_NULLENTRY                    "0"
70 #define SS_MAX_NAMELENSUPPORTED         (200)   //(Tar supports 256, But extra space is used for PartitionName, .delta, /p, so restricting filename max to 200)
71 #define SS_MAX_FILE_PATH                (512)
72 #define SS_TOKEN_MAXLINE_LEN            (1024)
73 #define SS_COMPRESSED_FILE              "system.7z"
74
75 #define SS_STRING_DIFF                  "DIFF"
76 #define SS_STRING_MOVE                  "MOVE"
77 #define SS_STRING_DEL                   "DEL"
78 #define SS_STRING_SYM                   "SYM"
79 #define SS_STRING_HARD                  "HARD"
80 #define SS_STRING_NEW                   "NEW"
81 #define SS_STRING_REG                   "REG"
82 #define SS_STRING_TPK                   "TPK"
83 #define SS_STRING_ZIP                   "ZIP"
84 #define SS_STRING_END                   "END"
85
86 #define SS_COMMON_WORKSPACE                     "/run/upgrade-sysroot/opt/usr/data/fota"
87
88 #ifdef MEM_PROFILING
89 #define SS_MEMORY_USAGE_LOG             SS_COMMON_WORKSPACE "/log_memory"
90 #define SS_MEMORY_PROFILING_SCRIPT      SS_COMMON_WORKSPACE "/mem_use.sh"
91 #endif
92
93 #ifdef POWER_FAIL_TEST
94 #define SS_POWER_FAIL_TEST_FLAG         SS_COMMON_WORKSPACE "/power_fail_test_flag"
95 #endif
96
97 struct tar_Data {
98         int itemSize;
99         int itemOffset;
100         int itemName[256];
101         struct tar_Data *nextnode;
102 };
103 typedef struct tar_Data tar_Data_t;
104
105 #endif                          /* __FOTA_COMMON_H__ */