/* If tmp_mount_point is non-null, mount the filesystem there. This is for the * tmp mount we do to check the user password */ int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, char *tmp_mount_point) { int i = 0; int ret = -1; char *m; if (!fstab) { return ret; } for (i = 0; i < fstab->num_entries; i++) { if (!fs_match(fstab->recs[i].mount_point, n_name)) { continue; } /* We found our match */ /* If this is a raw partition, report an error */ if (!strcmp(fstab->recs[i].fs_type, "emmc") || !strcmp(fstab->recs[i].fs_type, "mtd")) { ERROR("Cannot mount filesystem of type %s on %s\n", fstab->recs[i].fs_type, n_blk_device); goto out; } /* First check the filesystem if requested */ if (fstab->recs[i].fs_mgr_flags & MF_WAIT) { wait_for_file(n_blk_device, WAIT_TIMEOUT); } if (fstab->recs[i].fs_mgr_flags & MF_CHECK) { check_fs(n_blk_device, fstab->recs[i].fs_type, fstab->recs[i].mount_point); } /* Now mount it where requested */ if (tmp_mount_point) { m = tmp_mount_point; } else { m = fstab->recs[i].mount_point; } if (mount(n_blk_device, m, fstab->recs[i].fs_type, fstab->recs[i].flags, fstab->recs[i].fs_options)) { ERROR("Cannot mount filesystem on %s at %s\n", n_blk_device, m); goto out; } else { ret = 0; goto out; } } /* We didn't find a match, say so and return an error */ ERROR("Cannot find mount point %s in fstab\n", fstab->recs[i].mount_point); out: return ret; }
/* Check if we should ignore this filesystem. */ static int ignore(struct fs_info *fs) { const char **ip; int wanted = 0; /* * If the pass number is 0, ignore it. */ if (fs->passno == 0) return 1; /* * If this is a bind mount, ignore it. */ if (opt_in_list("bind", fs->opts)) { fprintf(stderr, _("%s: skipping bad line in /etc/fstab: bind mount with nonzero fsck pass number\n"), fs->mountpt); return 1; } interpret_type(fs); /* * If a specific fstype is specified, and it doesn't match, * ignore it. */ if (!fs_match(fs, &fs_type_compiled)) return 1; /* Are we ignoring this type? */ for(ip = ignored_types; *ip; ip++) if (strcmp(fs->type, *ip) == 0) return 1; /* Do we really really want to check this fs? */ for(ip = really_wanted; *ip; ip++) if (strcmp(fs->type, *ip) == 0) { wanted = 1; break; } /* See if the <fsck.fs> program is available. */ if (find_fsck(fs->type) == NULL) { if (wanted) fprintf(stderr, _("fsck: cannot check %s: fsck.%s not found\n"), fs->device, fs->type); return 1; } /* We can and want to check this file system type. */ return 0; }
/* If tmp_mnt_point is non-null, mount the filesystem there. This is for the * tmp mount we do to check the user password */ int fs_mgr_do_mount(char *fstab_file, char *n_name, char *n_blk_dev, char *tmp_mnt_point) { int i = 0; int ret = -1; struct fstab_rec *fstab = 0; char *m; if (!(fstab = read_fstab(fstab_file))) { return ret; } for (i = 0; fstab[i].blk_dev; i++) { if (!fs_match(fstab[i].mnt_point, n_name)) { continue; } /* We found our match */ /* First check the filesystem if requested */ if (fstab[i].fs_mgr_flags & MF_WAIT) { wait_for_file(fstab[i].blk_dev, WAIT_TIMEOUT); } if (fstab[i].fs_mgr_flags & MF_CHECK) { check_fs(fstab[i].blk_dev, fstab[i].type, fstab[i].mnt_point); } /* Now mount it where requested */ if (tmp_mnt_point) { m = tmp_mnt_point; } else { m = fstab[i].mnt_point; } if (mount(n_blk_dev, m, fstab[i].type, fstab[i].flags, fstab[i].fs_options)) { ERROR("Cannot mount filesystem on %s at %s\n", n_blk_dev, m); goto out; } else { ret = 0; goto out; } } /* We didn't find a match, say so and return an error */ ERROR("Cannot find mount point %s in fstab\n", fstab[i].mnt_point); out: free_fstab(fstab); return ret; }
static int ignore(struct fs_info *fs) { const char **ip; int wanted = 0; if (fs->passno == 0) return 1; if (opt_in_list("bind", fs->opts)) { fprintf(stderr, _("%s: skipping bad line in /etc/fstab: bind mount with nonzero fsck pass number\n"), fs->mountpt); return 1; } interpret_type(fs); if (!fs_match(fs, &fs_type_compiled)) return 1; for(ip = ignored_types; *ip; ip++) if (strcmp(fs->type, *ip) == 0) return 1; for(ip = really_wanted; *ip; ip++) if (strcmp(fs->type, *ip) == 0) { wanted = 1; break; } if (find_fsck(fs->type) == NULL) { if (wanted) fprintf(stderr, _("fsck: cannot check %s: fsck.%s not found\n"), fs->device, fs->type); return 1; } return 0; }
/* Check if we should ignore this filesystem. */ static int ignore(struct fs_info *fs) { int wanted; char *s; /* * If the pass number is 0, ignore it. */ if (fs->passno == 0) return 1; interpret_type(fs); /* * If a specific fstype is specified, and it doesn't match, * ignore it. */ if (!fs_match(fs, &fs_type_compiled)) return 1; /* Are we ignoring this type? */ if (index_in_str_array(ignored_types, fs->type) >= 0) return 1; /* Do we really really want to check this fs? */ wanted = index_in_str_array(really_wanted, fs->type) >= 0; /* See if the <fsck.fs> program is available. */ s = find_fsck(fs->type); if (s == NULL) { if (wanted) bb_error_msg("cannot check %s: fsck.%s not found", fs->device, fs->type); return 1; } free(s); /* We can and want to check this file system type. */ return 0; }
/* If tmp_mount_point is non-null, mount the filesystem there. This is for the * tmp mount we do to check the user password * If multiple fstab entries are to be mounted on "n_name", it will try to mount each one * in turn, and stop on 1st success, or no more match. */ int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, char *tmp_mount_point) { int i = 0; int ret = FS_MGR_DOMNT_FAILED; int mount_errors = 0; int first_mount_errno = 0; char *m; if (!fstab) { return ret; } for (i = 0; i < fstab->num_entries; i++) { if (!fs_match(fstab->recs[i].mount_point, n_name)) { continue; } /* We found our match */ /* If this swap or a raw partition, report an error */ if (!strcmp(fstab->recs[i].fs_type, "swap") || !strcmp(fstab->recs[i].fs_type, "emmc") || !strcmp(fstab->recs[i].fs_type, "mtd")) { ERROR("Cannot mount filesystem of type %s on %s\n", fstab->recs[i].fs_type, n_blk_device); goto out; } /* First check the filesystem if requested */ if (fstab->recs[i].fs_mgr_flags & MF_WAIT) { wait_for_file(n_blk_device, WAIT_TIMEOUT); } if (fstab->recs[i].fs_mgr_flags & MF_CHECK) { check_fs(n_blk_device, fstab->recs[i].fs_type, fstab->recs[i].mount_point); } if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && !device_is_debuggable()) { if (fs_mgr_setup_verity(&fstab->recs[i]) < 0) { ERROR("Could not set up verified partition, skipping!\n"); continue; } } /* Now mount it where requested */ if (tmp_mount_point) { m = tmp_mount_point; } else { m = fstab->recs[i].mount_point; } if (__mount(n_blk_device, m, &fstab->recs[i], FS_MGR_MNTALL_DEV_NOT_ENCRYPTED)) { if (!first_mount_errno) first_mount_errno = errno; mount_errors++; continue; } else { ret = 0; goto out; } } if (mount_errors) { ERROR("Cannot mount filesystem on %s at %s. error: %s\n", n_blk_device, m, strerror(first_mount_errno)); if (first_mount_errno == EBUSY) { ret = FS_MGR_DOMNT_BUSY; } else { ret = FS_MGR_DOMNT_FAILED; } } else { /* We didn't find a match, say so and return an error */ ERROR("Cannot find mount point %s in fstab\n", fstab->recs[i].mount_point); } out: return ret; }
/* If tmp_mount_point is non-null, mount the filesystem there. This is for the * tmp mount we do to check the user password * If multiple fstab entries are to be mounted on "n_name", it will try to mount each one * in turn, and stop on 1st success, or no more match. */ int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, char *tmp_mount_point) { int i = 0; int ret = FS_MGR_DOMNT_FAILED; int mount_errors = 0; int first_mount_errno = 0; char *m; if (!fstab) { return ret; } for (i = 0; i < fstab->num_entries; i++) { if (!fs_match(fstab->recs[i].mount_point, n_name)) { continue; } /* We found our match */ /* If this swap or a raw partition, report an error */ if (!strcmp(fstab->recs[i].fs_type, "swap") || !strcmp(fstab->recs[i].fs_type, "emmc") || !strcmp(fstab->recs[i].fs_type, "mtd")) { ERROR("Cannot mount filesystem of type %s on %s\n", fstab->recs[i].fs_type, n_blk_device); goto out; } /* First check the filesystem if requested */ if (fstab->recs[i].fs_mgr_flags & MF_WAIT) { wait_for_file(n_blk_device, WAIT_TIMEOUT); } int force_check = do_quota(fstab->recs[i].blk_device, fstab->recs[i].fs_type, &fstab->recs[i]); if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) { check_fs(n_blk_device, fstab->recs[i].fs_type, fstab->recs[i].mount_point); } if (fstab->recs[i].fs_mgr_flags & MF_RESERVEDSIZE) { do_reserved_size(n_blk_device, fstab->recs[i].fs_type, &fstab->recs[i]); } if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && device_is_secure()) { int rc = fs_mgr_setup_verity(&fstab->recs[i]); if (__android_log_is_debuggable() && rc == FS_MGR_SETUP_VERITY_DISABLED) { INFO("Verity disabled"); } else if (rc != FS_MGR_SETUP_VERITY_SUCCESS) { ERROR("Could not set up verified partition, skipping!\n"); continue; } } /* Now mount it where requested */ if (tmp_mount_point) { m = tmp_mount_point; } else { m = fstab->recs[i].mount_point; } if (__mount(n_blk_device, m, &fstab->recs[i])) { if (!first_mount_errno) first_mount_errno = errno; mount_errors++; continue; } else { ret = 0; goto out; } } if (mount_errors) { ERROR("Cannot mount filesystem on %s at %s. error: %s\n", n_blk_device, m, strerror(first_mount_errno)); if (first_mount_errno == EBUSY) { ret = FS_MGR_DOMNT_BUSY; } else { ret = FS_MGR_DOMNT_FAILED; } } else { /* We didn't find a match, say so and return an error */ ERROR("Cannot find mount point %s in fstab\n", fstab->recs[i].mount_point); } out: return ret; }