Skip to content

Commit 350f3ed

Browse files
committed
Switch multirom directory to /data/media/MultiROM
FBE devices leave this directory unencrypted and this saves us a lot of hassle of decrypting and rebooting the phone
1 parent cb751b8 commit 350f3ed

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

install_zip/prebuilt-installer/scripts/extract_multirom.sh

+5-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ if [ -d "/data/media/multirom" ] && [ ! -d "/data/media/MultiROM/multirom" ]; th
99
elif [ -d "/data/media/0/multirom" ] && [ ! -d "/data/media/0/MultiROM/multirom" ]; then
1010
mkdir "/data/media/0/MultiROM"
1111
mv "/data/media/0/multirom" "/data/media/0/MultiROM/multirom"
12+
elif [ -d "/data/media/0/MultiROM/multirom" ] && [ ! -d "/data/media/MultiROM/multirom" ]; then
13+
mkdir "/data/media/MultiROM"
14+
mv "/data/media/0/MultiROM/multirom" "/data/media/MultiROM/multirom"
1215
fi
1316

1417
# Check for existing dirs otherwise create them
@@ -19,13 +22,8 @@ elif [ -d "/data/media/0/MultiROM/multirom" ] ; then
1922
cont="/data/media/0/MultiROM"
2023
base="/data/media/0/MultiROM/multirom"
2124
else
22-
if [ -d "/data/media/0" ] ; then
23-
cont="/data/media/0/MultiROM"
24-
base="/data/media/0/MultiROM/multirom"
25-
else
26-
cont="/data/media/MultiROM"
27-
base="/data/media/MultiROM/multirom"
28-
fi
25+
cont="/data/media/MultiROM"
26+
base="/data/media/MultiROM/multirom"
2927

3028
mkdir "$cont"
3129
chown root:root "$cont"

multirom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ struct multirom_rom *multirom_get_rom_by_id(struct multirom_status *s, int id)
15211521

15221522
int multirom_prepare_for_boot(struct multirom_status *s, struct multirom_rom *to_boot, int always_reboot)
15231523
{
1524-
int exit = always_reboot ? (EXIT_REBOOT | EXIT_UMOUNT) : EXIT_UMOUNT;
1524+
int exit = EXIT_UMOUNT;
15251525
int type = to_boot->type;
15261526

15271527

trampoline/trampoline.cpp

+27-5
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,13 @@ static int try_mount_all_entries(struct fstab *fstab, struct fstab_part *first_d
247247
if(stat("/realdata/unencrypted/key/version", &info) < 0) {
248248
return 0;
249249
} else {
250-
INFO("File system is FBE encrypted");
251-
return -2;
250+
if (!mrom_is_second_boot() && stat("/realdata/media/MultiROM/multirom", &info) >= 0) {
251+
INFO("Multirom found");
252+
return 0;
253+
} else {
254+
INFO("File system is FBE encrypted");
255+
return -2;
256+
}
252257
}
253258
}
254259
}
@@ -273,8 +278,13 @@ static int try_mount_all_entries(struct fstab *fstab, struct fstab_part *first_d
273278
if(stat("/realdata/unencrypted/key/version", &info) < 0) {
274279
return 0;
275280
} else {
276-
INFO("File system is FBE encrypted\n");
277-
return -2;
281+
if (!mrom_is_second_boot() && stat("/realdata/media/MultiROM/multirom", &info) >= 0) {
282+
INFO("Multirom found");
283+
return 0;
284+
} else {
285+
INFO("File system is FBE encrypted\n");
286+
return -2;
287+
}
278288
}
279289
return 0;
280290
}
@@ -426,7 +436,8 @@ static void switch_root(const char* path) {
426436
}
427437

428438
for (auto i : v) {
429-
if (!strncmp(mentry.mnt_dir, i.data(), i.length())) {
439+
if (!strcmp(mentry.mnt_dir, i.data())) {
440+
INFO("%s %s %d not adding to vector\n", mentry.mnt_dir, i.data(), i.length());
430441
add = false;
431442
break;
432443
} else {
@@ -482,6 +493,17 @@ static int do_cmdline(int argc, char *argv[])
482493
} else {
483494
INFO("chroot returned %d\n", error);
484495
}
496+
struct stat info;
497+
if(stat("/system/etc/selinux", &info) < 0) {
498+
INFO("/system/etc/selinux does not exist!\n");
499+
} else {
500+
INFO("/system/etc/selinux exists\n");
501+
}
502+
if (stat("/vendor/etc/selinux", &info) < 0) {
503+
INFO("/vendor/etc/selinux does not exist!\n");
504+
} else {
505+
INFO("/vendor/etc/selinux exists\n");
506+
}
485507
int res;
486508
static char *const cmd[] = { "/init", "selinux_setup", NULL };
487509
res = execv(cmd[0], cmd);

0 commit comments

Comments
 (0)