aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-10-10 15:25:29 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 20:15:08 -0400
commit873f1eedc1b983d772283279192c4ca2f60e8482 (patch)
treedc5ff4dabb933c3392917602c0f6aeb00d25e6ea /fs/namei.c
parent7ac86265dc8f665cc49d6e60a125e608cd2fca14 (diff)
vfs: turn do_path_lookup into wrapper around struct filename variant
...and make the user_path callers use that variant instead. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 5dbc3f836934..8c14353fb750 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1988,20 +1988,30 @@ static int path_lookupat(int dfd, const char *name,
1988 return err; 1988 return err;
1989} 1989}
1990 1990
1991static int do_path_lookup(int dfd, const char *name, 1991static int filename_lookup(int dfd, struct filename *name,
1992 unsigned int flags, struct nameidata *nd) 1992 unsigned int flags, struct nameidata *nd)
1993{ 1993{
1994 int retval = path_lookupat(dfd, name, flags | LOOKUP_RCU, nd); 1994 int retval = path_lookupat(dfd, name->name, flags | LOOKUP_RCU, nd);
1995 if (unlikely(retval == -ECHILD)) 1995 if (unlikely(retval == -ECHILD))
1996 retval = path_lookupat(dfd, name, flags, nd); 1996 retval = path_lookupat(dfd, name->name, flags, nd);
1997 if (unlikely(retval == -ESTALE)) 1997 if (unlikely(retval == -ESTALE))
1998 retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd); 1998 retval = path_lookupat(dfd, name->name,
1999 flags | LOOKUP_REVAL, nd);
1999 2000
2000 if (likely(!retval)) 2001 if (likely(!retval))
2001 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT); 2002 audit_inode(name->name, nd->path.dentry,
2003 flags & LOOKUP_PARENT);
2002 return retval; 2004 return retval;
2003} 2005}
2004 2006
2007static int do_path_lookup(int dfd, const char *name,
2008 unsigned int flags, struct nameidata *nd)
2009{
2010 struct filename filename = { .name = name };
2011
2012 return filename_lookup(dfd, &filename, flags, nd);
2013}
2014
2005/* does lookup, returns the object with parent locked */ 2015/* does lookup, returns the object with parent locked */
2006struct dentry *kern_path_locked(const char *name, struct path *path) 2016struct dentry *kern_path_locked(const char *name, struct path *path)
2007{ 2017{
@@ -2125,7 +2135,7 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
2125 2135
2126 BUG_ON(flags & LOOKUP_PARENT); 2136 BUG_ON(flags & LOOKUP_PARENT);
2127 2137
2128 err = do_path_lookup(dfd, tmp->name, flags, &nd); 2138 err = filename_lookup(dfd, tmp, flags, &nd);
2129 putname(tmp); 2139 putname(tmp);
2130 if (!err) 2140 if (!err)
2131 *path = nd.path; 2141 *path = nd.path;
@@ -2139,6 +2149,12 @@ int user_path_at(int dfd, const char __user *name, unsigned flags,
2139 return user_path_at_empty(dfd, name, flags, path, NULL); 2149 return user_path_at_empty(dfd, name, flags, path, NULL);
2140} 2150}
2141 2151
2152/*
2153 * NB: most callers don't do anything directly with the reference to the
2154 * to struct filename, but the nd->last pointer points into the name string
2155 * allocated by getname. So we must hold the reference to it until all
2156 * path-walking is complete.
2157 */
2142static struct filename * 2158static struct filename *
2143user_path_parent(int dfd, const char __user *path, struct nameidata *nd) 2159user_path_parent(int dfd, const char __user *path, struct nameidata *nd)
2144{ 2160{
@@ -2148,7 +2164,7 @@ user_path_parent(int dfd, const char __user *path, struct nameidata *nd)
2148 if (IS_ERR(s)) 2164 if (IS_ERR(s))
2149 return s; 2165 return s;
2150 2166
2151 error = do_path_lookup(dfd, s->name, LOOKUP_PARENT, nd); 2167 error = filename_lookup(dfd, s, LOOKUP_PARENT, nd);
2152 if (error) { 2168 if (error) {
2153 putname(s); 2169 putname(s);
2154 return ERR_PTR(error); 2170 return ERR_PTR(error);