Commit 896475d5 authored by Al Viro's avatar Al Viro

do_last: move path there from caller's stack frame

We used to need it to feed to follow_link().  No more...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent caa85634
...@@ -2911,7 +2911,7 @@ static int lookup_open(struct nameidata *nd, struct path *path, ...@@ -2911,7 +2911,7 @@ static int lookup_open(struct nameidata *nd, struct path *path,
/* /*
* Handle the last step of open() * Handle the last step of open()
*/ */
static int do_last(struct nameidata *nd, struct path *path, static int do_last(struct nameidata *nd,
struct file *file, const struct open_flags *op, struct file *file, const struct open_flags *op,
int *opened, struct filename *name) int *opened, struct filename *name)
{ {
...@@ -2922,6 +2922,7 @@ static int do_last(struct nameidata *nd, struct path *path, ...@@ -2922,6 +2922,7 @@ static int do_last(struct nameidata *nd, struct path *path,
int acc_mode = op->acc_mode; int acc_mode = op->acc_mode;
struct inode *inode; struct inode *inode;
struct path save_parent = { .dentry = NULL, .mnt = NULL }; struct path save_parent = { .dentry = NULL, .mnt = NULL };
struct path path;
bool retried = false; bool retried = false;
int error; int error;
...@@ -2939,7 +2940,7 @@ static int do_last(struct nameidata *nd, struct path *path, ...@@ -2939,7 +2940,7 @@ static int do_last(struct nameidata *nd, struct path *path,
if (nd->last.name[nd->last.len]) if (nd->last.name[nd->last.len])
nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
/* we _can_ be in RCU mode here */ /* we _can_ be in RCU mode here */
error = lookup_fast(nd, path, &inode); error = lookup_fast(nd, &path, &inode);
if (likely(!error)) if (likely(!error))
goto finish_lookup; goto finish_lookup;
...@@ -2977,7 +2978,7 @@ static int do_last(struct nameidata *nd, struct path *path, ...@@ -2977,7 +2978,7 @@ static int do_last(struct nameidata *nd, struct path *path,
*/ */
} }
mutex_lock(&dir->d_inode->i_mutex); mutex_lock(&dir->d_inode->i_mutex);
error = lookup_open(nd, path, file, op, got_write, opened); error = lookup_open(nd, &path, file, op, got_write, opened);
mutex_unlock(&dir->d_inode->i_mutex); mutex_unlock(&dir->d_inode->i_mutex);
if (error <= 0) { if (error <= 0) {
...@@ -2997,15 +2998,15 @@ static int do_last(struct nameidata *nd, struct path *path, ...@@ -2997,15 +2998,15 @@ static int do_last(struct nameidata *nd, struct path *path,
open_flag &= ~O_TRUNC; open_flag &= ~O_TRUNC;
will_truncate = false; will_truncate = false;
acc_mode = MAY_OPEN; acc_mode = MAY_OPEN;
path_to_nameidata(path, nd); path_to_nameidata(&path, nd);
goto finish_open_created; goto finish_open_created;
} }
/* /*
* create/update audit record if it already exists. * create/update audit record if it already exists.
*/ */
if (d_is_positive(path->dentry)) if (d_is_positive(path.dentry))
audit_inode(name, path->dentry, 0); audit_inode(name, path.dentry, 0);
/* /*
* If atomic_open() acquired write access it is dropped now due to * If atomic_open() acquired write access it is dropped now due to
...@@ -3021,7 +3022,7 @@ static int do_last(struct nameidata *nd, struct path *path, ...@@ -3021,7 +3022,7 @@ static int do_last(struct nameidata *nd, struct path *path,
if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))
goto exit_dput; goto exit_dput;
error = follow_managed(path, nd->flags); error = follow_managed(&path, nd->flags);
if (error < 0) if (error < 0)
goto exit_dput; goto exit_dput;
...@@ -3029,38 +3030,38 @@ static int do_last(struct nameidata *nd, struct path *path, ...@@ -3029,38 +3030,38 @@ static int do_last(struct nameidata *nd, struct path *path,
nd->flags |= LOOKUP_JUMPED; nd->flags |= LOOKUP_JUMPED;
BUG_ON(nd->flags & LOOKUP_RCU); BUG_ON(nd->flags & LOOKUP_RCU);
inode = path->dentry->d_inode; inode = path.dentry->d_inode;
error = -ENOENT; error = -ENOENT;
if (d_is_negative(path->dentry)) { if (d_is_negative(path.dentry)) {
path_to_nameidata(path, nd); path_to_nameidata(&path, nd);
goto out; goto out;
} }
finish_lookup: finish_lookup:
if (should_follow_link(path->dentry, nd->flags & LOOKUP_FOLLOW)) { if (should_follow_link(path.dentry, nd->flags & LOOKUP_FOLLOW)) {
if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) {
if (unlikely(nd->path.mnt != path->mnt || if (unlikely(nd->path.mnt != path.mnt ||
unlazy_walk(nd, path->dentry))) { unlazy_walk(nd, path.dentry))) {
error = -ECHILD; error = -ECHILD;
goto out; goto out;
} }
} }
BUG_ON(inode != path->dentry->d_inode); BUG_ON(inode != path.dentry->d_inode);
nd->link = *path; nd->link = path;
return 1; return 1;
} }
if (unlikely(d_is_symlink(path->dentry)) && !(open_flag & O_PATH)) { if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
path_to_nameidata(path, nd); path_to_nameidata(&path, nd);
error = -ELOOP; error = -ELOOP;
goto out; goto out;
} }
if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) {
path_to_nameidata(path, nd); path_to_nameidata(&path, nd);
} else { } else {
save_parent.dentry = nd->path.dentry; save_parent.dentry = nd->path.dentry;
save_parent.mnt = mntget(path->mnt); save_parent.mnt = mntget(path.mnt);
nd->path.dentry = path->dentry; nd->path.dentry = path.dentry;
} }
nd->inode = inode; nd->inode = inode;
...@@ -3122,7 +3123,7 @@ static int do_last(struct nameidata *nd, struct path *path, ...@@ -3122,7 +3123,7 @@ static int do_last(struct nameidata *nd, struct path *path,
return error; return error;
exit_dput: exit_dput:
path_put_conditional(path, nd); path_put_conditional(&path, nd);
goto out; goto out;
exit_fput: exit_fput:
fput(file); fput(file);
...@@ -3213,7 +3214,6 @@ static struct file *path_openat(int dfd, struct filename *pathname, ...@@ -3213,7 +3214,6 @@ static struct file *path_openat(int dfd, struct filename *pathname,
struct nameidata *nd, const struct open_flags *op, int flags) struct nameidata *nd, const struct open_flags *op, int flags)
{ {
struct file *file; struct file *file;
struct path path;
int opened = 0; int opened = 0;
int error; int error;
...@@ -3232,7 +3232,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, ...@@ -3232,7 +3232,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
error = do_last(nd, &path, file, op, &opened, pathname); error = do_last(nd, file, op, &opened, pathname);
while (unlikely(error > 0)) { /* trailing symlink */ while (unlikely(error > 0)) { /* trailing symlink */
struct path link = nd->link; struct path link = nd->link;
void *cookie; void *cookie;
...@@ -3244,7 +3244,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, ...@@ -3244,7 +3244,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
error = follow_link(&link, nd, &cookie); error = follow_link(&link, nd, &cookie);
if (unlikely(error)) if (unlikely(error))
break; break;
error = do_last(nd, &path, file, op, &opened, pathname); error = do_last(nd, file, op, &opened, pathname);
put_link(nd, &link, cookie); put_link(nd, &link, cookie);
} }
out: out:
......
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