LASSERT(!info->mti_cross_ref);
/* Only got the fid of this obj by name */
+ fid_zero(child_fid);
rc = mdo_lookup(info->mti_env, next, lname, child_fid,
&info->mti_spec);
#if 0
}
/* step 2: lookup child's fid by name */
+ fid_zero(child_fid);
rc = mdo_lookup(info->mti_env, next, lname, child_fid,
&info->mti_spec);
return lu_object_exists(&o->mot_obj.mo_lu);
}
-static inline const struct lu_fid *mdt_object_fid(struct mdt_object *o)
+static inline const struct lu_fid *mdt_object_fid(const struct mdt_object *o)
{
return lu_object_fid(&o->mot_obj.mo_lu);
}
+static inline int mdt_object_obf(const struct mdt_object *o)
+{
+ return lu_fid_eq(mdt_object_fid(o), &LU_OBF_FID);
+}
+
static inline struct lu_site *mdt_lu_site(const struct mdt_device *mdt)
{
return mdt->mdt_md_dev.md_lu_dev.ld_site;
mdt_set_capainfo(info, 1, child_fid, BYPASS_CAPA);
if (result == -ENOENT) {
+ if (mdt_object_obf(parent))
+ GOTO(out_child, result = -EPERM);
+
/* save versions in reply */
mdt_version_get_save(info, parent, 0);
mdt_version_get_save(info, child, 1);
if (IS_ERR(parent))
RETURN(PTR_ERR(parent));
+ if (mdt_object_obf(parent))
+ GOTO(out_put_parent, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, parent, 0);
if (rc)
GOTO(out_put_parent, rc);
GOTO(out, rc);
}
+ if (mdt_object_obf(mp))
+ GOTO(out_unlock_parent, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, mp, 0);
if (rc)
GOTO(out_unlock_parent, rc);
/* step 2: find & lock the child */
lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
/* lookup child object along with version checking */
+ fid_zero(child_fid);
rc = mdt_lookup_version_check(info, mp, lname, child_fid, 1);
if (rc != 0)
GOTO(out_unlock_parent, rc);
if (IS_ERR(mp))
RETURN(PTR_ERR(mp));
+ if (mdt_object_obf(mp))
+ GOTO(out_unlock_parent, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, mp, 0);
if (rc)
GOTO(out_unlock_parent, rc);
if (IS_ERR(msrcdir))
GOTO(out_rename_lock, rc = PTR_ERR(msrcdir));
+ if (mdt_object_obf(msrcdir))
+ GOTO(out_unlock_source, rc = -EPERM);
+
rc = mdt_version_get_check_save(info, msrcdir, 0);
if (rc)
GOTO(out_unlock_source, rc);
if (IS_ERR(mtgtdir))
GOTO(out_unlock_source, rc = PTR_ERR(mtgtdir));
+ if (mdt_object_obf(mtgtdir))
+ GOTO(out_put_target, rc = -EPERM);
+
/* check early, the real version will be saved after locking */
rc = mdt_version_get_check(info, mtgtdir, 1);
if (rc)
/* step 3: find & lock the old object. */
lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
mdt_name_copy(&slname, lname);
+ fid_zero(old_fid);
rc = mdt_lookup_version_check(info, msrcdir, &slname, old_fid, 2);
if (rc != 0)
GOTO(out_unlock_target, rc);
/* new target object may not exist now */
lname = mdt_name(info->mti_env, (char *)rr->rr_tgt, rr->rr_tgtlen);
/* lookup with version checking */
+ fid_zero(new_fid);
rc = mdt_lookup_version_check(info, mtgtdir, lname, new_fid, 3);
if (rc == 0) {
/* the new_fid should have been filled at this moment */
rc=$?
[ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
- echo "open fid $fid"
- diff /etc/hosts $DIR/.lustre/fid/$fid || error "open by fid failed: did not find expected data in file."
+ ffid=$DIR/.lustre/fid/$fid
+
+ echo "stat fid $fid"
+ stat $ffid > /dev/null || error "stat $ffid failed."
+ echo "touch fid $fid"
+ touch $ffid || error "touch $ffid failed."
+ echo "write to fid $fid"
+ cat /etc/hosts > $ffid || error "write $ffid failed."
+ echo "read fid $fid"
+ diff /etc/hosts $ffid || error "read $ffid failed."
+ echo "append write to fid $fid"
+ cat /etc/hosts >> $ffid || error "append write $ffid failed."
+ echo "rename fid $fid"
+ mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
+ touch $DIR/$tfile.1
+ mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
+ rm -f $DIR/$tfile.1
+ echo "truncate fid $fid"
+ $TRUNCATE $ffid 777 || error "truncate $ffid failed."
+ echo "link fid $fid"
+ ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
+ if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
+ echo "setfacl fid $fid"
+ setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
+ echo "getfacl fid $fid"
+ getfacl $ffid >/dev/null || error "getfacl $ffid failed."
+ fi
+ echo "unlink fid $fid"
+ unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
+ echo "mknod fid $fid"
+ mknod $ffid c 1 3 && error "mknod $ffid should fail."
+
+ fid=[0xf00000400:0x1:0x0]
+ ffid=$DIR/.lustre/fid/$fid
+
+ echo "stat non-exist fid $fid"
+ stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
+ echo "write to non-exist fid $fid"
+ cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
+ echo "link new fid $fid"
+ ln $DIR/$tfile $ffid && error "link $ffid should fail."
+
+ mkdir -p $DIR/$tdir
+ touch $DIR/$tdir/$tfile
+ fid=$($LFS path2fid $DIR/$tdir)
+ rc=$?
+ [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
+
+ ffid=$DIR/.lustre/fid/$fid
+
+ echo "ls $fid"
+ ls $ffid > /dev/null || error "ls $ffid failed."
+ echo "touch $fid/$tfile.1"
+ touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
+
+ echo "touch $DIR/.lustre/fid/$tfile"
+ touch $DIR/.lustre/fid/$tfile && \
+ error "touch $DIR/.lustre/fid/$tfile should fail."
- echo "Opening a file by FID succeeded"
+ echo "Open-by-FID succeeded"
}
-run_test 154 "Opening a file by FID"
+run_test 154 "Open-by-FID"
test_155_small_load() {
local temp=$TMP/$tfile