Commit e0a01249 authored by Al Viro's avatar Al Viro

switch vfs_path_lookup() to struct path

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent ed75e95d
...@@ -1575,16 +1575,22 @@ int kern_path(const char *name, unsigned int flags, struct path *path) ...@@ -1575,16 +1575,22 @@ int kern_path(const char *name, unsigned int flags, struct path *path)
* @mnt: pointer to vfs mount of the base directory * @mnt: pointer to vfs mount of the base directory
* @name: pointer to file name * @name: pointer to file name
* @flags: lookup flags * @flags: lookup flags
* @nd: pointer to nameidata * @path: pointer to struct path to fill
*/ */
int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
const char *name, unsigned int flags, const char *name, unsigned int flags,
struct nameidata *nd) struct path *path)
{ {
nd->root.dentry = dentry; struct nameidata nd;
nd->root.mnt = mnt; 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 */ /* 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, static struct dentry *__lookup_hash(struct qstr *name,
......
...@@ -113,19 +113,18 @@ int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq) ...@@ -113,19 +113,18 @@ int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq)
int nfs_cache_register(struct cache_detail *cd) int nfs_cache_register(struct cache_detail *cd)
{ {
struct nameidata nd;
struct vfsmount *mnt; struct vfsmount *mnt;
struct path path;
int ret; int ret;
mnt = rpc_get_mount(); mnt = rpc_get_mount();
if (IS_ERR(mnt)) if (IS_ERR(mnt))
return PTR_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) if (ret)
goto err; goto err;
ret = sunrpc_cache_register_pipefs(nd.path.dentry, ret = sunrpc_cache_register_pipefs(path.dentry, cd->name, 0600, cd);
cd->name, 0600, cd); path_put(&path);
path_put(&nd.path);
if (!ret) if (!ret)
return ret; return ret;
err: err:
......
...@@ -2773,16 +2773,12 @@ static void nfs_referral_loop_unprotect(void) ...@@ -2773,16 +2773,12 @@ static void nfs_referral_loop_unprotect(void)
static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
const char *export_path) const char *export_path)
{ {
struct nameidata *nd = NULL;
struct mnt_namespace *ns_private; struct mnt_namespace *ns_private;
struct super_block *s; struct super_block *s;
struct dentry *dentry; struct dentry *dentry;
struct path path;
int ret; int ret;
nd = kmalloc(sizeof(*nd), GFP_KERNEL);
if (nd == NULL)
return ERR_PTR(-ENOMEM);
ns_private = create_mnt_ns(root_mnt); ns_private = create_mnt_ns(root_mnt);
ret = PTR_ERR(ns_private); ret = PTR_ERR(ns_private);
if (IS_ERR(ns_private)) if (IS_ERR(ns_private))
...@@ -2793,7 +2789,7 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, ...@@ -2793,7 +2789,7 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
goto out_put_mnt_ns; goto out_put_mnt_ns;
ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
export_path, LOOKUP_FOLLOW, nd); export_path, LOOKUP_FOLLOW, &path);
nfs_referral_loop_unprotect(); nfs_referral_loop_unprotect();
put_mnt_ns(ns_private); put_mnt_ns(ns_private);
...@@ -2801,12 +2797,11 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, ...@@ -2801,12 +2797,11 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
if (ret != 0) if (ret != 0)
goto out_err; goto out_err;
s = nd->path.mnt->mnt_sb; s = path.mnt->mnt_sb;
atomic_inc(&s->s_active); atomic_inc(&s->s_active);
dentry = dget(nd->path.dentry); dentry = dget(path.dentry);
path_put(&nd->path); path_put(&path);
kfree(nd);
down_write(&s->s_umount); down_write(&s->s_umount);
return dentry; return dentry;
out_put_mnt_ns: out_put_mnt_ns:
...@@ -2814,7 +2809,6 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, ...@@ -2814,7 +2809,6 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
out_mntput: out_mntput:
mntput(root_mnt); mntput(root_mnt);
out_err: out_err:
kfree(nd);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -78,7 +78,7 @@ extern struct dentry *kern_path_create(int, const char *, struct path *, int); ...@@ -78,7 +78,7 @@ extern struct dentry *kern_path_create(int, const char *, struct path *, int);
extern struct dentry *user_path_create(int, const char __user *, struct path *, int); extern struct dentry *user_path_create(int, const char __user *, struct path *, int);
extern int kern_path_parent(const char *, struct nameidata *); extern int kern_path_parent(const char *, struct nameidata *);
extern int vfs_path_lookup(struct dentry *, struct vfsmount *, 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, extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
int (*open)(struct inode *, struct file *)); int (*open)(struct inode *, struct file *));
......
...@@ -97,8 +97,7 @@ static int ...@@ -97,8 +97,7 @@ static int
rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
{ {
static uint32_t clntid; static uint32_t clntid;
struct nameidata nd; struct path path, dir;
struct path path;
char name[15]; char name[15];
struct qstr q = { struct qstr q = {
.name = name, .name = name,
...@@ -113,7 +112,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) ...@@ -113,7 +112,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
path.mnt = rpc_get_mount(); path.mnt = rpc_get_mount();
if (IS_ERR(path.mnt)) if (IS_ERR(path.mnt))
return PTR_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) if (error)
goto err; goto err;
...@@ -121,7 +120,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) ...@@ -121,7 +120,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
name[sizeof(name) - 1] = '\0'; name[sizeof(name) - 1] = '\0';
q.hash = full_name_hash(q.name, q.len); 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)) if (!IS_ERR(path.dentry))
break; break;
error = PTR_ERR(path.dentry); error = PTR_ERR(path.dentry);
...@@ -132,11 +131,11 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) ...@@ -132,11 +131,11 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
goto err_path_put; goto err_path_put;
} }
} }
path_put(&nd.path); path_put(&dir);
clnt->cl_path = path; clnt->cl_path = path;
return 0; return 0;
err_path_put: err_path_put:
path_put(&nd.path); path_put(&dir);
err: err:
rpc_put_mount(); rpc_put_mount();
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment