int dt_try_as_dir(const struct lu_env *env, struct dt_object *obj, bool check);
-/*
- * Callback function used for parsing path.
- * see llo_store_resolve
- */
-typedef int (*dt_entry_func_t)(const struct lu_env *env,
- const char *name,
- void *pvt);
-
-int dt_path_parser(const struct lu_env *env,
- char *local, dt_entry_func_t entry_func,
- void *data);
-
-struct dt_object *
-dt_store_resolve(const struct lu_env *env, struct dt_device *dt,
- const char *path, struct lu_fid *fid);
-
-struct dt_object *dt_store_open(const struct lu_env *env,
- struct dt_device *dt,
- const char *dirname,
- const char *filename,
- struct lu_fid *fid);
-
struct dt_object *dt_find_or_create(const struct lu_env *env,
struct dt_device *dt,
const struct lu_fid *fid,
}
EXPORT_SYMBOL(dt_locate_at);
-/**
- * find an object named \a entry in given \a dfh->dfh_o directory.
- */
-static int dt_find_entry(const struct lu_env *env, const char *entry,
- void *data)
-{
- struct dt_find_hint *dfh = data;
- struct dt_device *dt = dfh->dfh_dt;
- struct lu_fid *fid = dfh->dfh_fid;
- struct dt_object *obj = dfh->dfh_o;
- int rc;
-
- rc = dt_lookup_dir(env, obj, entry, fid);
- dt_object_put(env, obj);
- if (rc == 0) {
- obj = dt_locate(env, dt, fid);
- if (IS_ERR(obj))
- rc = PTR_ERR(obj);
- }
- dfh->dfh_o = obj;
-
- return rc;
-}
-
-/**
- * Abstract function which parses path name. This function feeds
- * path component to \a entry_func.
- */
-int dt_path_parser(const struct lu_env *env,
- char *path, dt_entry_func_t entry_func,
- void *data)
-{
- char *e;
- int rc = 0;
-
- while (1) {
- e = strsep(&path, "/");
- if (e == NULL)
- break;
-
- if (e[0] == 0) {
- if (!path || path[0] == '\0')
- break;
- continue;
- }
- rc = entry_func(env, e, data);
- if (rc)
- break;
- }
-
- return rc;
-}
-
-struct dt_object *
-dt_store_resolve(const struct lu_env *env, struct dt_device *dt,
- const char *path, struct lu_fid *fid)
-{
- struct dt_thread_info *info = dt_info(env);
- struct dt_find_hint *dfh = &info->dti_dfh;
- struct dt_object *obj;
- int result;
-
-
- dfh->dfh_dt = dt;
- dfh->dfh_fid = fid;
-
- strscpy(info->dti_buf, path, sizeof(info->dti_buf));
-
- result = dt->dd_ops->dt_root_get(env, dt, fid);
- if (result == 0) {
- obj = dt_locate(env, dt, fid);
- if (!IS_ERR(obj)) {
- dfh->dfh_o = obj;
- result = dt_path_parser(env, info->dti_buf,
- dt_find_entry, dfh);
- if (result != 0)
- obj = ERR_PTR(result);
- else
- obj = dfh->dfh_o;
- }
- } else {
- obj = ERR_PTR(result);
- }
- return obj;
-}
-
-static struct dt_object *dt_reg_open(const struct lu_env *env,
- struct dt_device *dt,
- struct dt_object *p,
- const char *name,
- struct lu_fid *fid)
-{
- struct dt_object *o;
- int result;
-
- result = dt_lookup_dir(env, p, name, fid);
- if (result == 0)
- o = dt_locate(env, dt, fid);
- else
- o = ERR_PTR(result);
-
- return o;
-}
-
-/**
- * Open dt object named \a filename from \a dirname directory.
- * \param dt dt device
- * \param fid on success, object fid is stored in *fid
- */
-struct dt_object *dt_store_open(const struct lu_env *env, struct dt_device *dt,
- const char *dirname, const char *filename,
- struct lu_fid *fid)
-{
- struct dt_object *file;
- struct dt_object *dir;
-
- dir = dt_store_resolve(env, dt, dirname, fid);
- if (!IS_ERR(dir)) {
- file = dt_reg_open(env, dt, dir, filename, fid);
- dt_object_put(env, dir);
- } else {
- file = dir;
- }
-
- return file;
-}
-
struct dt_object *dt_find_or_create(const struct lu_env *env,
struct dt_device *dt,
const struct lu_fid *fid,