[PATCH 33/79] do_last: move path there from caller's stack frame
From: Al Viro
Date: Tue May 05 2015 - 01:26:37 EST
From: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
We used to need it to feed to follow_link(). No more...
Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
fs/namei.c | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index 72a6130..c5d5e9e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2903,7 +2903,7 @@ out_dput:
/*
* 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,
int *opened, struct filename *name)
{
@@ -2914,6 +2914,7 @@ static int do_last(struct nameidata *nd, struct path *path,
int acc_mode = op->acc_mode;
struct inode *inode;
struct path save_parent = { .dentry = NULL, .mnt = NULL };
+ struct path path;
bool retried = false;
int error;
@@ -2931,7 +2932,7 @@ static int do_last(struct nameidata *nd, struct path *path,
if (nd->last.name[nd->last.len])
nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
/* we _can_ be in RCU mode here */
- error = lookup_fast(nd, path, &inode);
+ error = lookup_fast(nd, &path, &inode);
if (likely(!error))
goto finish_lookup;
@@ -2969,7 +2970,7 @@ retry_lookup:
*/
}
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);
if (error <= 0) {
@@ -2989,15 +2990,15 @@ retry_lookup:
open_flag &= ~O_TRUNC;
will_truncate = false;
acc_mode = MAY_OPEN;
- path_to_nameidata(path, nd);
+ path_to_nameidata(&path, nd);
goto finish_open_created;
}
/*
* create/update audit record if it already exists.
*/
- if (d_is_positive(path->dentry))
- audit_inode(name, path->dentry, 0);
+ if (d_is_positive(path.dentry))
+ audit_inode(name, path.dentry, 0);
/*
* If atomic_open() acquired write access it is dropped now due to
@@ -3013,7 +3014,7 @@ retry_lookup:
if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))
goto exit_dput;
- error = follow_managed(path, nd->flags);
+ error = follow_managed(&path, nd->flags);
if (error < 0)
goto exit_dput;
@@ -3021,40 +3022,40 @@ retry_lookup:
nd->flags |= LOOKUP_JUMPED;
BUG_ON(nd->flags & LOOKUP_RCU);
- inode = path->dentry->d_inode;
+ inode = path.dentry->d_inode;
finish_lookup:
/* we _can_ be in RCU mode here */
error = -ENOENT;
- if (d_is_negative(path->dentry)) {
- path_to_nameidata(path, nd);
+ if (d_is_negative(path.dentry)) {
+ path_to_nameidata(&path, nd);
goto out;
}
- 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 (unlikely(nd->path.mnt != path->mnt ||
- unlazy_walk(nd, path->dentry))) {
+ if (unlikely(nd->path.mnt != path.mnt ||
+ unlazy_walk(nd, path.dentry))) {
error = -ECHILD;
goto out;
}
}
- BUG_ON(inode != path->dentry->d_inode);
- nd->link = *path;
+ BUG_ON(inode != path.dentry->d_inode);
+ nd->link = path;
return 1;
}
- if (unlikely(d_is_symlink(path->dentry)) && !(open_flag & O_PATH)) {
- path_to_nameidata(path, nd);
+ if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
+ path_to_nameidata(&path, nd);
error = -ELOOP;
goto out;
}
- if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) {
- path_to_nameidata(path, nd);
+ if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) {
+ path_to_nameidata(&path, nd);
} else {
save_parent.dentry = nd->path.dentry;
- save_parent.mnt = mntget(path->mnt);
- nd->path.dentry = path->dentry;
+ save_parent.mnt = mntget(path.mnt);
+ nd->path.dentry = path.dentry;
}
nd->inode = inode;
@@ -3116,7 +3117,7 @@ out:
return error;
exit_dput:
- path_put_conditional(path, nd);
+ path_put_conditional(&path, nd);
goto out;
exit_fput:
fput(file);
@@ -3207,7 +3208,6 @@ static struct file *path_openat(int dfd, struct filename *pathname,
struct nameidata *nd, const struct open_flags *op, int flags)
{
struct file *file;
- struct path path;
int opened = 0;
int error;
@@ -3226,7 +3226,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
if (unlikely(error))
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 */
struct path link = nd->link;
void *cookie;
@@ -3238,7 +3238,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
error = follow_link(&link, nd, &cookie);
if (unlikely(error))
break;
- error = do_last(nd, &path, file, op, &opened, pathname);
+ error = do_last(nd, file, op, &opened, pathname);
put_link(nd, &link, cookie);
}
out:
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/