struct md_op_spec *spc,
struct md_attr *at)
{
- LASSERT(c->mo_dir_ops->mdo_create);
- return c->mo_dir_ops->mdo_create(env, p, lchild_name, c, spc, at);
+ LASSERT(p->mo_dir_ops->mdo_create);
+ return p->mo_dir_ops->mdo_create(env, p, lchild_name, c, spc, at);
}
static inline int mdo_create_data(const struct lu_env *env,
return 0;
}
-static int dot_lustre_mdd_attr_get(const struct lu_env *env,
- struct md_object *obj, struct md_attr *ma)
-{
- struct mdd_object *mdd_obj = md2mdd_obj(obj);
-
- return mdd_attr_get_internal_locked(env, mdd_obj, ma);
-}
-
-static int dot_lustre_mdd_attr_set(const struct lu_env *env,
- struct md_object *obj,
- const struct md_attr *ma)
-{
- return -EPERM;
-}
-
static int dot_lustre_mdd_xattr_get(const struct lu_env *env,
struct md_object *obj, struct lu_buf *buf,
const char *name)
static struct md_object_operations mdd_dot_lustre_obj_ops = {
.moo_permission = dot_lustre_mdd_permission,
- .moo_attr_get = dot_lustre_mdd_attr_get,
- .moo_attr_set = dot_lustre_mdd_attr_set,
+ .moo_attr_get = mdd_attr_get,
+ .moo_attr_set = mdd_attr_set,
.moo_xattr_get = dot_lustre_mdd_xattr_get,
.moo_xattr_list = dot_lustre_mdd_xattr_list,
.moo_xattr_set = dot_lustre_mdd_xattr_set,
/* "fid" is a virtual object and hence does not have any "real"
* attributes. So we reuse attributes of .lustre for "fid" dir */
ma->ma_need |= MA_INODE;
- rc = dot_lustre_mdd_attr_get(env, &mdd->mdd_dot_lustre->mod_obj,
- ma);
+ rc = mdd_attr_get(env, &mdd->mdd_dot_lustre->mod_obj, ma);
if (rc)
return rc;
ma->ma_valid |= MA_INODE;
return -EPERM;
}
+static int obf_xattr_list(const struct lu_env *env,
+ struct md_object *obj, struct lu_buf *buf)
+{
+ return 0;
+}
+
static int obf_xattr_get(const struct lu_env *env,
struct md_object *obj, struct lu_buf *buf,
const char *name)
return 0;
}
+static int obf_xattr_set(const struct lu_env *env,
+ struct md_object *obj,
+ const struct lu_buf *buf, const char *name,
+ int fl)
+{
+ return -EPERM;
+}
+
+static int obf_xattr_del(const struct lu_env *env,
+ struct md_object *obj,
+ const char *name)
+{
+ return -EPERM;
+}
+
static int obf_mdd_open(const struct lu_env *env, struct md_object *obj,
int flags)
{
}
static struct md_object_operations mdd_obf_obj_ops = {
- .moo_attr_get = obf_attr_get,
- .moo_attr_set = obf_attr_set,
- .moo_xattr_get = obf_xattr_get,
- .moo_open = obf_mdd_open,
- .moo_close = obf_mdd_close,
- .moo_readpage = obf_mdd_readpage,
- .moo_path = obf_path
+ .moo_attr_get = obf_attr_get,
+ .moo_attr_set = obf_attr_set,
+ .moo_xattr_list = obf_xattr_list,
+ .moo_xattr_get = obf_xattr_get,
+ .moo_xattr_set = obf_xattr_set,
+ .moo_xattr_del = obf_xattr_del,
+ .moo_open = obf_mdd_open,
+ .moo_close = obf_mdd_close,
+ .moo_readpage = obf_mdd_readpage,
+ .moo_path = obf_path
};
/**
sscanf(name, SFID, RFID(f));
if (!fid_is_sane(f)) {
- CWARN("bad FID format [%s], should be "DFID"\n", lname->ln_name,
- (__u64)1, 2, 0);
+ CWARN("%s: bad FID format [%s], should be "DFID"\n",
+ mdd->mdd_obd_dev->obd_name, lname->ln_name,
+ (__u64)FID_SEQ_NORMAL, 1, 0);
GOTO(out, rc = -EINVAL);
}
+ if (!fid_is_norm(f)) {
+ CWARN("%s: "DFID" is invalid, sequence should be "
+ ">= "LPX64"\n", mdd->mdd_obd_dev->obd_name, PFID(f),
+ (__u64)FID_SEQ_NORMAL);
+ GOTO(out, rc = -EINVAL);
+ }
+
/* Check if object with this fid exists */
child = mdd_object_find(env, mdd, f);
if (child == NULL)
int mdd_data_get(const struct lu_env *env, struct mdd_object *obj, void **data);
int mdd_la_get(const struct lu_env *env, struct mdd_object *obj,
struct lu_attr *la, struct lustre_capa *capa);
+int mdd_attr_get(const struct lu_env *env, struct md_object *obj,
+ struct md_attr *ma);
+int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
+ const struct md_attr *ma);
int mdd_attr_set_internal(const struct lu_env *env,
struct mdd_object *obj,
struct lu_attr *attr,
/*
* No permission check is needed.
*/
-static int mdd_attr_get(const struct lu_env *env, struct md_object *obj,
- struct md_attr *ma)
+int mdd_attr_get(const struct lu_env *env, struct md_object *obj,
+ struct md_attr *ma)
{
struct mdd_object *mdd_obj = md2mdd_obj(obj);
int rc;
}
/* set attr and LOV EA at once, return updated attr */
-static int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
- const struct md_attr *ma)
+int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
+ const struct md_attr *ma)
{
struct mdd_object *mdd_obj = md2mdd_obj(obj);
struct mdd_device *mdd = mdo2mdd(obj);
{
LASSERT(o);
LASSERT(mdt_object_exists(o) >= 0);
- if (mdt_object_exists(o) > 0)
+ if (mdt_object_exists(o) > 0 && !mdt_object_obf(o))
*version = dt_version_get(info->mti_env, mdt_obj2dt(o));
else
*version = ENOENT_VERSION;
if (IS_ERR(mo))
GOTO(out, rc = PTR_ERR(mo));
+ if (mdt_object_obf(mo))
+ GOTO(out_put, rc = -EPERM);
+
/* start a log jounal handle if needed */
if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM)) {
if ((ma->ma_attr.la_valid & LA_SIZE) ||
if (IS_ERR(mold))
GOTO(out_unlock_target, rc = PTR_ERR(mold));
+ if (mdt_object_obf(mold)) {
+ mdt_object_put(info->mti_env, mold);
+ GOTO(out_unlock_target, rc = -EPERM);
+ }
+
lh_oldp = &info->mti_lh[MDT_LH_OLD];
mdt_lock_reg_init(lh_oldp, LCK_EX);
rc = mdt_object_lock(info, mold, lh_oldp, MDS_INODELOCK_LOOKUP,
if (IS_ERR(mnew))
GOTO(out_unlock_old, rc = PTR_ERR(mnew));
+ if (mdt_object_obf(mnew)) {
+ mdt_object_put(info->mti_env, mnew);
+ GOTO(out_unlock_old, rc = -EPERM);
+ }
+
rc = mdt_object_lock(info, mnew, lh_newp,
MDS_INODELOCK_FULL, MDT_CROSS_LOCK);
if (rc != 0) {
touch $DIR/.lustre/fid/$tfile && \
error "touch $DIR/.lustre/fid/$tfile should fail."
+ echo "setxattr to $DIR/.lustre/fid"
+ setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
+ error "setxattr should fail."
+
+ echo "listxattr for $DIR/.lustre/fid"
+ getfattr -d -m "^trusted" $DIR/.lustre/fid &&
+ error "listxattr should fail."
+
+ echo "delxattr from $DIR/.lustre/fid"
+ setfattr -x trusted.name1 $DIR/.lustre/fid &&
+ error "delxattr should fail."
+
+ echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
+ touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
+ error "touch invalid fid should fail."
+
+ echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
+ touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
+ error "touch non-normal fid should fail."
+
+ echo "rename $tdir to $DIR/.lustre/fid"
+ mrename $DIR/$tdir $DIR/.lustre/fid &&
+ error "rename to $DIR/.lustre/fid should fail."
+
+ echo "rename .lustre to itself"
+ fid=$($LFS path2fid $DIR)
+ mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
+ error "rename .lustre to itself should fail."
+
echo "Open-by-FID succeeded"
}
run_test 154 "Open-by-FID"