- /* Check if object with this fid exists */
- child = mdd_object_find(env, mdd, f);
- if (child == NULL)
- GOTO(out, rc = 0);
- if (IS_ERR(child))
- GOTO(out, rc = PTR_ERR(child));
-
- if (mdd_object_exists(child) == 0)
- rc = -ENOENT;
-
- mdd_object_put(env, child);
-
-out:
- return rc;
-}
-
-static int obf_create(const struct lu_env *env, struct md_object *pobj,
- const struct lu_name *lname, struct md_object *child,
- struct md_op_spec *spec, struct md_attr* ma)
-{
- return -EPERM;
-}
-
-static int obf_rename(const struct lu_env *env,
- struct md_object *src_pobj, struct md_object *tgt_pobj,
- const struct lu_fid *lf, const struct lu_name *lsname,
- struct md_object *tobj, const struct lu_name *ltname,
- struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static int obf_link(const struct lu_env *env, struct md_object *tgt_obj,
- struct md_object *src_obj, const struct lu_name *lname,
- struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static int obf_unlink(const struct lu_env *env, struct md_object *pobj,
- struct md_object *cobj, const struct lu_name *lname,
- struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static struct md_dir_operations mdd_obf_dir_ops = {
- .mdo_lookup = obf_lookup,
- .mdo_create = obf_create,
- .mdo_rename = obf_rename,
- .mdo_link = obf_link,
- .mdo_unlink = obf_unlink
-};
-
-/**
- * Create special in-memory "fid" object for open-by-fid.
- */
-static int mdd_obf_setup(const struct lu_env *env, struct mdd_device *m)
-{
- struct mdd_object *mdd_obf;
- struct lu_object *obf_lu_obj;
- int rc = 0;
-
- m->mdd_dot_lustre_objs.mdd_obf = mdd_object_find(env, m,
- &LU_OBF_FID);
- if (m->mdd_dot_lustre_objs.mdd_obf == NULL ||
- IS_ERR(m->mdd_dot_lustre_objs.mdd_obf))
- GOTO(out, rc = -ENOENT);
-
- mdd_obf = m->mdd_dot_lustre_objs.mdd_obf;
- mdd_obf->mod_obj.mo_dir_ops = &mdd_obf_dir_ops;
- mdd_obf->mod_obj.mo_ops = &mdd_obf_obj_ops;
- /* Don't allow objects to be created in "fid" dir */
- mdd_obf->mod_flags |= IMMUTE_OBJ;
-
- obf_lu_obj = mdd2lu_obj(mdd_obf);
- obf_lu_obj->lo_header->loh_attr |= (LOHA_EXISTS | S_IFDIR);
-
-out:
- return rc;
-}
-
-/** Setup ".lustre" directory object */
-static int mdd_dot_lustre_setup(const struct lu_env *env, struct mdd_device *m)
-{
- struct dt_object *dt_dot_lustre;
- struct lu_fid *fid = &mdd_env_info(env)->mti_fid;
- int rc;
- ENTRY;
-
- rc = create_dot_lustre_dir(env, m);
- if (rc)
- return rc;
-
- dt_dot_lustre = dt_store_open(env, m->mdd_child, mdd_root_dir_name,
- dot_lustre_name, fid);
- if (IS_ERR(dt_dot_lustre)) {
- rc = PTR_ERR(dt_dot_lustre);
- GOTO(out, rc);
- }
-
- /* references are released in mdd_device_shutdown() */
- m->mdd_dot_lustre = lu2mdd_obj(lu_object_locate(dt_dot_lustre->do_lu.lo_header,
- &mdd_device_type));
-
- m->mdd_dot_lustre->mod_obj.mo_dir_ops = &mdd_dot_lustre_dir_ops;
- m->mdd_dot_lustre->mod_obj.mo_ops = &mdd_dot_lustre_obj_ops;
-
- rc = mdd_obf_setup(env, m);
- if (rc)
- CERROR("Error initializing \"fid\" object - %d.\n", rc);
-
-out:
- RETURN(rc);