static int fp_fstab_init(struct module_data *data) { unsigned i; // recovery is fully ptraced so we don't need any patching if (data->bootmode == BOOTMODE_RECOVERY) return 0; DEBUG("patch fstabs...\n"); for (i = 0; i < data->target_fstabs_count; i++) { if (patch_fstab(data, i)) return -1; } return 0; }
int main(int argc, char **argv) { struct fstab *fstab; int ret=0, syspart, i, status; char filenamePatched[PATH_MAX], filenameSystem[PATH_MAX]; // check arguments if(argc!=2) { ERROR("Invalid Arguments"); return -EINVAL; } // get syspart from cmdline syspart = getDualbootSyspart(); if(syspart<0) { ERROR("Cannot read system number"); return -EINVAL; } // patch fstab sprintf(filenamePatched, "%s.patched", argv[1]); sprintf(filenameSystem, "%s.system", argv[1]); patch_fstab(argv[1], filenamePatched, filenameSystem, syspart); // mount system fstab = fs_mgr_read_fstab(filenameSystem); ret = fs_mgr_mount_all(fstab); fs_mgr_free_fstab(fstab); if (ret == -1) { ERROR("fs_mgr_mount_all returned an error\n"); } // mount data fstab = fs_mgr_read_fstab(argv[1]); for (i = 0; i < fstab->num_entries; ++i) { struct fstab_rec* v = &fstab->recs[i]; if(strcmp(PARTITION_USERDATA, v->blk_device)) continue; if (v->fs_mgr_flags & MF_WAIT) { wait_for_file(v->blk_device, WAIT_TIMEOUT); } if (v->fs_mgr_flags & MF_CHECK) { check_fs(v->blk_device, v->fs_type, v->mount_point); } if(mountScriptExists()) { char *e2fsck_argv[] = { "/system/bin/mount_ext4.sh", v->blk_device, v->mount_point }; ret = android_fork_execvp_ext(ARRAY_SIZE(e2fsck_argv), e2fsck_argv, &status, true, LOG_KLOG, true, NULL); } else { ret = mount(v->blk_device, v->mount_point, v->fs_type, v->flags, v->fs_options); } } fs_mgr_free_fstab(fstab); if (ret == -1) { ERROR("error mounting userdata\n"); } return ret; }