Commit 46afd6f6 authored by Al Viro's avatar Al Viro

namei: lift nameidata into filename_mountpoint()

when we go for on-demand allocation of saved state in
link_path_walk(), we'll want nameidata to stay around
for all 3 calls of path_mountpoint().
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f5beed75
...@@ -2344,31 +2344,28 @@ mountpoint_last(struct nameidata *nd, struct path *path) ...@@ -2344,31 +2344,28 @@ mountpoint_last(struct nameidata *nd, struct path *path)
*/ */
static int static int
path_mountpoint(int dfd, const struct filename *name, struct path *path, path_mountpoint(int dfd, const struct filename *name, struct path *path,
unsigned int flags) struct nameidata *nd, unsigned int flags)
{ {
struct nameidata nd; int err = path_init(dfd, name, flags, nd);
int err;
err = path_init(dfd, name, flags, &nd);
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
err = mountpoint_last(&nd, path); err = mountpoint_last(nd, path);
while (err > 0) { while (err > 0) {
void *cookie; void *cookie;
struct path link = *path; struct path link = *path;
err = may_follow_link(&link, &nd); err = may_follow_link(&link, nd);
if (unlikely(err)) if (unlikely(err))
break; break;
nd.flags |= LOOKUP_PARENT; nd->flags |= LOOKUP_PARENT;
err = follow_link(&link, &nd, &cookie); err = follow_link(&link, nd, &cookie);
if (err) if (err)
break; break;
err = mountpoint_last(&nd, path); err = mountpoint_last(nd, path);
put_link(&nd, &link, cookie); put_link(nd, &link, cookie);
} }
out: out:
path_cleanup(&nd); path_cleanup(nd);
return err; return err;
} }
...@@ -2376,14 +2373,15 @@ static int ...@@ -2376,14 +2373,15 @@ static int
filename_mountpoint(int dfd, struct filename *name, struct path *path, filename_mountpoint(int dfd, struct filename *name, struct path *path,
unsigned int flags) unsigned int flags)
{ {
struct nameidata nd;
int error; int error;
if (IS_ERR(name)) if (IS_ERR(name))
return PTR_ERR(name); return PTR_ERR(name);
error = path_mountpoint(dfd, name, path, flags | LOOKUP_RCU); error = path_mountpoint(dfd, name, path, &nd, flags | LOOKUP_RCU);
if (unlikely(error == -ECHILD)) if (unlikely(error == -ECHILD))
error = path_mountpoint(dfd, name, path, flags); error = path_mountpoint(dfd, name, path, &nd, flags);
if (unlikely(error == -ESTALE)) if (unlikely(error == -ESTALE))
error = path_mountpoint(dfd, name, path, flags | LOOKUP_REVAL); error = path_mountpoint(dfd, name, path, &nd, flags | LOOKUP_REVAL);
if (likely(!error)) if (likely(!error))
audit_inode(name, path->dentry, 0); audit_inode(name, path->dentry, 0);
putname(name); putname(name);
......
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