aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-27 17:00:37 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:44:14 -0400
commite0a0124936171af6156b80fe8ac8799f039e767f (patch)
tree5eed31f5b5dbf43f9a4d0e14fb4f9e1f9bcfd6d0
parented75e95de574c99575e5f3e1d9ca59ea8c12a9cb (diff)
switch vfs_path_lookup() to struct path
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/namei.c16
-rw-r--r--fs/nfs/cache_lib.c9
-rw-r--r--fs/nfs/super.c16
-rw-r--r--include/linux/namei.h2
-rw-r--r--net/sunrpc/clnt.c11
5 files changed, 26 insertions, 28 deletions
diff --git a/fs/namei.c b/fs/namei.c
index b45a039216c7..7e6ba8c80e77 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1575,16 +1575,22 @@ int kern_path(const char *name, unsigned int flags, struct path *path)
1575 * @mnt: pointer to vfs mount of the base directory 1575 * @mnt: pointer to vfs mount of the base directory
1576 * @name: pointer to file name 1576 * @name: pointer to file name
1577 * @flags: lookup flags 1577 * @flags: lookup flags
1578 * @nd: pointer to nameidata 1578 * @path: pointer to struct path to fill
1579 */ 1579 */
1580int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, 1580int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
1581 const char *name, unsigned int flags, 1581 const char *name, unsigned int flags,
1582 struct nameidata *nd) 1582 struct path *path)
1583{ 1583{
1584 nd->root.dentry = dentry; 1584 struct nameidata nd;
1585 nd->root.mnt = mnt; 1585 int err;
1586 nd.root.dentry = dentry;
1587 nd.root.mnt = mnt;
1588 BUG_ON(flags & LOOKUP_PARENT);
1586 /* the first argument of do_path_lookup() is ignored with LOOKUP_ROOT */ 1589 /* the first argument of do_path_lookup() is ignored with LOOKUP_ROOT */
1587 return do_path_lookup(AT_FDCWD, name, flags | LOOKUP_ROOT, nd); 1590 err = do_path_lookup(AT_FDCWD, name, flags | LOOKUP_ROOT, &nd);
1591 if (!err)
1592 *path = nd.path;
1593 return err;
1588} 1594}
1589 1595
1590static struct dentry *__lookup_hash(struct qstr *name, 1596static struct dentry *__lookup_hash(struct qstr *name,
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c
index 84690319e625..c98b439332fc 100644
--- a/fs/nfs/cache_lib.c
+++ b/fs/nfs/cache_lib.c
@@ -113,19 +113,18 @@ int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq)
113 113
114int nfs_cache_register(struct cache_detail *cd) 114int nfs_cache_register(struct cache_detail *cd)
115{ 115{
116 struct nameidata nd;
117 struct vfsmount *mnt; 116 struct vfsmount *mnt;
117 struct path path;
118 int ret; 118 int ret;
119 119
120 mnt = rpc_get_mount(); 120 mnt = rpc_get_mount();
121 if (IS_ERR(mnt)) 121 if (IS_ERR(mnt))
122 return PTR_ERR(mnt); 122 return PTR_ERR(mnt);
123 ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &nd); 123 ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &path);
124 if (ret) 124 if (ret)
125 goto err; 125 goto err;
126 ret = sunrpc_cache_register_pipefs(nd.path.dentry, 126 ret = sunrpc_cache_register_pipefs(path.dentry, cd->name, 0600, cd);
127 cd->name, 0600, cd); 127 path_put(&path);
128 path_put(&nd.path);
129 if (!ret) 128 if (!ret)
130 return ret; 129 return ret;
131err: 130err:
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ce40e5c568ba..b961ceac66b4 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2773,16 +2773,12 @@ static void nfs_referral_loop_unprotect(void)
2773static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, 2773static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2774 const char *export_path) 2774 const char *export_path)
2775{ 2775{
2776 struct nameidata *nd = NULL;
2777 struct mnt_namespace *ns_private; 2776 struct mnt_namespace *ns_private;
2778 struct super_block *s; 2777 struct super_block *s;
2779 struct dentry *dentry; 2778 struct dentry *dentry;
2779 struct path path;
2780 int ret; 2780 int ret;
2781 2781
2782 nd = kmalloc(sizeof(*nd), GFP_KERNEL);
2783 if (nd == NULL)
2784 return ERR_PTR(-ENOMEM);
2785
2786 ns_private = create_mnt_ns(root_mnt); 2782 ns_private = create_mnt_ns(root_mnt);
2787 ret = PTR_ERR(ns_private); 2783 ret = PTR_ERR(ns_private);
2788 if (IS_ERR(ns_private)) 2784 if (IS_ERR(ns_private))
@@ -2793,7 +2789,7 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2793 goto out_put_mnt_ns; 2789 goto out_put_mnt_ns;
2794 2790
2795 ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, 2791 ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
2796 export_path, LOOKUP_FOLLOW, nd); 2792 export_path, LOOKUP_FOLLOW, &path);
2797 2793
2798 nfs_referral_loop_unprotect(); 2794 nfs_referral_loop_unprotect();
2799 put_mnt_ns(ns_private); 2795 put_mnt_ns(ns_private);
@@ -2801,12 +2797,11 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2801 if (ret != 0) 2797 if (ret != 0)
2802 goto out_err; 2798 goto out_err;
2803 2799
2804 s = nd->path.mnt->mnt_sb; 2800 s = path.mnt->mnt_sb;
2805 atomic_inc(&s->s_active); 2801 atomic_inc(&s->s_active);
2806 dentry = dget(nd->path.dentry); 2802 dentry = dget(path.dentry);
2807 2803
2808 path_put(&nd->path); 2804 path_put(&path);
2809 kfree(nd);
2810 down_write(&s->s_umount); 2805 down_write(&s->s_umount);
2811 return dentry; 2806 return dentry;
2812out_put_mnt_ns: 2807out_put_mnt_ns:
@@ -2814,7 +2809,6 @@ out_put_mnt_ns:
2814out_mntput: 2809out_mntput:
2815 mntput(root_mnt); 2810 mntput(root_mnt);
2816out_err: 2811out_err:
2817 kfree(nd);
2818 return ERR_PTR(ret); 2812 return ERR_PTR(ret);
2819} 2813}
2820 2814
diff --git a/include/linux/namei.h b/include/linux/namei.h
index b8cea804d31a..76fe2c62ae71 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -78,7 +78,7 @@ extern struct dentry *kern_path_create(int, const char *, struct path *, int);
78extern struct dentry *user_path_create(int, const char __user *, struct path *, int); 78extern struct dentry *user_path_create(int, const char __user *, struct path *, int);
79extern int kern_path_parent(const char *, struct nameidata *); 79extern int kern_path_parent(const char *, struct nameidata *);
80extern int vfs_path_lookup(struct dentry *, struct vfsmount *, 80extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
81 const char *, unsigned int, struct nameidata *); 81 const char *, unsigned int, struct path *);
82 82
83extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, 83extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
84 int (*open)(struct inode *, struct file *)); 84 int (*open)(struct inode *, struct file *));
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 8c9141583d6f..304f403a0411 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -97,8 +97,7 @@ static int
97rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) 97rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
98{ 98{
99 static uint32_t clntid; 99 static uint32_t clntid;
100 struct nameidata nd; 100 struct path path, dir;
101 struct path path;
102 char name[15]; 101 char name[15];
103 struct qstr q = { 102 struct qstr q = {
104 .name = name, 103 .name = name,
@@ -113,7 +112,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
113 path.mnt = rpc_get_mount(); 112 path.mnt = rpc_get_mount();
114 if (IS_ERR(path.mnt)) 113 if (IS_ERR(path.mnt))
115 return PTR_ERR(path.mnt); 114 return PTR_ERR(path.mnt);
116 error = vfs_path_lookup(path.mnt->mnt_root, path.mnt, dir_name, 0, &nd); 115 error = vfs_path_lookup(path.mnt->mnt_root, path.mnt, dir_name, 0, &dir);
117 if (error) 116 if (error)
118 goto err; 117 goto err;
119 118
@@ -121,7 +120,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
121 q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); 120 q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
122 name[sizeof(name) - 1] = '\0'; 121 name[sizeof(name) - 1] = '\0';
123 q.hash = full_name_hash(q.name, q.len); 122 q.hash = full_name_hash(q.name, q.len);
124 path.dentry = rpc_create_client_dir(nd.path.dentry, &q, clnt); 123 path.dentry = rpc_create_client_dir(dir.dentry, &q, clnt);
125 if (!IS_ERR(path.dentry)) 124 if (!IS_ERR(path.dentry))
126 break; 125 break;
127 error = PTR_ERR(path.dentry); 126 error = PTR_ERR(path.dentry);
@@ -132,11 +131,11 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
132 goto err_path_put; 131 goto err_path_put;
133 } 132 }
134 } 133 }
135 path_put(&nd.path); 134 path_put(&dir);
136 clnt->cl_path = path; 135 clnt->cl_path = path;
137 return 0; 136 return 0;
138err_path_put: 137err_path_put:
139 path_put(&nd.path); 138 path_put(&dir);
140err: 139err:
141 rpc_put_mount(); 140 rpc_put_mount();
142 return error; 141 return error;