Home | History | Annotate | Download | only in fs_mgr

Lines Matching refs:fstab

339     // The size to reserve is given in the fstab, but we won't reserve more
401 // If the "check" option was given in the fstab record, or it seems that the
405 // the fstab record.
550 * Tries to mount any of the consecutive fstab entries that match
551 * the mountpoint of the one given by fstab->recs[start_idx].
554 * attempted_idx: On return, will indicate which fstab rec
560 static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_idx, int *attempted_idx)
566 if (!end_idx || !attempted_idx || start_idx >= fstab->num_entries) {
573 /* Hunt down an fstab entry for the same mount point that might succeed */
575 /* We required that fstab entries for the same mountpoint be consecutive */
576 i < fstab->num_entries && !strcmp(fstab->recs[start_idx].mount_point, fstab->recs[i].mount_point);
584 LERROR << __FUNCTION__ << "(): skipping fstab dup mountpoint="
585 << fstab->recs[i].mount_point << " rec[" << i
586 << "].fs_type=" << fstab->recs[i].fs_type
588 << fstab->recs[*attempted_idx].fs_type;
592 int fs_stat = prepare_fs_for_mount(fstab->recs[i].blk_device, &fstab->recs[i]);
595 << fstab->recs[i].mount_point << " rec[" << i
596 << "].fs_type=" << fstab->recs[i].fs_type;
603 if (!__mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point,
604 &fstab->recs[i])) {
608 LERROR << __FUNCTION__ << "(): Mounted " << fstab->recs[i].blk_device
609 << " on " << fstab->recs[i].mount_point
610 << " with fs_type=" << fstab->recs[i].fs_type << " instead of "
611 << fstab->recs[start_idx].fs_type;
624 check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
625 fstab->recs[i].mount_point, &fs_stat);
628 log_fs_stat(fstab->recs[i].blk_device, fs_stat);
632 if (i < fstab->num_entries) --i;
794 /* When multiple fstab records share the same mount_point, it will
799 int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
809 if (!fstab) {
813 for (i = 0; i < fstab->num_entries; i++) {
815 if ((fstab->recs[i].fs_mgr_flags & (MF_VOLDMANAGED | MF_RECOVERYONLY)) ||
816 ((mount_mode == MOUNT_MODE_LATE) && !fs_mgr_is_latemount(&fstab->recs[i])) ||
817 ((mount_mode == MOUNT_MODE_EARLY) && fs_mgr_is_latemount(&fstab->recs[i]))) {
822 if (!strcmp(fstab->recs[i].fs_type, "swap") ||
823 !strcmp(fstab->recs[i].fs_type, "emmc") ||
824 !strcmp(fstab->recs[i].fs_type, "mtd")) {
829 if (!strcmp(fstab->recs[i].mount_point, "/")) {
830 if ((fstab->recs[i].fs_mgr_flags & MS_RDONLY) != 0) {
831 fs_mgr_set_blk_ro(fstab->recs[i].blk_device);
837 if (is_extfs(fstab->recs[i].fs_type)) {
838 int tret = translate_ext_labels(&fstab->recs[i]);
845 if (fstab->recs[i].fs_mgr_flags & MF_WAIT &&
846 !fs_mgr_wait_for_file(fstab->recs[i].blk_device, 20s)) {
847 LERROR << "Skipping '" << fstab->recs[i].blk_device << "' during mount_all";
851 if (fstab->recs[i].fs_mgr_flags & MF_AVB) {
853 avb_handle = FsManagerAvbHandle::Open(*fstab);
859 if (avb_handle->SetUpAvbHashtree(&fstab->recs[i], true /* wait_for_verity_dev */) ==
862 << fstab->recs[i].mount_point << ", skipping!";
866 } else if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && is_device_secure()) {
867 int rc = fs_mgr_setup_verity(&fstab->recs[i], true);
881 mret = mount_with_alternatives(fstab, i, &last_idx_inspected, &attempted_idx);
887 int status = handle_encryptable(&fstab->recs[attempted_idx]);
906 bool wiped = partition_wiped(fstab->recs[top_idx].blk_device);
909 fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) {
911 * at two different lines in the fstab. Use the top one for formatting
914 LERROR << __FUNCTION__ << "(): " << fstab->recs[top_idx].blk_device
915 << " is wiped and " << fstab->recs[top_idx].mount_point
916 << " " << fstab->recs[top_idx].fs_type
918 if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
919 strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
920 int fd = open(fstab->recs[top_idx].key_loc, O_WRONLY);
923 << fstab->recs[top_idx].key_loc;
928 << fstab->recs[top_idx].key_loc << " wouldn't open";
930 } else if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
931 !strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
934 if (fs_mgr_do_format(&fstab->recs[top_idx], crypt_footer) == 0) {
948 fs_mgr_is_encryptable(&fstab->recs[attempted_idx])) {
951 << fstab->recs[attempted_idx].blk_device
953 << fstab->recs[attempted_idx].mount_point << " "
954 << fstab->recs[attempted_idx].fs_type
963 << fstab->recs[attempted_idx].blk_device
964 << " for mount " << fstab->recs[attempted_idx].mount_point
965 << " type " << fstab->recs[attempted_idx].fs_type;
966 if (fs_mgr_do_tmpfs_mount(fstab->recs[attempted_idx].mount_point) < 0) {
973 should_use_metadata_encryption(&fstab->recs[attempted_idx])) {
978 if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) {
982 fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
983 fstab->recs[attempted_idx].fs_options);
988 fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
989 fstab->recs[attempted_idx].fs_options);
1023 * If multiple fstab entries are to be mounted on "n_name", it will try to mount each one
1026 int fs_mgr_do_mount(struct fstab *fstab, const char *n_name, char *n_blk_device,
1035 if (!fstab) {
1039 for (i = 0; i < fstab->num_entries; i++) {
1040 if (!fs_match(fstab->recs[i].mount_point, n_name)) {
1046 if (!strcmp(fstab->recs[i].fs_type, "swap") ||
1047 !strcmp(fstab->recs[i].fs_type, "emmc") ||
1048 !strcmp(fstab->recs[i].fs_type, "mtd")) {
1050 << fstab->recs[i].fs_type << " on " << n_blk_device;
1055 if (fstab->recs[i].fs_mgr_flags & MF_WAIT && !fs_mgr_wait_for_file(n_blk_device, 20s)) {
1060 int fs_stat = prepare_fs_for_mount(n_blk_device, &fstab->recs[i]);
1062 if (fstab->recs[i].fs_mgr_flags & MF_AVB) {
1064 avb_handle = FsManagerAvbHandle::Open(*fstab);
1070 if (avb_handle->SetUpAvbHashtree(&fstab->recs[i], true /* wait_for_verity_dev */) ==
1073 << fstab->recs[i].mount_point << ", skipping!";
1077 } else if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && is_device_secure()) {
1078 int rc = fs_mgr_setup_verity(&fstab->recs[i], true);
1093 mount_point = fstab->recs[i].mount_point;
1097 if (!__mount(n_blk_device, mount_point, &fstab->recs[i])) {
1106 check_fs(n_blk_device, fstab->recs[i].fs_type, fstab->recs[i].mount_point, &fs_stat);
1109 log_fs_stat(fstab->recs[i].blk_device, fs_stat);
1118 LERROR << "Cannot find mount point " << n_name << " in fstab";
1142 int fs_mgr_unmount_all(struct fstab *fstab)
1147 if (!fstab) {
1151 while (fstab->recs[i].blk_device) {
1152 if (umount(fstab->recs[i].mount_point)) {
1154 << fstab->recs[i].mount_point;
1166 int fs_mgr_swapon_all(struct fstab *fstab)
1178 if (!fstab) {
1182 for (i = 0; i < fstab->num_entries; i++) {
1184 if (strcmp(fstab->recs[i].fs_type, "swap")) {
1188 if (fstab->recs[i].zram_size > 0) {
1197 if (fstab->recs[i].max_comp_streams >= 0) {
1205 fprintf(zram_mcs_fp, "%d\n", fstab->recs[i].max_comp_streams);
1215 fprintf(zram_fp, "%u\n", fstab->recs[i].zram_size);
1219 if (fstab->recs[i].fs_mgr_flags & MF_WAIT &&
1220 !fs_mgr_wait_for_file(fstab->recs[i].blk_device, 20s)) {
1221 LERROR << "Skipping mkswap for '" << fstab->recs[i].blk_device << "'";
1227 mkswap_argv[1] = fstab->recs[i].blk_device;
1233 LERROR << "mkswap failed for " << fstab->recs[i].blk_device;
1238 /* If -1, then no priority was specified in fstab, so don't set
1240 if (fstab->recs[i].swap_prio >= 0) {
1241 flags = (fstab->recs[i].swap_prio << SWAP_FLAG_PRIO_SHIFT) &
1247 err = swapon(fstab->recs[i].blk_device, flags);
1249 LERROR << "swapon failed for " << fstab->recs[i].blk_device;
1257 struct fstab_rec const* fs_mgr_get_crypt_entry(struct fstab const* fstab) {
1260 if (!fstab) {
1265 for (i = 0; i < fstab->num_entries; i++) {
1267 if (!(fstab->recs[i].fs_mgr_flags & MF_VOLDMANAGED) &&
1268 (fstab->recs[i].fs_mgr_flags &
1270 return &fstab->recs[i];
1281 void fs_mgr_get_crypt_info(struct fstab* fstab, char* key_loc, char* real_blk_device, size_t size) {
1282 struct fstab_rec const* rec = fs_mgr_get_crypt_entry(fstab);
1304 std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
1306 if (!fstab) {
1307 LERROR << "Failed to read default fstab";
1311 for (int i = 0; i < fstab->num_entries; i++) {
1312 if (fs_mgr_is_avb(&fstab->recs[i])) {
1315 } else if (!fs_mgr_is_verified(&fstab->recs[i])) {
1320 if (load_verity_state(&fstab->recs[i], &current) < 0) {
1348 std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
1350 if (!fstab) {
1351 LERROR << "Failed to read default fstab";
1359 for (int i = 0; i < fstab->num_entries; i++) {
1360 if (!fs_mgr_is_verified(&fstab->recs[i]) && !fs_mgr_is_avb(&fstab->recs[i])) {
1365 if (system_root && !strcmp(fstab->recs[i].mount_point, "/")) {
1367 mount_point = fs_mgr_is_avb(&fstab
1369 mount_point = basename(fstab->recs[i].mount_point);
1376 if (fstab->recs[i].fs_mgr_flags & MF_VERIFYATBOOT) {
1391 callback(&fstab->recs[i], mount_point.c_str(), mode, *status);