14d8773f5483bec6fcc5cb69ff5cbe7764a30106
[platform/core/system/upgrade.git] / src / upgrade-apply-deltafs / engine / ua_types.h
1 /*
2  * upgrade-apply-deltafs
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 __UA_TYPES_H__
20 #define __UA_TYPES_H__
21
22 #include <stdio.h>
23 #include <libtar.h>
24
25 #define MAX_FILE_PATH           512
26 // every delta should have a patchlist text file, and can have
27 // an attribute file additionally
28 #define NO_OF_TEXT_FILES        2
29
30 // the following macros define the meaning of indexes in tar_info.text_files_info array
31
32 // this file has a list of diff files and the number of all operations (DIFFS, NEWS, MOVES etc.)
33 // this file is required to be present in a delta
34 #define PATCHLIST_FILE  0
35
36 // this files lists files whose attributes changed and their new values
37 #define ATTR_FILE       1
38
39 /*
40  * FOTA Adaptaion header
41  */
42
43 #define UI_OP_SCOUT_UPDATE              0
44 #define UI_OP_SCOUT                     1
45 #define UI_OP_UPDATE                    3
46
47 typedef struct _ua_update_data_t {
48         unsigned int weight; // the sum of weight should be 100
49         unsigned int weight_offset; // start offset
50         unsigned int data_size; // byte
51         char *ua_delta_path; // it will be allocated to copy delta file path, need to free memory
52         char *ua_temp_path; // it will be allocated to copy delta file path, need to free memory
53         char *ua_delta_folder;
54 } ua_update_data_t;
55
56 typedef struct _ua_update_cfg_t {
57         int skip_verify;
58         int skip_update;
59         int source_img_size; //TOTA
60 } ua_update_cfg_t;
61
62 typedef struct _ua_part_info_t {
63         char *ua_parti_name;
64         char *ua_subject_name;
65 } ua_part_info_t;
66
67 // User data structure
68 typedef struct _ua_data_t { // partition operations
69         ua_part_info_t *parti_info;
70         ua_update_cfg_t *update_cfg;
71         ua_update_data_t *update_data;
72         unsigned long ua_operation;
73
74         int (*ua_op_read_block)(void *, unsigned char *, unsigned long, unsigned long);
75         int (*ua_op_write_block)(void *, unsigned char *, unsigned long);
76         void (*ui_progress)(void *, unsigned long);
77 } ua_data_t;
78
79 typedef struct _ua_delta_info_t {
80         char ua_patch_path[MAX_FILE_PATH];
81         char ua_patch_info[MAX_FILE_PATH];
82         char ua_delta_path[MAX_FILE_PATH];
83         char ua_attrib_path[MAX_FILE_PATH];
84 } ua_delta_info_t;
85
86 typedef struct _file_text_info {
87         int size;
88         char item_name[MAX_FILE_PATH];
89         char extracted_name[MAX_FILE_PATH];
90 } text_file_info;
91
92 typedef struct _file_7z_info {
93         off_t offset;
94         char item_name[MAX_FILE_PATH];
95         char extracted_name[MAX_FILE_PATH];
96 } file_7z_info;
97
98 typedef struct _tar_info {
99         TAR *tar;
100         char *subject_name;
101         int uncompressed_folder_size;
102         off_t subject_offset;
103         file_7z_info new_files_info;
104         // id = 0 -> config file, id = 1 -> attribute file
105         text_file_info text_files_info[NO_OF_TEXT_FILES];
106 } tar_info;
107
108 typedef struct _ua_dataSS_t { // partition operations
109         ua_part_info_t *parti_info;
110         ua_update_cfg_t *update_cfg;
111         ua_update_data_t *update_data;
112         ua_delta_info_t *update_delta;
113         tar_info *tar_data;
114         unsigned long ua_operation;
115         void (*ui_progress)(void *, unsigned long);
116         int (*write_data_to_blkdev)(char *, int, int, char *);
117 } ua_dataSS_t;
118
119 typedef unsigned int SS_UINT32;
120
121 #endif