summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-22 04:40:19 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:33:39 -0400
commit30d904947459cca2beb69e0110716f5248b31f2a (patch)
tree024e2a913266377d234147b14b7eb37017546173 /fs/namei.c
parenta4a3bdd778715999ddfeefdc52ab76254580fa76 (diff)
kill struct opendata
Just pass struct file *. Methods are happier that way... There's no need to return struct file * from finish_open() now, so let it return int. Next: saner prototypes for parts in namei.c Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/fs/namei.c b/fs/namei.c
index af83ede92a4f..aaff8a862151 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2194,7 +2194,7 @@ static int may_o_create(struct path *dir, struct dentry *dentry, umode_t mode)
2194} 2194}
2195 2195
2196static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry, 2196static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
2197 struct path *path, struct opendata *od, 2197 struct path *path, struct file *file,
2198 const struct open_flags *op, 2198 const struct open_flags *op,
2199 bool *want_write, bool need_lookup, 2199 bool *want_write, bool need_lookup,
2200 int *opened) 2200 int *opened)
@@ -2269,9 +2269,9 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
2269 if (nd->flags & LOOKUP_DIRECTORY) 2269 if (nd->flags & LOOKUP_DIRECTORY)
2270 open_flag |= O_DIRECTORY; 2270 open_flag |= O_DIRECTORY;
2271 2271
2272 od->filp->f_path.dentry = DENTRY_NOT_SET; 2272 file->f_path.dentry = DENTRY_NOT_SET;
2273 od->filp->f_path.mnt = nd->path.mnt; 2273 file->f_path.mnt = nd->path.mnt;
2274 error = dir->i_op->atomic_open(dir, dentry, od, open_flag, mode, 2274 error = dir->i_op->atomic_open(dir, dentry, file, open_flag, mode,
2275 opened); 2275 opened);
2276 if (error < 0) { 2276 if (error < 0) {
2277 if (create_error && error == -ENOENT) 2277 if (create_error && error == -ENOENT)
@@ -2287,13 +2287,13 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
2287 } 2287 }
2288 2288
2289 if (error) { /* returned 1, that is */ 2289 if (error) { /* returned 1, that is */
2290 if (WARN_ON(od->filp->f_path.dentry == DENTRY_NOT_SET)) { 2290 if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) {
2291 filp = ERR_PTR(-EIO); 2291 filp = ERR_PTR(-EIO);
2292 goto out; 2292 goto out;
2293 } 2293 }
2294 if (od->filp->f_path.dentry) { 2294 if (file->f_path.dentry) {
2295 dput(dentry); 2295 dput(dentry);
2296 dentry = od->filp->f_path.dentry; 2296 dentry = file->f_path.dentry;
2297 } 2297 }
2298 goto looked_up; 2298 goto looked_up;
2299 } 2299 }
@@ -2302,7 +2302,7 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
2302 * We didn't have the inode before the open, so check open permission 2302 * We didn't have the inode before the open, so check open permission
2303 * here. 2303 * here.
2304 */ 2304 */
2305 filp = od->filp; 2305 filp = file;
2306 error = may_open(&filp->f_path, acc_mode, open_flag); 2306 error = may_open(&filp->f_path, acc_mode, open_flag);
2307 if (error) { 2307 if (error) {
2308 fput(filp); 2308 fput(filp);
@@ -2350,7 +2350,7 @@ looked_up:
2350 * was performed, only lookup. 2350 * was performed, only lookup.
2351 */ 2351 */
2352static struct file *lookup_open(struct nameidata *nd, struct path *path, 2352static struct file *lookup_open(struct nameidata *nd, struct path *path,
2353 struct opendata *od, 2353 struct file *file,
2354 const struct open_flags *op, 2354 const struct open_flags *op,
2355 bool *want_write, int *opened) 2355 bool *want_write, int *opened)
2356{ 2356{
@@ -2370,7 +2370,7 @@ static struct file *lookup_open(struct nameidata *nd, struct path *path,
2370 goto out_no_open; 2370 goto out_no_open;
2371 2371
2372 if ((nd->flags & LOOKUP_OPEN) && dir_inode->i_op->atomic_open) { 2372 if ((nd->flags & LOOKUP_OPEN) && dir_inode->i_op->atomic_open) {
2373 return atomic_open(nd, dentry, path, od, op, want_write, 2373 return atomic_open(nd, dentry, path, file, op, want_write,
2374 need_lookup, opened); 2374 need_lookup, opened);
2375 } 2375 }
2376 2376
@@ -2420,7 +2420,7 @@ out_dput:
2420 * Handle the last step of open() 2420 * Handle the last step of open()
2421 */ 2421 */
2422static struct file *do_last(struct nameidata *nd, struct path *path, 2422static struct file *do_last(struct nameidata *nd, struct path *path,
2423 struct opendata *od, const struct open_flags *op, 2423 struct file *file, const struct open_flags *op,
2424 int *opened, const char *pathname) 2424 int *opened, const char *pathname)
2425{ 2425{
2426 struct dentry *dir = nd->path.dentry; 2426 struct dentry *dir = nd->path.dentry;
@@ -2497,7 +2497,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
2497 2497
2498retry_lookup: 2498retry_lookup:
2499 mutex_lock(&dir->d_inode->i_mutex); 2499 mutex_lock(&dir->d_inode->i_mutex);
2500 filp = lookup_open(nd, path, od, op, &want_write, opened); 2500 filp = lookup_open(nd, path, file, op, &want_write, opened);
2501 mutex_unlock(&dir->d_inode->i_mutex); 2501 mutex_unlock(&dir->d_inode->i_mutex);
2502 2502
2503 if (filp) { 2503 if (filp) {
@@ -2604,13 +2604,15 @@ finish_open_created:
2604 error = may_open(&nd->path, acc_mode, open_flag); 2604 error = may_open(&nd->path, acc_mode, open_flag);
2605 if (error) 2605 if (error)
2606 goto exit; 2606 goto exit;
2607 od->filp->f_path.mnt = nd->path.mnt; 2607 file->f_path.mnt = nd->path.mnt;
2608 filp = finish_open(od, nd->path.dentry, NULL, opened); 2608 error = finish_open(file, nd->path.dentry, NULL, opened);
2609 if (IS_ERR(filp)) { 2609 if (error) {
2610 if (filp == ERR_PTR(-EOPENSTALE)) 2610 filp = ERR_PTR(error);
2611 if (error == -EOPENSTALE)
2611 goto stale_open; 2612 goto stale_open;
2612 goto out; 2613 goto out;
2613 } 2614 }
2615 filp = file;
2614opened: 2616opened:
2615 error = open_check_o_direct(filp); 2617 error = open_check_o_direct(filp);
2616 if (error) 2618 if (error)
@@ -2663,17 +2665,17 @@ static struct file *path_openat(int dfd, const char *pathname,
2663 struct nameidata *nd, const struct open_flags *op, int flags) 2665 struct nameidata *nd, const struct open_flags *op, int flags)
2664{ 2666{
2665 struct file *base = NULL; 2667 struct file *base = NULL;
2666 struct opendata od; 2668 struct file *file;
2667 struct file *res; 2669 struct file *res;
2668 struct path path; 2670 struct path path;
2669 int opened = 0; 2671 int opened = 0;
2670 int error; 2672 int error;
2671 2673
2672 od.filp = get_empty_filp(); 2674 file = get_empty_filp();
2673 if (!od.filp) 2675 if (!file)
2674 return ERR_PTR(-ENFILE); 2676 return ERR_PTR(-ENFILE);
2675 2677
2676 od.filp->f_flags = op->open_flag; 2678 file->f_flags = op->open_flag;
2677 2679
2678 error = path_init(dfd, pathname, flags | LOOKUP_PARENT, nd, &base); 2680 error = path_init(dfd, pathname, flags | LOOKUP_PARENT, nd, &base);
2679 if (unlikely(error)) 2681 if (unlikely(error))
@@ -2684,7 +2686,7 @@ static struct file *path_openat(int dfd, const char *pathname,
2684 if (unlikely(error)) 2686 if (unlikely(error))
2685 goto out_filp; 2687 goto out_filp;
2686 2688
2687 res = do_last(nd, &path, &od, op, &opened, pathname); 2689 res = do_last(nd, &path, file, op, &opened, pathname);
2688 while (unlikely(!res)) { /* trailing symlink */ 2690 while (unlikely(!res)) { /* trailing symlink */
2689 struct path link = path; 2691 struct path link = path;
2690 void *cookie; 2692 void *cookie;
@@ -2699,7 +2701,7 @@ static struct file *path_openat(int dfd, const char *pathname,
2699 error = follow_link(&link, nd, &cookie); 2701 error = follow_link(&link, nd, &cookie);
2700 if (unlikely(error)) 2702 if (unlikely(error))
2701 goto out_filp; 2703 goto out_filp;
2702 res = do_last(nd, &path, &od, op, &opened, pathname); 2704 res = do_last(nd, &path, file, op, &opened, pathname);
2703 put_link(nd, &link, cookie); 2705 put_link(nd, &link, cookie);
2704 } 2706 }
2705out: 2707out:
@@ -2708,7 +2710,7 @@ out:
2708 if (base) 2710 if (base)
2709 fput(base); 2711 fput(base);
2710 if (!(opened & FILE_OPENED)) 2712 if (!(opened & FILE_OPENED))
2711 put_filp(od.filp); 2713 put_filp(file);
2712 if (res == ERR_PTR(-EOPENSTALE)) { 2714 if (res == ERR_PTR(-EOPENSTALE)) {
2713 if (flags & LOOKUP_RCU) 2715 if (flags & LOOKUP_RCU)
2714 res = ERR_PTR(-ECHILD); 2716 res = ERR_PTR(-ECHILD);