+static int mdt_lookup_fileset(struct mdt_thread_info *info, const char *fileset,
+ struct lu_fid *fid)
+{
+ struct mdt_device *mdt = info->mti_mdt;
+ struct lu_name *lname = &info->mti_name;
+ char *name = NULL;
+ struct mdt_object *parent;
+ u32 mode;
+ int rc = 0;
+
+ LASSERT(!info->mti_cross_ref);
+
+ OBD_ALLOC(name, NAME_MAX + 1);
+ if (name == NULL)
+ return -ENOMEM;
+ lname->ln_name = name;
+
+ /*
+ * We may want to allow this to mount a completely separate
+ * fileset from the MDT in the future, but keeping it to
+ * ROOT/ only for now avoid potential security issues.
+ */
+ *fid = mdt->mdt_md_root_fid;
+
+ while (rc == 0 && fileset != NULL && *fileset != '\0') {
+ const char *s1 = fileset;
+ const char *s2;
+
+ while (*++s1 == '/')
+ ;
+ s2 = s1;
+ while (*s2 != '/' && *s2 != '\0')
+ s2++;
+
+ if (s2 == s1)
+ break;
+
+ fileset = s2;
+
+ lname->ln_namelen = s2 - s1;
+ if (lname->ln_namelen > NAME_MAX) {
+ rc = -EINVAL;
+ break;
+ }
+
+ /* reject .. as a path component */
+ if (lname->ln_namelen == 2 &&
+ strncmp(s1, "..", 2) == 0) {
+ rc = -EINVAL;
+ break;
+ }
+
+ strncpy(name, s1, lname->ln_namelen);
+ name[lname->ln_namelen] = '\0';
+
+ parent = mdt_object_find(info->mti_env, mdt, fid);
+ if (IS_ERR(parent)) {
+ rc = PTR_ERR(parent);
+ break;
+ }
+ /* Only got the fid of this obj by name */
+ fid_zero(fid);
+ rc = mdo_lookup(info->mti_env, mdt_object_child(parent), lname,
+ fid, &info->mti_spec);
+ mdt_object_put(info->mti_env, parent);
+ }
+ if (!rc) {
+ parent = mdt_object_find(info->mti_env, mdt, fid);
+ if (IS_ERR(parent))
+ rc = PTR_ERR(parent);
+ else {
+ mode = lu_object_attr(&parent->mot_obj);
+ mdt_object_put(info->mti_env, parent);
+ if (!S_ISDIR(mode))
+ rc = -ENOTDIR;
+ }
+ }
+
+ OBD_FREE(name, NAME_MAX + 1);
+
+ return rc;
+}
+
+static int mdt_get_root(struct tgt_session_info *tsi)