6b538ebf6c2702bf5c53ed782f6005ffc4b0d5d2
[platform/core/system/libtota.git] / ss_engine / fota_common.h
1 /*
2  * libtota
3  *
4  * Copyright (c) 2017 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 signed char s8;
26 typedef unsigned char u8;
27
28 typedef signed short s16;
29 typedef unsigned short u16;
30
31 typedef signed int s32;
32 typedef unsigned int u32;
33 #ifndef __size_t /* typedef check for x86 env: stddef.h */
34 #define __size_t
35 typedef u32 size_t;
36 #endif /* __size_t */
37
38 typedef signed long sl32;
39 typedef unsigned long ul32;
40
41 typedef signed long long s64;
42 typedef unsigned long long u64;
43
44 #define MAX_FILE_PATH           512
45
46 #ifndef TIME_PROFILING
47         //#define TIME_PROFILING
48 #endif
49 #ifndef HEAP_PROFILING
50         //#define HEAP_PROFILING;
51 #endif
52 #ifndef MEM_PROFILING
53         //#define MEM_PROFILING
54 #endif
55
56 #define UNUSED(x) (void)(x)
57
58 #define SS_TOTA_VERSION                 "1.0.18"
59 #define BSDIFF                          "BSDIFF40"
60 #define IMGDIFF                         "IMGDIFF2"
61 #define SECTOR_SIZE                     512
62 #define SS_KERNEL_DELTA_HEADER          128
63
64 #define SS_COMMON_WORKSPACE                     "/system/opt/usr/data/fota"
65 #define SS_KERNEL_UNPACK_SCRIPT         "unpack.sh"
66 #define SS_KERN_UNPK_SCRIPT_PATH        SS_COMMON_WORKSPACE "/" SS_KERNEL_UNPACK_SCRIPT
67 #define SS_BACKUP_SOURCE                SS_COMMON_WORKSPACE "/saved.file"       //How to make sure there is SPACE
68 #define SS_PATCHFILE_SOURCE             SS_COMMON_WORKSPACE "/patchfile.file"   //define in common place
69 #define SS_PATCHLIST_BKUPLOC            SS_COMMON_WORKSPACE "/patchlist.txt"
70 #define SS_NEW_COMPRESSED_FILE          SS_COMMON_WORKSPACE "/system.7z"
71 #define SS_KERNEL_WORKSPACE             SS_COMMON_WORKSPACE "/kernel-work"
72 #define SS_GZIP_TARGET                  SS_KERNEL_WORKSPACE "/gzip"
73 #define SS_STAT_TARGET                  SS_KERNEL_WORKSPACE "/stat"
74 #define SS_DD_TARGET                    SS_KERNEL_WORKSPACE "/dd"
75 //#define SS_UPDATE_STATUR_PATH         SS_COMMON_WORKSPACE "/UP.STATUS"
76 #define SS_UPDATE_STATUR_PATH           "/system/opt/data/recovery/UP.STATUS"
77
78 #define SS_GZIP_SOURCE                  "system/bin/gzip"
79 #define SS_STAT_SOURCE                  "system/usr/bin/stat"
80 #define SS_DD_SOURCE                    "system/bin/dd"
81
82 #define SS_KERNEL_MAGIC                 "UnpackdzImage"
83 #define SS_KERNEL_NAME                  "zImage"
84 #define SS_KERNEL_TARGET_NAME           "dzImage_final"
85 #define SS_KERNEL_UNPACK_DIR            SS_KERNEL_NAME "_unpacked"
86 #define SS_PATCHLISTFOLDER              "/p"
87 #define SS_NEWPATCHFOLDER               "/n"
88 #define SS_PATCHLISTFORMAT              ".txt"
89 #define SS_PATCH_ATTR_FORMAT            "_attr.txt"
90 #define SS_FSCOUNT_MAGIC_KEY            "PaTcHCoUnT:"
91 #define SS_FSCOUNT_MAGIG_KEYLEN         (11)    //length of  SS_FSCOUNT_MAGIC_KEY
92 #define SS_IMAGE_MAGIC_KEY              "TiZSiG@tOtA_00_:.{0,64}"
93 #define SS_IMAGE_MAGIC_KEY_VAL          SS_COMMON_WORKSPACE "/delta_sha.txt"
94
95 #define SS_TOKEN_SPACE                  " "
96 #define SS_TOKEN_NEWLINE                "\n"
97 #define SS_TOEKN_COLON                  ":"
98 #define SS_CHAR_FWSLASH                 '/'
99 #define SS_FWSLASH                      "/"
100 #define SS_NULLENTRY                    "0"
101 #define SS_MAX_NAMELENSUPPORTED         (200)   //(Tar supports 256, But extra space is used for PartitionName, .delta, /p, so restricting filename max to 200)
102 #define SS_MAX_FILE_PATH                (512)
103 #define SS_TOKEN_MAXLINE_LEN            (1024)
104 #define SS_COMPRESSED_FILE              "system.7z"
105
106 #define SS_STRING_DIFF                  "DIFF"
107 #define SS_STRING_MOVE                  "MOVE"
108 #define SS_STRING_DEL                   "DEL"
109 #define SS_STRING_SYM                   "SYM"
110 #define SS_STRING_NEW                   "NEW"
111 #define SS_STRING_REG                   "REG"
112 #define SS_STRING_TPK                   "TPK"
113 #define SS_STRING_ZIP                   "ZIP"
114 #define SS_STRING_END                   "END"
115
116 #ifdef MEM_PROFILING
117 #define SS_MEMORY_USAGE_LOG             SS_COMMON_WORKSPACE "/log_memory"
118 #define SS_MEMORY_PROFILING_SCRIPT      SS_COMMON_WORKSPACE "/mem_use.sh"
119 #endif
120
121 struct tar_Data {
122         int itemSize;
123         int itemOffset;
124         int itemName[256];
125         struct tar_Data *nextnode;
126 };
127 typedef struct tar_Data tar_Data_t;
128
129 #endif                          /* __FOTA_COMMON_H__ */