6
6
#include "common.h"
7
7
#include "recovery_ui.h"
8
8
#include "mounts.h"
9
+ #include "roots.h"
9
10
10
11
extern int ui_menu_level ;
11
12
extern int ui_root_menu ;
12
13
static enum dualboot_system selected_system = INVALID_SYSTEM ;
14
+ static int force_raw_format = 0 ;
13
15
14
16
struct partition {
15
17
char path [PATH_MAX ];
@@ -28,7 +30,7 @@ enum dualboot_system get_selected_system(void) {
28
30
}
29
31
30
32
static int select_system (const char * title ) {
31
- char * headers [] = { title , "" , NULL };
33
+ const char * headers [] = { title , "" , NULL };
32
34
char * items [] = { "System1" , "System2" , NULL };
33
35
enum dualboot_system chosen_item = -1 ;
34
36
@@ -85,13 +87,13 @@ static int replace_device_node(int num, struct stat* statbuf) {
85
87
MountedVolume * mv = find_mounted_volume_by_real_node (part_table [num ].path );
86
88
87
89
if (mv != NULL && unmount_mounted_volume (mv )!= 0 ) {
88
- LOGE ("replace_device_node: could not unmount device!\n" );
90
+ LOGE ("could not unmount device!\n" );
89
91
return -1 ;
90
92
}
91
93
92
94
unlink (part_table [num ].path );
93
95
if (mknod (part_table [num ].path , statbuf -> st_mode , statbuf -> st_rdev )!= 0 ) {
94
- LOGE ("replace_device_node: could not create node!\n" );
96
+ LOGE ("could not create node!\n" );
95
97
return -1 ;
96
98
}
97
99
@@ -152,3 +154,42 @@ void dualboot_set_system(enum dualboot_system sys) {
152
154
selected_system = sys ;
153
155
dualboot_setup_env ();
154
156
}
157
+
158
+ static int dualboot_mount_dataroot (void ) {
159
+ int rc = ensure_path_mounted_at_mount_point ("/data" , MOUNTPOINT_DATAROOT );
160
+ if (rc )
161
+ LOGE ("failed mounting dataroot!\n" );
162
+ return rc ;
163
+ }
164
+
165
+ int dualboot_is_tdb_enabled (void ) {
166
+ struct stat st ;
167
+
168
+ if (dualboot_mount_dataroot ())
169
+ return 0 ;
170
+
171
+ return lstat (TDB_FILE , & st )== 0 ;
172
+ }
173
+
174
+ void dualboot_set_tdb_enabled (int enable ) {
175
+ if (dualboot_mount_dataroot ())
176
+ return ;
177
+
178
+ if (enable ) {
179
+ FILE * pFile = fopen (TDB_FILE , "w" );
180
+ if (pFile == NULL ) {
181
+ LOGE ("TrueDualBoot: failed creating file" );
182
+ return ;
183
+ }
184
+ fclose (pFile );
185
+ }
186
+ else remove (TDB_FILE );
187
+ }
188
+
189
+ int is_force_raw_format_enabled (void ) {
190
+ return !!force_raw_format ;
191
+ }
192
+
193
+ void set_force_raw_format_enabled (int enabled ) {
194
+ force_raw_format = enabled ;
195
+ }
0 commit comments