* @mnt: pointer to vfs mount of the base directory
* @name: pointer to file name
* @flags: lookup flags
- * @nd: pointer to nameidata
+ * @path: pointer to struct path to fill
*/
int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
const char *name, unsigned int flags,
- struct nameidata *nd)
+ struct path *path)
{
- nd->root.dentry = dentry;
- nd->root.mnt = mnt;
+ struct nameidata nd;
+ int err;
+ nd.root.dentry = dentry;
+ nd.root.mnt = mnt;
+ BUG_ON(flags & LOOKUP_PARENT);
/* the first argument of do_path_lookup() is ignored with LOOKUP_ROOT */
- return do_path_lookup(AT_FDCWD, name, flags | LOOKUP_ROOT, nd);
+ err = do_path_lookup(AT_FDCWD, name, flags | LOOKUP_ROOT, &nd);
+ if (!err)
+ *path = nd.path;
+ return err;
}
static struct dentry *__lookup_hash(struct qstr *name,
int nfs_cache_register(struct cache_detail *cd)
{
- struct nameidata nd;
struct vfsmount *mnt;
+ struct path path;
int ret;
mnt = rpc_get_mount();
if (IS_ERR(mnt))
return PTR_ERR(mnt);
- ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &nd);
+ ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &path);
if (ret)
goto err;
- ret = sunrpc_cache_register_pipefs(nd.path.dentry,
- cd->name, 0600, cd);
- path_put(&nd.path);
+ ret = sunrpc_cache_register_pipefs(path.dentry, cd->name, 0600, cd);
+ path_put(&path);
if (!ret)
return ret;
err:
static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
const char *export_path)
{
- struct nameidata *nd = NULL;
struct mnt_namespace *ns_private;
struct super_block *s;
struct dentry *dentry;
+ struct path path;
int ret;
- nd = kmalloc(sizeof(*nd), GFP_KERNEL);
- if (nd == NULL)
- return ERR_PTR(-ENOMEM);
-
ns_private = create_mnt_ns(root_mnt);
ret = PTR_ERR(ns_private);
if (IS_ERR(ns_private))
goto out_put_mnt_ns;
ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
- export_path, LOOKUP_FOLLOW, nd);
+ export_path, LOOKUP_FOLLOW, &path);
nfs_referral_loop_unprotect();
put_mnt_ns(ns_private);
if (ret != 0)
goto out_err;
- s = nd->path.mnt->mnt_sb;
+ s = path.mnt->mnt_sb;
atomic_inc(&s->s_active);
- dentry = dget(nd->path.dentry);
+ dentry = dget(path.dentry);
- path_put(&nd->path);
- kfree(nd);
+ path_put(&path);
down_write(&s->s_umount);
return dentry;
out_put_mnt_ns:
out_mntput:
mntput(root_mnt);
out_err:
- kfree(nd);
return ERR_PTR(ret);
}
extern struct dentry *user_path_create(int, const char __user *, struct path *, int);
extern int kern_path_parent(const char *, struct nameidata *);
extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
- const char *, unsigned int, struct nameidata *);
+ const char *, unsigned int, struct path *);
extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
int (*open)(struct inode *, struct file *));
rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
{
static uint32_t clntid;
- struct nameidata nd;
- struct path path;
+ struct path path, dir;
char name[15];
struct qstr q = {
.name = name,
path.mnt = rpc_get_mount();
if (IS_ERR(path.mnt))
return PTR_ERR(path.mnt);
- error = vfs_path_lookup(path.mnt->mnt_root, path.mnt, dir_name, 0, &nd);
+ error = vfs_path_lookup(path.mnt->mnt_root, path.mnt, dir_name, 0, &dir);
if (error)
goto err;
q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
name[sizeof(name) - 1] = '\0';
q.hash = full_name_hash(q.name, q.len);
- path.dentry = rpc_create_client_dir(nd.path.dentry, &q, clnt);
+ path.dentry = rpc_create_client_dir(dir.dentry, &q, clnt);
if (!IS_ERR(path.dentry))
break;
error = PTR_ERR(path.dentry);
goto err_path_put;
}
}
- path_put(&nd.path);
+ path_put(&dir);
clnt->cl_path = path;
return 0;
err_path_put:
- path_put(&nd.path);
+ path_put(&dir);
err:
rpc_put_mount();
return error;