@@ -100,22 +100,22 @@ void disable_dtb_fstab(char* partition) {
100
100
if (access ("status" , F_OK )) {
101
101
DIR * dir = opendir ("/proc/device-tree/firmware/android" );
102
102
char * * exclude_dirs = NULL ;
103
- copy_dir_contents (dir , "/proc/device-tree/firmware/android" , "/fakefstab " , exclude_dirs );
103
+ copy_dir_contents (dir , "/proc/device-tree/firmware/android" , "/fakefsbat " , exclude_dirs );
104
104
FILE * fp = fopen ("status" , "w" );
105
105
fprintf (fp , "disabled" );
106
106
fclose (fp );
107
107
}
108
108
char path [256 ];
109
- sprintf (path , "/fakefstab /fstab/%s/status" , partition );
109
+ sprintf (path , "/fakefsbat /fstab/%s/status" , partition );
110
110
copy_file ("/status" , path );
111
111
}
112
112
113
113
void remove_dtb_fstab () {
114
114
mkdir ("/dummy_fw" , S_IFDIR );
115
115
DIR * dir = opendir ("/proc/device-tree/firmware/android" );
116
116
char * * exclude_dirs = NULL ;
117
- copy_dir_contents (dir , "/proc/device-tree/firmware/android" , "/fakefstab " , exclude_dirs );
118
- if (!mount ("/dummy_fw" , "/fakefstab " , "ext4" , MS_BIND , "discard,nomblk_io_submit" )) {
117
+ copy_dir_contents (dir , "/proc/device-tree/firmware/android" , "/fakefsbat " , exclude_dirs );
118
+ if (!mount ("/dummy_fw" , "/fakefsbat " , "ext4" , MS_BIND , "discard,nomblk_io_submit" )) {
119
119
INFO ("dummy dtb node bind mounted in procfs\n" );
120
120
} else {
121
121
ERROR ("dummy dtb node bind mount failed! %s\n" , strerror (errno ));
@@ -124,22 +124,32 @@ void remove_dtb_fstab() {
124
124
125
125
int multirom_is_android10 () {
126
126
if (!multirom_path_exists ("/" , "apex" )) {
127
+ INFO ("APEX folder found\n" );
128
+ return 1 ;
129
+ }
130
+ if (!multirom_path_exists ("/system" , "system/bin/init" )) {
131
+ INFO ("system/bin/init found\n" );
127
132
return 1 ;
128
133
}
129
134
char * initPath = "/main_init" ;
130
135
if (!multirom_path_exists ("/" , "/.backup/init" )) {
131
136
initPath = "/.backup/init" ;
132
137
}
133
138
134
- char * addr ;
139
+ void * addr ;
135
140
int initfd = open (initPath , O_RDWR );
141
+ INFO ("open file %s result %d\n" , initPath , initfd );
136
142
struct stat st ;
137
143
lstat (initPath , & st );
138
144
size_t size = st .st_size ;
139
- addr = mmap (NULL , size , PROT_WRITE , MAP_SHARED , initfd , 0 );
140
- int contains = strstr (addr , "selinux_setup" ) != NULL ;
145
+ addr = mmap (NULL , size , PROT_READ , MAP_SHARED , initfd , 0 );
146
+ if (addr == -1 ) {
147
+ INFO ("mmap error! %s\n" , strerror (errno ));
148
+ }
149
+ int contains = memmem (addr , size , "selinux_setup" , 13 ) != NULL ;
141
150
munmap (addr , size );
142
151
close (initfd );
152
+ INFO ("init contains selinux_setup %d\n" , contains );
143
153
return contains ;
144
154
}
145
155
@@ -1972,6 +1982,7 @@ int multirom_prep_android_mounts(struct multirom_status *s, struct multirom_rom
1972
1982
asprintf (& system_path , "%s/system.sparse.img" , rom -> base_path );
1973
1983
1974
1984
if (!multirom_path_exists ("/system" , "init.rc" ) && !multirom_is_android10 ()) {
1985
+ INFO ("ROM is not android 10\n" );
1975
1986
umount ("/system" );
1976
1987
mkdir_with_perms ("/system_root" , 0755 , NULL , NULL );
1977
1988
multirom_mount_image (system_path , "/system_root" , "ext4" , MS_RDONLY , NULL );
@@ -1988,6 +1999,7 @@ int multirom_prep_android_mounts(struct multirom_status *s, struct multirom_rom
1988
1999
char * exclude_dirs [] = {"system" , "vendor" , "product" , NULL };
1989
2000
copy_init_contents (dir , "/system_root" , "/" , true, exclude_dirs );
1990
2001
} else if (multirom_is_android10 ()) {
2002
+ INFO ("ROM is android 10+\n" );
1991
2003
umount ("/system" );
1992
2004
mkdir_with_perms ("/system_root" , 0755 , NULL , NULL );
1993
2005
multirom_mount_image (system_path , "/system_root" , "ext4" , MS_RDONLY , NULL );
0 commit comments