aboutsummaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-01 02:55:20 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-01 02:55:20 -0500
commit35858adbfca13678af99fb31618ef4428d6dedb0 (patch)
tree3336feaa61324486945816cb52c347733e7c0821 /fs/open.c
parent197d4db752e67160d79fed09968c2140376a80a3 (diff)
parent4b70858ba8d4537daf782defebe5f2ff80ccef2b (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/open.c b/fs/open.c
index b4b31d277f3a..040cef72bc00 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -30,6 +30,9 @@
30#include <linux/audit.h> 30#include <linux/audit.h>
31#include <linux/falloc.h> 31#include <linux/falloc.h>
32#include <linux/fs_struct.h> 32#include <linux/fs_struct.h>
33#include <linux/ima.h>
34
35#include "internal.h"
33 36
34int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) 37int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
35{ 38{
@@ -818,15 +821,14 @@ static inline int __get_file_write_access(struct inode *inode,
818} 821}
819 822
820static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, 823static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
821 int flags, struct file *f, 824 struct file *f,
822 int (*open)(struct inode *, struct file *), 825 int (*open)(struct inode *, struct file *),
823 const struct cred *cred) 826 const struct cred *cred)
824{ 827{
825 struct inode *inode; 828 struct inode *inode;
826 int error; 829 int error;
827 830
828 f->f_flags = flags; 831 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
829 f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | FMODE_LSEEK |
830 FMODE_PREAD | FMODE_PWRITE; 832 FMODE_PREAD | FMODE_PWRITE;
831 inode = dentry->d_inode; 833 inode = dentry->d_inode;
832 if (f->f_mode & FMODE_WRITE) { 834 if (f->f_mode & FMODE_WRITE) {
@@ -855,6 +857,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
855 if (error) 857 if (error)
856 goto cleanup_all; 858 goto cleanup_all;
857 } 859 }
860 ima_counts_get(f);
858 861
859 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); 862 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
860 863
@@ -926,7 +929,6 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry
926 if (IS_ERR(dentry)) 929 if (IS_ERR(dentry))
927 goto out_err; 930 goto out_err;
928 nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt), 931 nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt),
929 nd->intent.open.flags - 1,
930 nd->intent.open.file, 932 nd->intent.open.file,
931 open, cred); 933 open, cred);
932out: 934out:
@@ -945,7 +947,7 @@ EXPORT_SYMBOL_GPL(lookup_instantiate_filp);
945 * 947 *
946 * Note that this function destroys the original nameidata 948 * Note that this function destroys the original nameidata
947 */ 949 */
948struct file *nameidata_to_filp(struct nameidata *nd, int flags) 950struct file *nameidata_to_filp(struct nameidata *nd)
949{ 951{
950 const struct cred *cred = current_cred(); 952 const struct cred *cred = current_cred();
951 struct file *filp; 953 struct file *filp;
@@ -954,7 +956,7 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
954 filp = nd->intent.open.file; 956 filp = nd->intent.open.file;
955 /* Has the filesystem initialised the file for us? */ 957 /* Has the filesystem initialised the file for us? */
956 if (filp->f_path.dentry == NULL) 958 if (filp->f_path.dentry == NULL)
957 filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp, 959 filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp,
958 NULL, cred); 960 NULL, cred);
959 else 961 else
960 path_put(&nd->path); 962 path_put(&nd->path);
@@ -993,7 +995,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags,
993 return ERR_PTR(error); 995 return ERR_PTR(error);
994 } 996 }
995 997
996 return __dentry_open(dentry, mnt, flags, f, NULL, cred); 998 f->f_flags = flags;
999 return __dentry_open(dentry, mnt, f, NULL, cred);
997} 1000}
998EXPORT_SYMBOL(dentry_open); 1001EXPORT_SYMBOL(dentry_open);
999 1002