static int mount_and_run(struct fstab *fstab) { struct fstab_part *datap = fstab_find_first_by_path(fstab, "/data"); if(!datap) { ERROR("Failed to find /data partition in fstab\n"); return -1; } if(access(datap->device, R_OK) < 0) { INFO("Waiting for %s\n", datap->device); if(wait_for_file(datap->device, 5) < 0) { ERROR("Waiting too long for dev %s\n", datap->device); return -1; } } mkdir(REALDATA, 0755); if(try_mount_all_entries(fstab, datap) < 0) { #ifndef MR_ENCRYPTION ERROR("Failed to mount /data with all possible filesystems!\n"); return -1; #else INFO("Failed to mount /data, trying encryption...\n"); switch(encryption_before_mount(fstab)) { case ENC_RES_ERR: ERROR("/data decryption failed!\n"); return -1; case ENC_RES_BOOT_INTERNAL: return 0; default: case ENC_RES_OK: { if(try_mount_all_entries(fstab, datap) < 0) { ERROR("Failed to mount decrypted /data with all possible filesystems!\n"); return -1; } break; } } #endif } if(find_multirom() == -1) { ERROR("Could not find multirom folder!\n"); return -1; } adb_init(path_multirom); run_multirom(); adb_quit(); return 0; }
static void mount_and_run(struct fstab *fstab) { struct fstab_part *p = fstab_find_by_path(fstab, "/data"); if(!p) { ERROR("Failed to find /data partition in fstab\n"); return; } if(wait_for_file(p->device, 5) < 0) { ERROR("Waiting too long for dev %s", p->device); return; } // Remove nosuid flag, because secondary ROMs have // su binaries on /data p->mountflags &= ~(MS_NOSUID); mkdir(REALDATA, 0755); if (mount(p->device, REALDATA, p->type, p->mountflags, p->options) < 0) { ERROR("Failed to mount /realdata, err %d, trying all filesystems\n", errno); const char *fs_types[] = { "ext4", "f2fs", "ext3", "ext2" }; const char *fs_opts [] = { "barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic", // ext4 "inline_xattr,flush_merge,errors=recover", // f2fs "", // ext3 "" // ext2 }; int mounted = 0; size_t i; for(i = 0; i < ARRAY_SIZE(fs_types); ++i) { ERROR("Trying to mount %s with fs %s\n", p->device, fs_types[i]); if(mount(p->device, REALDATA, fs_types[i], p->mountflags, fs_opts[i]) >= 0) { ERROR("/realdata successfuly mounted with fs %s\n", fs_types[i]); mounted = 1; break; } } if(!mounted) { ERROR("Failed to mount /realdata with all possible filesystems!"); return; } } if(find_multirom() == -1) { ERROR("Could not find multirom folder!"); return; } adb_init(path_multirom); run_multirom(); adb_quit(); }