Home | History | Annotate | Download | only in fs_mgr

Lines Matching refs:fstab

275 struct fstab *fs_mgr_read_fstab(const char *fstab_path)
283 struct fstab *fstab;
317 ERROR("No entries found in fstab\n");
321 /* Allocate and init the fstab structure */
322 fstab = calloc(1, sizeof(struct fstab));
323 fstab->num_entries = entries;
324 fstab->fstab_filename = strdup(fstab_path);
325 fstab->recs = calloc(fstab->num_entries, sizeof(struct fstab_rec));
359 fstab->recs[cnt].blk_device = strdup(p);
365 fstab->recs[cnt].mount_point = strdup(p);
371 fstab->recs[cnt].fs_type = strdup(p);
378 fstab->recs[cnt].flags = parse_flags(p, mount_flags,
384 fstab->recs[cnt].fs_options = strdup(tmp_fs_options);
386 fstab->recs[cnt].fs_options = NULL;
393 fstab->recs[cnt].fs_mgr_flags = parse_flags(p, fs_mgr_flags,
397 fstab->recs[cnt].key_loc = key_loc;
398 fstab->recs[cnt].length = part_length;
399 fstab->recs[cnt].label = label;
400 fstab->recs[cnt].partnum = partnum;
405 return fstab;
408 void fs_mgr_free_fstab(struct fstab *fstab)
412 for (i = 0; i < fstab->num_entries; i++) {
414 free(fstab->recs[i].blk_device);
415 free(fstab->recs[i].mount_point);
416 free(fstab->recs[i].fs_type);
417 free(fstab->recs[i].fs_options);
418 free(fstab->recs[i].key_loc);
419 free(fstab->recs[i].label);
424 free(fstab->recs);
426 /* Free the fstab filename */
427 free(fstab->fstab_filename);
429 /* Free fstab */
430 free(fstab);
510 int fs_mgr_mount_all(struct fstab *fstab)
517 if (!fstab) {
521 for (i = 0; i < fstab->num_entries; i++) {
523 if (fstab->recs[i].fs_mgr_flags & (MF_VOLDMANAGED | MF_RECOVERYONLY)) {
528 if (!strcmp(fstab->recs[i].fs_type, "emmc") ||
529 !strcmp(fstab->recs[i].fs_type, "mtd")) {
533 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
534 wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
537 if (fstab->recs[i].fs_mgr_flags & MF_CHECK) {
538 check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
539 fstab->recs[i].mount_point);
542 mret = mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point,
543 fstab->recs[i].fs_type, fstab->recs[i].flags,
544 fstab->recs[i].fs_options);
551 if ((fstab->recs[i].fs_mgr_flags & MF_CRYPT) &&
552 !partition_wiped(fstab->recs[i].blk_device)) {
556 if (mount("tmpfs", fstab->recs[i].mount_point, "tmpfs",
559 fstab->recs[i].mount_point);
565 fstab->recs[i].blk_device, fstab->recs[i].mount_point);
583 int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device,
590 if (!fstab) {
594 for (i = 0; i < fstab->num_entries; i++) {
595 if (!fs_match(fstab->recs[i].mount_point, n_name)) {
601 if (!strcmp(fstab->recs[i].fs_type, "emmc") ||
602 !strcmp(fstab->recs[i].fs_type, "mtd")) {
604 fstab->recs[i].fs_type, n_blk_device);
609 if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
613 if (fstab->recs[i].fs_mgr_flags & MF_CHECK) {
614 check_fs(n_blk_device, fstab->recs[i].fs_type,
615 fstab->recs[i].mount_point);
622 m = fstab->recs[i].mount_point;
624 if (mount(n_blk_device, m, fstab->recs[i].fs_type,
625 fstab->recs[i].flags, fstab->recs[i].fs_options)) {
636 ERROR("Cannot find mount point %s in fstab\n", fstab->recs[i].mount_point);
661 int fs_mgr_unmount_all(struct fstab *fstab)
666 if (!fstab) {
670 while (fstab->recs[i].blk_device) {
671 if (umount(fstab->recs[i].mount_point)) {
672 ERROR("Cannot unmount filesystem at %s\n", fstab->recs[i].mount_point);
685 int fs_mgr_get_crypt_info(struct fstab *fstab, char *key_loc, char *real_blk_device, int size)
689 if (!fstab) {
701 for (i = 0; i < fstab->num_entries; i++) {
703 if (fstab->recs[i].fs_mgr_flags & MF_VOLDMANAGED) {
706 if (!(fstab->recs[i].fs_mgr_flags & MF_CRYPT)) {
712 strlcpy(key_loc, fstab->recs[i].key_loc, size);
715 strlcpy(real_blk_device, fstab->recs[i].blk_device, size);
723 /* Add an entry to the fstab, and return 0 on success or -1 on error */
724 int fs_mgr_add_entry(struct fstab *fstab,
729 int n = fstab->num_entries;
732 realloc(fstab->recs, sizeof(struct fstab_rec) * (n + 1));
745 /* Update the fstab struct */
746 fstab->recs = new_fstab_recs;
747 fstab->num_entries++;
752 struct fstab_rec *fs_mgr_get_entry_for_mount_point(struct fstab *fstab, const char *path)
756 if (!fstab) {
760 for (i = 0; i < fstab->num_entries; i++) {
761 int len = strlen(fstab->recs[i].mount_point);
762 if (strncmp(path, fstab->recs[i].mount_point, len) == 0 &&
764 return &fstab->recs[i];
771 int fs_mgr_is_voldmanaged(struct fstab_rec *fstab)
773 return fstab->fs_mgr_flags & MF_VOLDMANAGED;
776 int fs_mgr_is_nonremovable(struct fstab_rec *fstab)
778 return fstab->fs_mgr_flags & MF_NONREMOVABLE;
781 int fs_mgr_is_encryptable(struct fstab_rec *fstab)
783 return fstab->fs_mgr_flags & MF_CRYPT;