aboutsummaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/fs/open.c b/fs/open.c
index 9b33c0cbfacf..62f907e3bc36 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -228,7 +228,7 @@ SYSCALL_ALIAS(sys_ftruncate64, SyS_ftruncate64);
228 228
229int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 229int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
230{ 230{
231 struct inode *inode = file->f_path.dentry->d_inode; 231 struct inode *inode = file_inode(file);
232 long ret; 232 long ret;
233 233
234 if (offset < 0 || len <= 0) 234 if (offset < 0 || len <= 0)
@@ -426,7 +426,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
426 if (!f.file) 426 if (!f.file)
427 goto out; 427 goto out;
428 428
429 inode = f.file->f_path.dentry->d_inode; 429 inode = file_inode(f.file);
430 430
431 error = -ENOTDIR; 431 error = -ENOTDIR;
432 if (!S_ISDIR(inode->i_mode)) 432 if (!S_ISDIR(inode->i_mode))
@@ -689,7 +689,7 @@ static int do_dentry_open(struct file *f,
689 f->f_mode = FMODE_PATH; 689 f->f_mode = FMODE_PATH;
690 690
691 path_get(&f->f_path); 691 path_get(&f->f_path);
692 inode = f->f_path.dentry->d_inode; 692 inode = file_inode(f);
693 if (f->f_mode & FMODE_WRITE) { 693 if (f->f_mode & FMODE_WRITE) {
694 error = __get_file_write_access(inode, f->f_path.mnt); 694 error = __get_file_write_access(inode, f->f_path.mnt);
695 if (error) 695 if (error)
@@ -699,7 +699,6 @@ static int do_dentry_open(struct file *f,
699 } 699 }
700 700
701 f->f_mapping = inode->i_mapping; 701 f->f_mapping = inode->i_mapping;
702 f->f_pos = 0;
703 file_sb_list_add(f, inode->i_sb); 702 file_sb_list_add(f, inode->i_sb);
704 703
705 if (unlikely(f->f_mode & FMODE_PATH)) { 704 if (unlikely(f->f_mode & FMODE_PATH)) {
@@ -810,23 +809,22 @@ struct file *dentry_open(const struct path *path, int flags,
810 /* We must always pass in a valid mount pointer. */ 809 /* We must always pass in a valid mount pointer. */
811 BUG_ON(!path->mnt); 810 BUG_ON(!path->mnt);
812 811
813 error = -ENFILE;
814 f = get_empty_filp(); 812 f = get_empty_filp();
815 if (f == NULL) 813 if (!IS_ERR(f)) {
816 return ERR_PTR(error); 814 f->f_flags = flags;
817 815 f->f_path = *path;
818 f->f_flags = flags; 816 error = do_dentry_open(f, NULL, cred);
819 f->f_path = *path; 817 if (!error) {
820 error = do_dentry_open(f, NULL, cred); 818 /* from now on we need fput() to dispose of f */
821 if (!error) { 819 error = open_check_o_direct(f);
822 error = open_check_o_direct(f); 820 if (error) {
823 if (error) { 821 fput(f);
824 fput(f); 822 f = ERR_PTR(error);
823 }
824 } else {
825 put_filp(f);
825 f = ERR_PTR(error); 826 f = ERR_PTR(error);
826 } 827 }
827 } else {
828 put_filp(f);
829 f = ERR_PTR(error);
830 } 828 }
831 return f; 829 return f;
832} 830}