aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/anon_inodes.c10
-rw-r--r--fs/namei.c2
-rw-r--r--fs/open.c2
-rw-r--r--include/linux/fs.h3
-rw-r--r--kernel/auditsc.c1
-rw-r--r--security/tomoyo/file.c1
6 files changed, 5 insertions, 14 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 598237e97221..9f0bf13291e5 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -89,19 +89,11 @@ struct file *anon_inode_getfile(const char *name,
89 struct qstr this; 89 struct qstr this;
90 struct path path; 90 struct path path;
91 struct file *file; 91 struct file *file;
92 fmode_t mode;
93 int error; 92 int error;
94 93
95 if (IS_ERR(anon_inode_inode)) 94 if (IS_ERR(anon_inode_inode))
96 return ERR_PTR(-ENODEV); 95 return ERR_PTR(-ENODEV);
97 96
98 switch (flags & O_ACCMODE) {
99 case O_RDONLY: mode = FMODE_READ; break;
100 case O_WRONLY: mode = FMODE_WRITE; break;
101 case O_RDWR: mode = FMODE_READ | FMODE_WRITE; break;
102 default: return ERR_PTR(-EINVAL);
103 }
104
105 if (fops->owner && !try_module_get(fops->owner)) 97 if (fops->owner && !try_module_get(fops->owner))
106 return ERR_PTR(-ENOENT); 98 return ERR_PTR(-ENOENT);
107 99
@@ -129,7 +121,7 @@ struct file *anon_inode_getfile(const char *name,
129 d_instantiate(path.dentry, anon_inode_inode); 121 d_instantiate(path.dentry, anon_inode_inode);
130 122
131 error = -ENFILE; 123 error = -ENFILE;
132 file = alloc_file(&path, mode, fops); 124 file = alloc_file(&path, OPEN_FMODE(flags), fops);
133 if (!file) 125 if (!file)
134 goto err_dput; 126 goto err_dput;
135 file->f_mapping = anon_inode_inode->i_mapping; 127 file->f_mapping = anon_inode_inode->i_mapping;
diff --git a/fs/namei.c b/fs/namei.c
index d517f73aa36b..68921d9b5302 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -37,8 +37,6 @@
37 37
38#include "internal.h" 38#include "internal.h"
39 39
40#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
41
42/* [Feb-1997 T. Schoebel-Theuer] 40/* [Feb-1997 T. Schoebel-Theuer]
43 * Fundamental changes in the pathname lookup mechanisms (namei) 41 * Fundamental changes in the pathname lookup mechanisms (namei)
44 * were necessary because of omirr. The reason is that omirr needs 42 * were necessary because of omirr. The reason is that omirr needs
diff --git a/fs/open.c b/fs/open.c
index 6daee28f6e8f..040cef72bc00 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -828,7 +828,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
828 struct inode *inode; 828 struct inode *inode;
829 int error; 829 int error;
830 830
831 f->f_mode = (__force fmode_t)((f->f_flags+1) & O_ACCMODE) | FMODE_LSEEK | 831 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
832 FMODE_PREAD | FMODE_PWRITE; 832 FMODE_PREAD | FMODE_PWRITE;
833 inode = dentry->d_inode; 833 inode = dentry->d_inode;
834 if (f->f_mode & FMODE_WRITE) { 834 if (f->f_mode & FMODE_WRITE) {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cca191933ff6..9e13b533aaef 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2464,5 +2464,8 @@ int proc_nr_files(struct ctl_table *table, int write,
2464 2464
2465int __init get_filesystem_list(char *buf); 2465int __init get_filesystem_list(char *buf);
2466 2466
2467#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
2468#define OPEN_FMODE(flag) ((__force fmode_t)((flag + 1) & O_ACCMODE))
2469
2467#endif /* __KERNEL__ */ 2470#endif /* __KERNEL__ */
2468#endif /* _LINUX_FS_H */ 2471#endif /* _LINUX_FS_H */
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 267e484f0198..fc0f928167e7 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -250,7 +250,6 @@ struct audit_context {
250#endif 250#endif
251}; 251};
252 252
253#define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE])
254static inline int open_arg(int flags, int mask) 253static inline int open_arg(int flags, int mask)
255{ 254{
256 int n = ACC_MODE(flags); 255 int n = ACC_MODE(flags);
diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c
index 8346938809b1..9a6c58881c0a 100644
--- a/security/tomoyo/file.c
+++ b/security/tomoyo/file.c
@@ -12,7 +12,6 @@
12#include "common.h" 12#include "common.h"
13#include "tomoyo.h" 13#include "tomoyo.h"
14#include "realpath.h" 14#include "realpath.h"
15#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
16 15
17/* 16/*
18 * tomoyo_globally_readable_file_entry is a structure which is used for holding 17 * tomoyo_globally_readable_file_entry is a structure which is used for holding