Home | History | Annotate | Download | only in fs_mgr

Lines Matching refs:fstab

402     std::string file_name = get_android_dt_dir() + "/fstab/compatible";
404 if (dt_value == "android,fstab") {
417 std::string fstabdir_name = get_android_dt_dir() + "/fstab";
422 // Each element in fstab_dt_entries is <mount point, the line format in fstab file>.
506 static struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file)
514 struct fstab *fstab = NULL;
537 LERROR << "No entries found in fstab";
541 /* Allocate and init the fstab structure */
542 fstab = static_cast<struct fstab *>(calloc(1, sizeof(struct fstab)));
543 fstab->num_entries = entries;
544 fstab->recs = static_cast<struct fstab_rec *>(
545 calloc(fstab->num_entries, sizeof(struct fstab_rec)));
578 fstab->recs[cnt].blk_device = strdup(p);
584 fstab->recs[cnt].mount_point = strdup(p);
590 fstab->recs[cnt].fs_type = strdup(p);
597 fstab->recs[cnt].flags = parse_flags(p, mount_flags, NULL,
602 fstab->recs[cnt].fs_options = strdup(tmp_fs_options);
604 fstab->recs[cnt].fs_options = NULL;
611 fstab->recs[cnt].fs_mgr_flags = parse_flags(p, fs_mgr_flags,
613 fstab->recs[cnt].key_loc = flag_vals.key_loc;
614 fstab->recs[cnt].key_dir = flag_vals.key_dir;
615 fstab->recs[cnt].verity_loc = flag_vals.verity_loc;
616 fstab->recs[cnt].length = flag_vals.part_length;
617 fstab->recs[cnt].label = flag_vals.label;
618 fstab->recs[cnt].partnum = flag_vals.partnum;
619 fstab->recs[cnt].swap_prio = flag_vals.swap_prio;
620 fstab->recs[cnt].max_comp_streams = flag_vals.max_comp_streams;
621 fstab->recs[cnt].zram_size = flag_vals.zram_size;
622 fstab->recs[cnt].reserved_size = flag_vals.reserved_size;
623 fstab->recs[cnt].file_contents_mode = flag_vals.file_contents_mode;
624 fstab->recs[cnt].file_names_mode = flag_vals.file_names_mode;
625 fstab->recs[cnt].erase_blk_size = flag_vals.erase_blk_size;
626 fstab->recs[cnt].logical_blk_size = flag_vals.logical_blk_size;
627 fstab->recs[cnt].sysfs_path = flag_vals.sysfs_path;
631 if (!fs_mgr_update_for_slotselect(fstab)) {
636 return fstab;
640 if (fstab)
641 fs_mgr_free_fstab(fstab);
645 /* merges fstab entries from both a and b, then returns the merged result.
649 static struct fstab *in_place_merge(struct fstab *a, struct fstab *b)
659 LERROR << __FUNCTION__ << "(): failed to allocate fstab recs";
682 /* Extracts <device>s from the by-name symlinks specified in a fstab:
687 * For example, given the following entries in the input fstab:
692 static std::set<std::string> extract_boot_devices(const fstab& fstab) {
695 for (int i = 0; i < fstab.num_entries; i++) {
696 std::string blk_device(fstab.recs[i].blk_device);
725 struct fstab *fs_mgr_read_fstab(const char *fstab_path)
728 struct fstab *fstab;
736 fstab = fs_mgr_read_fstab_file(fstab_file);
737 if (fstab) {
738 fstab->fstab_filename = strdup(fstab_path);
740 LERROR << __FUNCTION__ << "(): failed to load fstab from : '" << fstab_path << "'";
744 return fstab;
747 /* Returns fstab entries parsed from the device tree if they
750 struct fstab *fs_mgr_read_fstab_dt()
754 LINFO << __FUNCTION__ << "(): failed to read fstab from dt";
762 PERROR << __FUNCTION__ << "(): failed to create a file stream for fstab dt";
766 struct fstab *fstab = fs_mgr_read_fstab_file(fstab_file.get());
767 if (!fstab) {
768 LERROR << __FUNCTION__ << "(): failed to load fstab from kernel:"
772 return fstab;
776 * Identify path to fstab file. Lookup is based on pattern
777 * fstab.<hardware>, fstab.<hardware.platform> in folders
787 for (const char* prefix : {"/odm/etc/fstab.", "/vendor/etc/fstab.", "/fstab."}) {
799 * loads the fstab file and combines with fstab entries passed in from device tree.
801 struct fstab *fs_mgr_read_fstab_default()
805 // Use different fstab paths for normal boot and recovery boot, respectively
807 default_fstab = "/etc/recovery.fstab";
812 struct fstab* fstab = nullptr;
814 fstab = fs_mgr_read_fstab(default_fstab.c_str());
816 LINFO << __FUNCTION__ << "(): failed to find device default fstab";
819 struct fstab* fstab_dt = fs_mgr_read_fstab_dt();
821 // combines fstab entries passed in from device tree with
823 return in_place_merge(fstab_dt, fstab);
826 void fs_mgr_free_fstab(struct fstab *fstab)
830 if (!fstab) {
834 for (i = 0; i < fstab->num_entries; i++) {
836 free(fstab->recs[i].blk_device);
837 free(fstab->recs[i].mount_point);
838 free(fstab->recs[i].fs_type);
839 free(fstab->recs[i].fs_options);
840 free(fstab->recs[i].key_loc);
841 free(fstab->recs[i].key_dir);
842 free(fstab->recs[i].label);
843 free(fstab->recs[i].sysfs_path);
847 free(fstab->recs);
849 /* Free the fstab filename */
850 free(fstab->fstab_filename);
852 /* Free fstab */
853 free(fstab);
856 /* Add an entry to the fstab, and return 0 on success or -1 on error */
857 int fs_mgr_add_entry(struct fstab *fstab,
862 int n = fstab->num_entries;
865 realloc(fstab->recs, sizeof(struct fstab_rec) * (n + 1));
878 /* Update the fstab struct */
879 fstab->recs = new_fstab_recs;
880 fstab->num_entries++;
889 struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path) {
890 if (!fstab) {
893 for (int i = 0; i < fstab->num_entries; i++) {
894 if (fstab->recs[i].mount_point && path == fstab->recs[i].mount_point) {
895 return &fstab->recs[i];
910 // Fallback to extract boot devices from fstab.
911 std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
913 if (fstab) return extract_boot_devices(*fstab);
918 int fs_mgr_is_voldmanaged(const struct fstab_rec *fstab)
920 return fstab->fs_mgr_flags & MF_VOLDMANAGED;
923 int fs_mgr_is_nonremovable(const struct fstab_rec *fstab)
925 return fstab->fs_mgr_flags & MF_NONREMOVABLE;
928 int fs_mgr_is_verified(const struct fstab_rec *fstab)
930 return fstab->fs_mgr_flags & MF_VERIFY;
933 fstab)
935 return fstab->fs_mgr_flags & MF_AVB;
938 int fs_mgr_is_verifyatboot(const struct fstab_rec *fstab)
940 return fstab->fs_mgr_flags & MF_VERIFYATBOOT;
943 int fs_mgr_is_encryptable(const struct fstab_rec *fstab)
945 return fstab->fs_mgr_flags & (MF_CRYPT | MF_FORCECRYPT | MF_FORCEFDEORFBE);
948 int fs_mgr_is_file_encrypted(const struct fstab_rec *fstab)
950 return fstab->fs_mgr_flags & MF_FILEENCRYPTION;
953 void fs_mgr_get_file_encryption_modes(const struct fstab_rec *fstab,
958 fstab->file_contents_mode);
960 fstab->file_names_mode);
963 int fs_mgr_is_convertible_to_fbe(const struct fstab_rec *fstab)
965 return fstab->fs_mgr_flags & MF_FORCEFDEORFBE;
968 int fs_mgr_is_noemulatedsd(const struct fstab_rec *fstab)
970 return fstab->fs_mgr_flags & MF_NOEMULATEDSD;
973 int fs_mgr_is_notrim(const struct fstab_rec* fstab) {
974 return fstab->fs_mgr_flags & MF_NOTRIM;
977 int fs_mgr_is_formattable(const struct fstab_rec* fstab) {
978 return fstab->fs_mgr_flags & (MF_FORMATTABLE);
981 int fs_mgr_is_slotselect(const struct fstab_rec* fstab) {
982 return fstab->fs_mgr_flags & MF_SLOTSELECT;
985 int fs_mgr_is_nofail(const struct fstab_rec* fstab) {
986 return fstab->fs_mgr_flags & MF_NOFAIL;
989 int fs_mgr_is_latemount(const struct fstab_rec* fstab) {
990 return fstab->fs_mgr_flags & MF_LATEMOUNT;
993 int fs_mgr_is_quota(const struct fstab_rec* fstab) {
994 return fstab->fs_mgr_flags & MF_QUOTA;
997 int fs_mgr_has_sysfs_path(const struct fstab_rec *fstab)
999 return fstab->fs_mgr_flags & MF_SYSFS;