aboutsummaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-10 14:32:45 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:33:54 -0400
commit02e5180d991f203441687cecd0b7e6a2ba0a34d3 (patch)
tree8699773ec227a8cbbe543b780f55df0ee45bcaea /fs/open.c
parent2a027e7a1873812240cbdac0f55c4734ff0042a5 (diff)
do_dentry_open(): take initialization of file->f_path to caller
... and get rid of a couple of arguments and a pointless reassignment in finish_open() case. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/open.c b/fs/open.c
index 28fbacbd5e3..124ccb1d38a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -667,8 +667,7 @@ int open_check_o_direct(struct file *f)
667 return 0; 667 return 0;
668} 668}
669 669
670static int do_dentry_open(struct dentry *dentry, struct vfsmount *mnt, 670static int do_dentry_open(struct file *f,
671 struct file *f,
672 int (*open)(struct inode *, struct file *), 671 int (*open)(struct inode *, struct file *),
673 const struct cred *cred) 672 const struct cred *cred)
674{ 673{
@@ -682,9 +681,9 @@ static int do_dentry_open(struct dentry *dentry, struct vfsmount *mnt,
682 if (unlikely(f->f_flags & O_PATH)) 681 if (unlikely(f->f_flags & O_PATH))
683 f->f_mode = FMODE_PATH; 682 f->f_mode = FMODE_PATH;
684 683
685 inode = dentry->d_inode; 684 inode = f->f_path.dentry->d_inode;
686 if (f->f_mode & FMODE_WRITE) { 685 if (f->f_mode & FMODE_WRITE) {
687 error = __get_file_write_access(inode, mnt); 686 error = __get_file_write_access(inode, f->f_path.mnt);
688 if (error) 687 if (error)
689 goto cleanup_file; 688 goto cleanup_file;
690 if (!special_file(inode->i_mode)) 689 if (!special_file(inode->i_mode))
@@ -692,8 +691,6 @@ static int do_dentry_open(struct dentry *dentry, struct vfsmount *mnt,
692 } 691 }
693 692
694 f->f_mapping = inode->i_mapping; 693 f->f_mapping = inode->i_mapping;
695 f->f_path.dentry = dentry;
696 f->f_path.mnt = mnt;
697 f->f_pos = 0; 694 f->f_pos = 0;
698 file_sb_list_add(f, inode->i_sb); 695 file_sb_list_add(f, inode->i_sb);
699 696
@@ -740,15 +737,14 @@ cleanup_all:
740 * here, so just reset the state. 737 * here, so just reset the state.
741 */ 738 */
742 file_reset_write(f); 739 file_reset_write(f);
743 mnt_drop_write(mnt); 740 mnt_drop_write(f->f_path.mnt);
744 } 741 }
745 } 742 }
746 file_sb_list_del(f); 743 file_sb_list_del(f);
747 f->f_path.dentry = NULL;
748 f->f_path.mnt = NULL;
749cleanup_file: 744cleanup_file:
750 dput(dentry); 745 path_put(&f->f_path);
751 mntput(mnt); 746 f->f_path.mnt = NULL;
747 f->f_path.dentry = NULL;
752 return error; 748 return error;
753} 749}
754 750
@@ -771,9 +767,9 @@ int finish_open(struct file *file, struct dentry *dentry,
771 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ 767 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
772 768
773 mntget(file->f_path.mnt); 769 mntget(file->f_path.mnt);
774 dget(dentry); 770 file->f_path.dentry = dget(dentry);
775 771
776 error = do_dentry_open(dentry, file->f_path.mnt, file, open, current_cred()); 772 error = do_dentry_open(file, open, current_cred());
777 if (!error) 773 if (!error)
778 *opened |= FILE_OPENED; 774 *opened |= FILE_OPENED;
779 775
@@ -821,7 +817,9 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags,
821 } 817 }
822 818
823 f->f_flags = flags; 819 f->f_flags = flags;
824 error = do_dentry_open(dentry, mnt, f, NULL, cred); 820 f->f_path.mnt = mnt;
821 f->f_path.dentry = dentry;
822 error = do_dentry_open(f, NULL, cred);
825 if (!error) { 823 if (!error) {
826 error = open_check_o_direct(f); 824 error = open_check_o_direct(f);
827 if (error) { 825 if (error) {