Home | History | Annotate | Download | only in fs_mgr

Lines Matching refs:fstab

292  * Tries to mount any of the consecutive fstab entries that match
293 * the mountpoint of the one given by fstab->recs[start_idx].
296 * attempted_idx: On return, will indicate which fstab rec
302 static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_idx, int *attempted_idx)
308 if (!end_idx || !attempted_idx || start_idx >= fstab->num_entries) {
315 /* Hunt down an fstab entry for the same mount point that might succeed */
317 /* We required that fstab entries for the same mountpoint be consecutive */
318 i < fstab->num_entries && !strcmp(fstab->recs[start_idx].mount_point, fstab->recs[i].mount_point);
326 ERROR("%s(): skipping fstab dup mountpoint=%s rec[%d].fs_type=%s already mounted as %s.\n", __func__,
327 fstab->recs[i].mount_point, i, fstab->recs[i].fs_type, fstab->recs[*attempted_idx].fs_type);
331 if (fstab->recs[i].fs_mgr_flags & MF_CHECK) {
332 check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
333 fstab->recs[i].mount_point);
335 if (!__mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point, &fstab->recs[i])) {
340 fstab->recs[i].blk_device, fstab->recs[i].mount_point, fstab->recs[i].fs_type,
341 fstab->recs[start_idx].fs_type);
350 if (i < fstab->num_entries) --i;
439 static int handle_encryptable(struct fstab *fstab, const struct fstab_rec* rec)
483 if (fs_mgr_do_mount(fstab, rec->mount_point,
495 /* When multiple fstab records share the same mount_point, it will
500 int fs_mgr_mount_all(struct fstab *fstab)
509 if (!fstab) {
513 for (i = 0; i < fstab->num_entries; i++) {
515 if (fstab->recs[i].fs_mgr_flags & (MF_VOLDMANAGED | MF_RECOVERYONLY)) {
520 if (!strcmp(fstab->recs[i].fs_type, "swap") ||
521 !strcmp(fstab->recs[i].fs_type, "emmc") ||
522 !strcmp(fstab->recs[i].fs_type, "mtd")) {
527 fstab->recs[i].fs_type, "ext2") ||
528 !strcmp(fstab->recs[i].fs_type, "ext3") ||
529 !strcmp(fstab->recs[i].fs_type, "ext4")) {
530 int tret = translate_ext_labels(&fstab->recs[i]);
537 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
538 wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
541 if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && device_is_secure()) {
542 int rc = fs_mgr_setup_verity(&fstab->recs[i]);
553 mret = mount_with_alternatives(fstab, i, &last_idx_inspected, &attempted_idx);
559 int status = handle_encryptable(fstab, &fstab->recs[attempted_idx]);
579 bool wiped = partition_wiped(fstab->recs[top_idx].blk_device);
581 fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) {
583 * at two different lines in the fstab. Use the top one for formatting
587 fstab->recs[top_idx].blk_device, fstab->recs[top_idx].mount_point,
588 fstab->recs[top_idx].fs_type);
589 if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
590 strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
591 int fd = open(fstab->recs[top_idx].key_loc, O_WRONLY, 0644);
593 INFO("%s(): also wipe %s\n", __func__, fstab->recs[top_idx].key_loc);
598 fstab->recs[top_idx].key_loc, strerror(errno));
601 if (fs_mgr_do_format(&fstab->recs[top_idx]) == 0) {
608 fs_mgr_is_encryptable(&fstab->recs[attempted_idx])) {
611 fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
612 fstab->recs[attempted_idx].fs_type);
620 fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
621 fstab->recs[attempted_idx].fs_type);
622 if (fs_mgr_do_tmpfs_mount(fstab->recs[attempted_idx].mount_point) < 0) {
631 fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
632 fstab->recs[attempted_idx].fs_options, strerror(mount_errno));
647 * If multiple fstab entries are to be mounted on "n_name", it will try to mount each one
650 int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device,
659 if (!fstab) {
663 for (i = 0; i < fstab->num_entries; i++) {
664 if (!fs_match(fstab->recs[i].mount_point, n_name)) {
670 if (!strcmp(fstab->recs[i].fs_type, "swap") ||
671 !strcmp(fstab->recs[i].fs_type, "emmc") ||
672 !strcmp(fstab->recs[i].fs_type, "mtd")) {
674 fstab->recs[i].fs_type, n_blk_device);
679 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
683 if (fstab->recs[i].fs_mgr_flags & MF_CHECK) {
684 check_fs(n_blk_device, fstab->recs[i].fs_type,
685 fstab->recs[i].mount_point);
688 if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && device_is_secure()) {
689 int rc = fs_mgr_setup_verity(&fstab->recs[i]);
702 m = fstab->recs[i].mount_point;
704 if (__mount(n_blk_device, m, &fstab->recs[i])) {
723 ERROR("Cannot find mount point %s in fstab\n", fstab->recs[i].mount_point);
749 int fs_mgr_unmount_all(struct fstab *fstab)
754 if (!fstab) {
758 while (fstab->recs[i].blk_device) {
759 if (umount(fstab->recs[i].mount_point)) {
760 ERROR("Cannot unmount filesystem at %s\n", fstab->recs[i].mount_point);
772 int fs_mgr_swapon_all(struct fstab *fstab)
784 if (!fstab) {
788 for (i = 0; i < fstab->num_entries; i++) {
790 if (strcmp(fstab->recs[i].fs_type, "swap")) {
794 if (fstab->recs[i].zram_size > 0) {
808 fprintf(zram_fp, "%d\n", fstab->recs[i].zram_size);
812 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
813 wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
817 mkswap_argv[1] = fstab->recs[i].blk_device;
821 ERROR("mkswap failed for %s\n", fstab->recs[i].blk_device);
826 /* If -1, then no priority was specified in fstab, so don't set
828 if (fstab->recs[i].swap_prio >= 0) {
829 flags = (fstab->recs[i].swap_prio << SWAP_FLAG_PRIO_SHIFT) &
835 err = swapon(fstab->recs[i].blk_device, flags);
837 ERROR("swapon failed for %s\n", fstab->recs[i].blk_device);
850 int fs_mgr_get_crypt_info(struct fstab *fstab, char *key_loc, char *real_blk_device, int size)
854 if (!fstab) {
866 for (i = 0; i < fstab->num_entries; i++) {
868 if (fstab->recs[i].fs_mgr_flags & MF_VOLDMANAGED) {
871 if (!(fstab->recs[i].fs_mgr_flags & (MF_CRYPT | MF_FORCECRYPT))) {
877 strlcpy(key_loc, fstab->recs[i].key_loc, size);
880 strlcpy(real_blk_device, fstab->recs[i].blk_device, size);