aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-22 18:02:17 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-05-10 22:19:52 -0400
commit896475d5bd2ee5d094239ff77801089ae25bcbc1 (patch)
tree7715b57a8e0e03427948a3f7496f34a12d7946cd /fs/namei.c
parentcaa8563443539895fc6654b996c68d5e8048b86e (diff)
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: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 06c3e4a6c440..858290768d92 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2911,7 +2911,7 @@ out_dput:
2911/* 2911/*
2912 * Handle the last step of open() 2912 * Handle the last step of open()
2913 */ 2913 */
2914static int do_last(struct nameidata *nd, struct path *path, 2914static int do_last(struct nameidata *nd,
2915 struct file *file, const struct open_flags *op, 2915 struct file *file, const struct open_flags *op,
2916 int *opened, struct filename *name) 2916 int *opened, struct filename *name)
2917{ 2917{
@@ -2922,6 +2922,7 @@ static int do_last(struct nameidata *nd, struct path *path,
2922 int acc_mode = op->acc_mode; 2922 int acc_mode = op->acc_mode;
2923 struct inode *inode; 2923 struct inode *inode;
2924 struct path save_parent = { .dentry = NULL, .mnt = NULL }; 2924 struct path save_parent = { .dentry = NULL, .mnt = NULL };
2925 struct path path;
2925 bool retried = false; 2926 bool retried = false;
2926 int error; 2927 int error;
2927 2928
@@ -2939,7 +2940,7 @@ static int do_last(struct nameidata *nd, struct path *path,
2939 if (nd->last.name[nd->last.len]) 2940 if (nd->last.name[nd->last.len])
2940 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; 2941 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
2941 /* we _can_ be in RCU mode here */ 2942 /* we _can_ be in RCU mode here */
2942 error = lookup_fast(nd, path, &inode); 2943 error = lookup_fast(nd, &path, &inode);
2943 if (likely(!error)) 2944 if (likely(!error))
2944 goto finish_lookup; 2945 goto finish_lookup;
2945 2946
@@ -2977,7 +2978,7 @@ retry_lookup:
2977 */ 2978 */
2978 } 2979 }
2979 mutex_lock(&dir->d_inode->i_mutex); 2980 mutex_lock(&dir->d_inode->i_mutex);
2980 error = lookup_open(nd, path, file, op, got_write, opened); 2981 error = lookup_open(nd, &path, file, op, got_write, opened);
2981 mutex_unlock(&dir->d_inode->i_mutex); 2982 mutex_unlock(&dir->d_inode->i_mutex);
2982 2983
2983 if (error <= 0) { 2984 if (error <= 0) {
@@ -2997,15 +2998,15 @@ retry_lookup:
2997 open_flag &= ~O_TRUNC; 2998 open_flag &= ~O_TRUNC;
2998 will_truncate = false; 2999 will_truncate = false;
2999 acc_mode = MAY_OPEN; 3000 acc_mode = MAY_OPEN;
3000 path_to_nameidata(path, nd); 3001 path_to_nameidata(&path, nd);
3001 goto finish_open_created; 3002 goto finish_open_created;
3002 } 3003 }
3003 3004
3004 /* 3005 /*
3005 * create/update audit record if it already exists. 3006 * create/update audit record if it already exists.
3006 */ 3007 */
3007 if (d_is_positive(path->dentry)) 3008 if (d_is_positive(path.dentry))
3008 audit_inode(name, path->dentry, 0); 3009 audit_inode(name, path.dentry, 0);
3009 3010
3010 /* 3011 /*
3011 * If atomic_open() acquired write access it is dropped now due to 3012 * If atomic_open() acquired write access it is dropped now due to
@@ -3021,7 +3022,7 @@ retry_lookup:
3021 if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) 3022 if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))
3022 goto exit_dput; 3023 goto exit_dput;
3023 3024
3024 error = follow_managed(path, nd->flags); 3025 error = follow_managed(&path, nd->flags);
3025 if (error < 0) 3026 if (error < 0)
3026 goto exit_dput; 3027 goto exit_dput;
3027 3028
@@ -3029,38 +3030,38 @@ retry_lookup:
3029 nd->flags |= LOOKUP_JUMPED; 3030 nd->flags |= LOOKUP_JUMPED;
3030 3031
3031 BUG_ON(nd->flags & LOOKUP_RCU); 3032 BUG_ON(nd->flags & LOOKUP_RCU);
3032 inode = path->dentry->d_inode; 3033 inode = path.dentry->d_inode;
3033 error = -ENOENT; 3034 error = -ENOENT;
3034 if (d_is_negative(path->dentry)) { 3035 if (d_is_negative(path.dentry)) {
3035 path_to_nameidata(path, nd); 3036 path_to_nameidata(&path, nd);
3036 goto out; 3037 goto out;
3037 } 3038 }
3038finish_lookup: 3039finish_lookup:
3039 if (should_follow_link(path->dentry, nd->flags & LOOKUP_FOLLOW)) { 3040 if (should_follow_link(path.dentry, nd->flags & LOOKUP_FOLLOW)) {
3040 if (nd->flags & LOOKUP_RCU) { 3041 if (nd->flags & LOOKUP_RCU) {
3041 if (unlikely(nd->path.mnt != path->mnt || 3042 if (unlikely(nd->path.mnt != path.mnt ||
3042 unlazy_walk(nd, path->dentry))) { 3043 unlazy_walk(nd, path.dentry))) {
3043 error = -ECHILD; 3044 error = -ECHILD;
3044 goto out; 3045 goto out;
3045 } 3046 }
3046 } 3047 }
3047 BUG_ON(inode != path->dentry->d_inode); 3048 BUG_ON(inode != path.dentry->d_inode);
3048 nd->link = *path; 3049 nd->link = path;
3049 return 1; 3050 return 1;
3050 } 3051 }
3051 3052
3052 if (unlikely(d_is_symlink(path->dentry)) && !(open_flag & O_PATH)) { 3053 if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
3053 path_to_nameidata(path, nd); 3054 path_to_nameidata(&path, nd);
3054 error = -ELOOP; 3055 error = -ELOOP;
3055 goto out; 3056 goto out;
3056 } 3057 }
3057 3058
3058 if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { 3059 if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) {
3059 path_to_nameidata(path, nd); 3060 path_to_nameidata(&path, nd);
3060 } else { 3061 } else {
3061 save_parent.dentry = nd->path.dentry; 3062 save_parent.dentry = nd->path.dentry;
3062 save_parent.mnt = mntget(path->mnt); 3063 save_parent.mnt = mntget(path.mnt);
3063 nd->path.dentry = path->dentry; 3064 nd->path.dentry = path.dentry;
3064 3065
3065 } 3066 }
3066 nd->inode = inode; 3067 nd->inode = inode;
@@ -3122,7 +3123,7 @@ out:
3122 return error; 3123 return error;
3123 3124
3124exit_dput: 3125exit_dput:
3125 path_put_conditional(path, nd); 3126 path_put_conditional(&path, nd);
3126 goto out; 3127 goto out;
3127exit_fput: 3128exit_fput:
3128 fput(file); 3129 fput(file);
@@ -3213,7 +3214,6 @@ static struct file *path_openat(int dfd, struct filename *pathname,
3213 struct nameidata *nd, const struct open_flags *op, int flags) 3214 struct nameidata *nd, const struct open_flags *op, int flags)
3214{ 3215{
3215 struct file *file; 3216 struct file *file;
3216 struct path path;
3217 int opened = 0; 3217 int opened = 0;
3218 int error; 3218 int error;
3219 3219
@@ -3232,7 +3232,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
3232 if (unlikely(error)) 3232 if (unlikely(error))
3233 goto out; 3233 goto out;
3234 3234
3235 error = do_last(nd, &path, file, op, &opened, pathname); 3235 error = do_last(nd, file, op, &opened, pathname);
3236 while (unlikely(error > 0)) { /* trailing symlink */ 3236 while (unlikely(error > 0)) { /* trailing symlink */
3237 struct path link = nd->link; 3237 struct path link = nd->link;
3238 void *cookie; 3238 void *cookie;
@@ -3244,7 +3244,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
3244 error = follow_link(&link, nd, &cookie); 3244 error = follow_link(&link, nd, &cookie);
3245 if (unlikely(error)) 3245 if (unlikely(error))
3246 break; 3246 break;
3247 error = do_last(nd, &path, file, op, &opened, pathname); 3247 error = do_last(nd, file, op, &opened, pathname);
3248 put_link(nd, &link, cookie); 3248 put_link(nd, &link, cookie);
3249 } 3249 }
3250out: 3250out: