static int confobd_setup(struct obd_device *obd, obd_count len, void *buf)
{
struct conf_obd *confobd = &obd->u.conf;
- struct lustre_cfg* lcfg = buf;
struct lvfs_obd_ctxt *lvfs_ctxt = NULL;
- char *name = NULL;
+ struct lustre_cfg* lcfg = buf;
+ char *mountoptions = NULL;
+ unsigned long page = 0;
char *fstype = NULL;
- char *mountoption = NULL;
+ char *name = NULL;
int rc = 0;
ENTRY;
- if (lcfg->lcfg_inllen1 < 1 || !lcfg->lcfg_inlbuf1) {
+ if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1 ||
+ lustre_cfg_buf(lcfg, 1) == NULL) {
CERROR("CONFOBD setup requires device name\n");
RETURN(-EINVAL);
}
- if (lcfg->lcfg_inllen2 < 1 || !lcfg->lcfg_inlbuf2) {
+ if (LUSTRE_CFG_BUFLEN(lcfg, 2) < 1 ||
+ lustre_cfg_buf(lcfg, 2) == NULL) {
CERROR("CONFOBD setup requires fstype\n");
RETURN(-EINVAL);
}
- OBD_ALLOC(name, lcfg->lcfg_inllen1 + 1);
+ OBD_ALLOC(name, LUSTRE_CFG_BUFLEN(lcfg, 1));
if (!name) {
- CERROR("No Memory\n");
+ CERROR("No memory\n");
GOTO(out, rc = -ENOMEM);
}
- memcpy(name, lcfg->lcfg_inlbuf1, lcfg->lcfg_inllen1);
+ memcpy(name, lustre_cfg_string(lcfg, 1), LUSTRE_CFG_BUFLEN(lcfg, 1));
- OBD_ALLOC(fstype, lcfg->lcfg_inllen2 + 1);
+ OBD_ALLOC(fstype, LUSTRE_CFG_BUFLEN(lcfg, 2));
if (!fstype) {
- CERROR("No Memory\n");
+ CERROR("No memory\n");
GOTO(out, rc = -ENOMEM);
}
- memcpy(fstype, lcfg->lcfg_inlbuf2, lcfg->lcfg_inllen2);
+ memcpy(fstype, lustre_cfg_string(lcfg, 2),
+ LUSTRE_CFG_BUFLEN(lcfg, 2));
obd->obd_fsops = fsfilt_get_ops(fstype);
if (IS_ERR(obd->obd_fsops)) {
GOTO(err_ops, rc = PTR_ERR(obd->obd_fsops));
}
- if (lcfg->lcfg_inllen3 >= 1 && lcfg->lcfg_inlbuf3) {
- OBD_ALLOC(mountoption, lcfg->lcfg_inllen3 + 1);
- if (!mountoption) {
- CERROR("No Memory\n");
+ if (LUSTRE_CFG_BUFLEN(lcfg, 3) >= 1 && lustre_cfg_buf(lcfg, 3)) {
+ /* 2.6.9 selinux wants a full option page for do_kern_mount
+ * (bug6471) */
+ page = get_zeroed_page(GFP_KERNEL);
+ if (!page) {
+ CERROR("No memory\n");
GOTO(err_ops, rc = -ENOMEM);
}
- memcpy(mountoption, lcfg->lcfg_inlbuf3, lcfg->lcfg_inllen3);
+ mountoptions = (char *)page;
+
+ memcpy(mountoptions, lustre_cfg_string(lcfg, 3),
+ LUSTRE_CFG_BUFLEN(lcfg, 3));
}
- rc = lvfs_mount_fs(name, fstype, mountoption, 0, &lvfs_ctxt);
+
+ rc = lvfs_mount_fs(name, fstype, mountoptions, 0, &lvfs_ctxt);
+
+ if (page) {
+ free_page(page);
+ page = 0;
+ }
+
if (rc)
GOTO(err_ops, rc);
- LASSERT(lvfs_ctxt);
+ LASSERT(lvfs_ctxt);
confobd->cfobd_lvfs_ctxt = lvfs_ctxt;
rc = confobd_fs_setup(obd, lvfs_ctxt);
if (rc && lvfs_ctxt)
lvfs_umount_fs(lvfs_ctxt);
if (name)
- OBD_FREE(name, lcfg->lcfg_inllen1 + 1);
+ OBD_FREE(name, LUSTRE_CFG_BUFLEN(lcfg, 1));
if (fstype)
- OBD_FREE(fstype, lcfg->lcfg_inllen2 + 1);
- if (mountoption)
- OBD_FREE(mountoption, lcfg->lcfg_inllen3 + 1);
+ OBD_FREE(fstype, LUSTRE_CFG_BUFLEN(lcfg, 2));
return rc;
err_ops: