Lines Matching refs:fstab

520  * Tries to mount any of the consecutive fstab entries that match
521 * the mountpoint of the one given by fstab->recs[start_idx].
524 * attempted_idx: On return, will indicate which fstab rec
530 static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_idx, int *attempted_idx)
536 if (!end_idx || !attempted_idx || start_idx >= fstab->num_entries) {
543 /* Hunt down an fstab entry for the same mount point that might succeed */
545 /* We required that fstab entries for the same mountpoint be consecutive */
546 i < fstab->num_entries && !strcmp(fstab->recs[start_idx].mount_point, fstab->recs[i].mount_point);
554 LERROR << __FUNCTION__ << "(): skipping fstab dup mountpoint="
555 << fstab->recs[i].mount_point << " rec[" << i
556 << "].fs_type=" << fstab->recs[i].fs_type
558 << fstab->recs[*attempted_idx].fs_type;
563 int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device,
564 fstab->recs[i].fs_type,
565 &fstab->recs[i], &fs_stat);
568 << fstab->recs[i].mount_point << " rec[" << i
569 << "].fs_type=" << fstab->recs[i].fs_type;
573 if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) {
574 check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
575 fstab->recs[i].mount_point, &fs_stat);
578 if (fstab->recs[i].fs_mgr_flags & MF_RESERVEDSIZE) {
579 do_reserved_size(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
580 &fstab->recs[i], &fs_stat);
585 if (!__mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point,
586 &fstab->recs[i])) {
590 LERROR << __FUNCTION__ << "(): Mounted " << fstab->recs[i].blk_device
591 << " on " << fstab->recs[i].mount_point
592 << " with fs_type=" << fstab->recs[i].fs_type << " instead of "
593 << fstab->recs[start_idx].fs_type;
606 check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
607 fstab->recs[i].mount_point, &fs_stat);
610 log_fs_stat(fstab->recs[i].blk_device, fs_stat);
614 if (i < fstab->num_entries) --i;
777 /* When multiple fstab records share the same mount_point, it will
782 int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
792 if (!fstab) {
796 for (i = 0; i < fstab->num_entries; i++) {
798 if ((fstab->recs[i].fs_mgr_flags & (MF_VOLDMANAGED | MF_RECOVERYONLY)) ||
799 ((mount_mode == MOUNT_MODE_LATE) && !fs_mgr_is_latemount(&fstab->recs[i])) ||
800 ((mount_mode == MOUNT_MODE_EARLY) && fs_mgr_is_latemount(&fstab->recs[i]))) {
805 if (!strcmp(fstab->recs[i].fs_type, "swap") ||
806 !strcmp(fstab->recs[i].fs_type, "emmc") ||
807 !strcmp(fstab->recs[i].fs_type, "mtd")) {
812 if (!strcmp(fstab->recs[i].mount_point, "/")) {
813 if ((fstab->recs[i].fs_mgr_flags & MS_RDONLY) != 0) {
814 fs_mgr_set_blk_ro(fstab->recs[i].blk_device);
820 if (!strcmp(fstab->recs[i].fs_type, "ext2") ||
821 !strcmp(fstab->recs[i].fs_type, "ext3") ||
822 !strcmp(fstab->recs[i].fs_type, "ext4")) {
823 int tret = translate_ext_labels(&fstab->recs[i]);
830 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
831 wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
834 if (fstab->recs[i].fs_mgr_flags & MF_AVB) {
836 avb_handle = FsManagerAvbHandle::Open(*fstab);
842 if (!avb_handle->SetUpAvb(&fstab->recs[i], true /* wait_for_verity_dev */)) {
844 << fstab->recs[i].mount_point << ", skipping!";
848 } else if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && is_device_secure()) {
849 int rc = fs_mgr_setup_verity(&fstab->recs[i], true);
861 mret = mount_with_alternatives(fstab, i, &last_idx_inspected, &attempted_idx);
867 int status = handle_encryptable(&fstab->recs[attempted_idx]);
887 bool wiped = partition_wiped(fstab->recs[top_idx].blk_device);
890 fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) {
892 * at two different lines in the fstab. Use the top one for formatting
895 LERROR << __FUNCTION__ << "(): " << fstab->recs[top_idx].blk_device
896 << " is wiped and " << fstab->recs[top_idx].mount_point
897 << " " << fstab->recs[top_idx].fs_type
899 if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
900 strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
901 int fd = open(fstab->recs[top_idx].key_loc, O_WRONLY);
904 << fstab->recs[top_idx].key_loc;
909 << fstab->recs[top_idx].key_loc << " wouldn't open";
911 } else if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
912 !strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
915 if (fs_mgr_do_format(&fstab->recs[top_idx], crypt_footer) == 0) {
927 fs_mgr_is_encryptable(&fstab->recs[attempted_idx])) {
930 << fstab->recs[attempted_idx].blk_device
932 << fstab->recs[attempted_idx].mount_point << " "
933 << fstab->recs[attempted_idx].fs_type
942 << fstab->recs[attempted_idx].blk_device
943 << " for mount " << fstab->recs[attempted_idx].mount_point
944 << " type " << fstab->recs[attempted_idx].fs_type;
945 if (fs_mgr_do_tmpfs_mount(fstab->recs[attempted_idx].mount_point) < 0) {
954 if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) {
958 fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
959 fstab->recs[attempted_idx].fs_options);
964 fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
965 fstab->recs[attempted_idx].fs_options);
999 * If multiple fstab entries are to be mounted on "n_name", it will try to mount each one
1002 int fs_mgr_do_mount(struct fstab *fstab, const char *n_name, char *n_blk_device,
1012 if (!fstab) {
1016 for (i = 0; i < fstab->num_entries; i++) {
1017 if (!fs_match(fstab->recs[i].mount_point, n_name)) {
1023 if (!strcmp(fstab->recs[i].fs_type, "swap") ||
1024 !strcmp(fstab->recs[i].fs_type, "emmc") ||
1025 !strcmp(fstab->recs[i].fs_type, "mtd")) {
1027 << fstab->recs[i].fs_type << " on " << n_blk_device;
1032 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
1037 int force_check = do_quota_with_shutdown_check(n_blk_device, fstab->recs[i].fs_type,
1038 &fstab->recs[i], &fs_stat);
1040 if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) {
1041 check_fs(n_blk_device, fstab->recs[i].fs_type,
1042 fstab->recs[i].mount_point, &fs_stat);
1045 if (fstab->recs[i].fs_mgr_flags & MF_RESERVEDSIZE) {
1046 do_reserved_size(n_blk_device, fstab->recs[i].fs_type, &fstab->recs[i], &fs_stat);
1049 if (fstab->recs[i].fs_mgr_flags & MF_AVB) {
1051 avb_handle = FsManagerAvbHandle::Open(*fstab);
1057 if (!avb_handle->SetUpAvb(&fstab->recs[i], true /* wait_for_verity_dev */)) {
1059 << fstab->recs[i].mount_point << ", skipping!";
1063 } else if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && is_device_secure()) {
1064 int rc = fs_mgr_setup_verity(&fstab->recs[i], true);
1077 m = fstab->recs[i].mount_point;
1081 if (!__mount(n_blk_device, m, &fstab->recs[i])) {
1091 check_fs(n_blk_device, fstab->recs[i].fs_type, fstab->recs[i].mount_point, &fs_stat);
1094 log_fs_stat(fstab->recs[i].blk_device, fs_stat);
1106 LERROR << "Cannot find mount point " << fstab->recs[i].mount_point
1107 << " in fstab";
1133 int fs_mgr_unmount_all(struct fstab *fstab)
1138 if (!fstab) {
1142 while (fstab->recs[i].blk_device) {
1143 if (umount(fstab->recs[i].mount_point)) {
1145 << fstab->recs[i].mount_point;
1157 int fs_mgr_swapon_all(struct fstab *fstab)
1169 if (!fstab) {
1173 for (i = 0; i < fstab->num_entries; i++) {
1175 if (strcmp(fstab->recs[i].fs_type, "swap")) {
1179 if (fstab->recs[i].zram_size > 0) {
1188 if (fstab->recs[i].max_comp_streams >= 0) {
1196 fprintf(zram_mcs_fp, "%d\n", fstab->recs[i].max_comp_streams);
1206 fprintf(zram_fp, "%d\n", fstab->recs[i].zram_size);
1210 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
1211 wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
1215 mkswap_argv[1] = fstab->recs[i].blk_device;
1221 LERROR << "mkswap failed for " << fstab->recs[i].blk_device;
1226 /* If -1, then no priority was specified in fstab, so don't set
1228 if (fstab->recs[i].swap_prio >= 0) {
1229 flags = (fstab->recs[i].swap_prio << SWAP_FLAG_PRIO_SHIFT) &
1235 err = swapon(fstab->recs[i].blk_device, flags);
1237 LERROR << "swapon failed for " << fstab->recs[i].blk_device;
1250 int fs_mgr_get_crypt_info(struct fstab *fstab, char *key_loc, char *real_blk_device, int size)
1254 if (!fstab) {
1266 for (i = 0; i < fstab->num_entries; i++) {
1268 if (fstab->recs[i].fs_mgr_flags & MF_VOLDMANAGED) {
1271 if (!(fstab->recs[i].fs_mgr_flags
1278 strlcpy(key_loc, fstab->recs[i].key_loc, size);
1281 strlcpy(real_blk_device, fstab->recs[i].blk_device, size);
1294 std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
1296 if (!fstab) {
1297 LERROR << "Failed to read default fstab";
1301 for (int i = 0; i < fstab->num_entries; i++) {
1302 if (fs_mgr_is_avb(&fstab->recs[i])) {
1305 } else if (!fs_mgr_is_verified(&fstab->recs[i])) {
1310 if (load_verity_state(&fstab->recs[i], &current) < 0) {
1338 std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
1340 if (!fstab) {
1341 LERROR << "Failed to read default fstab";
1349 for (int i = 0; i < fstab->num_entries; i++) {
1350 if (!fs_mgr_is_verified(&fstab->recs[i]) && !fs_mgr_is_avb(&fstab->recs[i])) {
1355 if (system_root && !strcmp(fstab->recs[i].mount_point, "/")) {
1357 mount_point = fs_mgr_is_avb(&fstab->recs[i]) ? "vroot" : "system";
1359 mount_point = basename(fstab->recs[i].mount_point);
1366 if (fstab->recs[i].fs_mgr_flags & MF_VERIFYATBOOT) {
1381 callback(&fstab->recs[i], mount_point.c_str(), mode, *status);