/* If tmp_mnt_point is non-null, mount the filesystem there. This is for the * tmp mount we do to check the user password */ int fs_mgr_do_mount(char *fstab_file, char *n_name, char *n_blk_dev, char *tmp_mnt_point) { int i = 0; int ret = -1; struct fstab_rec *fstab = 0; char *m; if (!(fstab = read_fstab(fstab_file))) { return ret; } for (i = 0; fstab[i].blk_dev; i++) { if (!fs_match(fstab[i].mnt_point, n_name)) { continue; } /* We found our match */ /* First check the filesystem if requested */ if (fstab[i].fs_mgr_flags & MF_WAIT) { wait_for_file(fstab[i].blk_dev, WAIT_TIMEOUT); } if ((fstab[i].fs_mgr_flags & MF_CHECK) && strcmp("ext4", fstab[i].type) != 0) { check_fs(fstab[i].blk_dev, fstab[i].type); } /* Now mount it where requested */ if (tmp_mnt_point) { m = tmp_mnt_point; } else { m = fstab[i].mnt_point; } if (mount(n_blk_dev, m, fstab[i].type, fstab[i].flags, fstab[i].fs_options)) { ERROR("Cannot mount filesystem on %s at %s\n", n_blk_dev, m); goto out; } else { ret = 0; goto out; } } /* We didn't find a match, say so and return an error */ ERROR("Cannot find mount point %s in fstab\n", fstab[i].mnt_point); out: free_fstab(fstab); return ret; }
static void free_lu_thread_info_fstab(void *x) { struct lu_thread_info *tdata; if (x == NULL) return; tdata = (struct lu_thread_info *)x; if (tdata->lu_entry != NULL) { free_fstab((struct fstab *)tdata->lu_entry); tdata->lu_entry = NULL; } _lu_data_free_vm_xdr(tdata); free(tdata); }
int fs_mgr_unmount_all(char *fstab_file) { int i = 0; int ret = 0; struct fstab_rec *fstab = 0; if (!(fstab = read_fstab(fstab_file))) { return -1; } while (fstab[i].blk_dev) { if (umount(fstab[i].mnt_point)) { ERROR("Cannot unmount filesystem at %s\n", fstab[i].mnt_point); ret = -1; } i++; } free_fstab(fstab); return ret; }
static struct fstab * extract_fstab(XDR *xdr) { int i, j, nkeys, nvals, status; char *key, **vals; struct fstab *f; if (xdr == NULL) return NULL; if (!xdr_int(xdr, &nkeys)) return NULL; f = (struct fstab *)calloc(1, sizeof(struct fstab)); for (i = 0; i < nkeys; i++) { key = NULL; vals = NULL; nvals = 0; status = _lu_xdr_attribute(xdr, &key, &vals, &nvals); if (status < 0) { free_fstab(f); return NULL; } if (nvals == 0) { free(key); continue; } j = 0; if ((f->fs_spec == NULL) && (!strcmp("name", key))) { f->fs_spec = vals[0]; j = 1; } else if ((f->fs_file == NULL) && (!strcmp("dir", key))) { f->fs_file = vals[0]; j = 1; } else if ((f->fs_vfstype == NULL) && (!strcmp("vfstype", key))) { f->fs_vfstype = vals[0]; j = 1; } else if ((f->fs_mntops == NULL) && (!strcmp("opts", key))) { f->fs_mntops = vals[0]; j = 1; } else if ((f->fs_type == NULL) && (!strcmp("type", key))) { f->fs_type = vals[0]; j = 1; } else if (!strcmp("freq", key)) { f->fs_freq = atoi(vals[0]); } else if (!strcmp("passno", key)) { f->fs_passno = atoi(vals[0]); } free(key); if (vals != NULL) { for (; j < nvals; j++) free(vals[j]); free(vals); } } if (f->fs_spec == NULL) f->fs_spec = strdup(""); if (f->fs_file == NULL) f->fs_file = strdup(""); if (f->fs_vfstype == NULL) f->fs_vfstype = strdup(""); if (f->fs_mntops == NULL) f->fs_mntops = strdup(""); if (f->fs_type == NULL) f->fs_type = strdup(""); return f; }