aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/pohmelfs/dir.c2
-rw-r--r--fs/anon_inodes.c4
-rw-r--r--fs/compat_ioctl.c2
-rw-r--r--fs/eventfd.c2
-rw-r--r--fs/eventpoll.c2
-rw-r--r--fs/file_table.c4
-rw-r--r--fs/internal.h7
-rw-r--r--fs/jfs/super.c2
-rw-r--r--fs/namei.c8
-rw-r--r--fs/open.c13
-rw-r--r--fs/signalfd.c2
-rw-r--r--fs/timerfd.c2
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/namei.h2
-rw-r--r--kernel/auditsc.c1
-rw-r--r--kernel/perf_event.c2
-rw-r--r--security/tomoyo/file.c1
-rw-r--r--virt/kvm/kvm_main.c4
18 files changed, 31 insertions, 34 deletions
diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c
index 6c5b261e9f06..aacd25bfb0cb 100644
--- a/drivers/staging/pohmelfs/dir.c
+++ b/drivers/staging/pohmelfs/dir.c
@@ -722,8 +722,6 @@ static int pohmelfs_remove_entry(struct inode *dir, struct dentry *dentry)
722 if (inode->i_nlink) 722 if (inode->i_nlink)
723 inode_dec_link_count(inode); 723 inode_dec_link_count(inode);
724 } 724 }
725 dprintk("%s: inode: %p, lock: %ld, unhashed: %d.\n",
726 __func__, pi, inode->i_state & I_LOCK, hlist_unhashed(&inode->i_hash));
727 725
728 return err; 726 return err;
729} 727}
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 2c994591f4d7..9f0bf13291e5 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -121,13 +121,13 @@ struct file *anon_inode_getfile(const char *name,
121 d_instantiate(path.dentry, anon_inode_inode); 121 d_instantiate(path.dentry, anon_inode_inode);
122 122
123 error = -ENFILE; 123 error = -ENFILE;
124 file = alloc_file(&path, FMODE_READ | FMODE_WRITE, fops); 124 file = alloc_file(&path, OPEN_FMODE(flags), fops);
125 if (!file) 125 if (!file)
126 goto err_dput; 126 goto err_dput;
127 file->f_mapping = anon_inode_inode->i_mapping; 127 file->f_mapping = anon_inode_inode->i_mapping;
128 128
129 file->f_pos = 0; 129 file->f_pos = 0;
130 file->f_flags = O_RDWR | (flags & O_NONBLOCK); 130 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
131 file->f_version = 0; 131 file->f_version = 0;
132 file->private_data = priv; 132 file->private_data = priv;
133 133
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 14cbc831422a..332dd00f0894 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1600,8 +1600,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
1600 case KDSKBMETA: 1600 case KDSKBMETA:
1601 case KDSKBLED: 1601 case KDSKBLED:
1602 case KDSETLED: 1602 case KDSETLED:
1603 /* SG stuff */
1604 case SG_SET_TRANSFORM:
1605 /* AUTOFS */ 1603 /* AUTOFS */
1606 case AUTOFS_IOC_READY: 1604 case AUTOFS_IOC_READY:
1607 case AUTOFS_IOC_FAIL: 1605 case AUTOFS_IOC_FAIL:
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 8b47e4200e65..d26402ff06ea 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -339,7 +339,7 @@ struct file *eventfd_file_create(unsigned int count, int flags)
339 ctx->flags = flags; 339 ctx->flags = flags;
340 340
341 file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx, 341 file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx,
342 flags & EFD_SHARED_FCNTL_FLAGS); 342 O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS));
343 if (IS_ERR(file)) 343 if (IS_ERR(file))
344 eventfd_free_ctx(ctx); 344 eventfd_free_ctx(ctx);
345 345
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 366c503f9657..bd056a5b4efc 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1206,7 +1206,7 @@ SYSCALL_DEFINE1(epoll_create1, int, flags)
1206 * a file structure and a free file descriptor. 1206 * a file structure and a free file descriptor.
1207 */ 1207 */
1208 error = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep, 1208 error = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep,
1209 flags & O_CLOEXEC); 1209 O_RDWR | (flags & O_CLOEXEC));
1210 if (error < 0) 1210 if (error < 0)
1211 ep_free(ep); 1211 ep_free(ep);
1212 1212
diff --git a/fs/file_table.c b/fs/file_table.c
index 0afacf654398..69652c5bd5f0 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -186,10 +186,8 @@ struct file *alloc_file(struct path *path, fmode_t mode,
186 * that we can do debugging checks at __fput() 186 * that we can do debugging checks at __fput()
187 */ 187 */
188 if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) { 188 if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) {
189 int error = 0;
190 file_take_write(file); 189 file_take_write(file);
191 error = mnt_clone_write(path->mnt); 190 WARN_ON(mnt_clone_write(path->mnt));
192 WARN_ON(error);
193 } 191 }
194 ima_counts_get(file); 192 ima_counts_get(file);
195 return file; 193 return file;
diff --git a/fs/internal.h b/fs/internal.h
index f67cd141d9a8..e96a1667d749 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -85,3 +85,10 @@ extern struct file *get_empty_filp(void);
85 * super.c 85 * super.c
86 */ 86 */
87extern int do_remount_sb(struct super_block *, int, void *, int); 87extern int do_remount_sb(struct super_block *, int, void *, int);
88
89/*
90 * open.c
91 */
92struct nameidata;
93extern struct file *nameidata_to_filp(struct nameidata *);
94extern void release_open_intent(struct nameidata *);
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 2234c73fc577..d929a822a74e 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -524,7 +524,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
524 * Page cache is indexed by long. 524 * Page cache is indexed by long.
525 * I would use MAX_LFS_FILESIZE, but it's only half as big 525 * I would use MAX_LFS_FILESIZE, but it's only half as big
526 */ 526 */
527 sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, sb->s_maxbytes); 527 sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, (u64)sb->s_maxbytes);
528#endif 528#endif
529 sb->s_time_gran = 1; 529 sb->s_time_gran = 1;
530 return 0; 530 return 0;
diff --git a/fs/namei.c b/fs/namei.c
index dad4b80257db..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
@@ -1640,6 +1638,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
1640 if (filp == NULL) 1638 if (filp == NULL)
1641 return ERR_PTR(-ENFILE); 1639 return ERR_PTR(-ENFILE);
1642 nd.intent.open.file = filp; 1640 nd.intent.open.file = filp;
1641 filp->f_flags = open_flag;
1643 nd.intent.open.flags = flag; 1642 nd.intent.open.flags = flag;
1644 nd.intent.open.create_mode = 0; 1643 nd.intent.open.create_mode = 0;
1645 error = do_path_lookup(dfd, pathname, 1644 error = do_path_lookup(dfd, pathname,
@@ -1685,6 +1684,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
1685 if (filp == NULL) 1684 if (filp == NULL)
1686 goto exit_parent; 1685 goto exit_parent;
1687 nd.intent.open.file = filp; 1686 nd.intent.open.file = filp;
1687 filp->f_flags = open_flag;
1688 nd.intent.open.flags = flag; 1688 nd.intent.open.flags = flag;
1689 nd.intent.open.create_mode = mode; 1689 nd.intent.open.create_mode = mode;
1690 dir = nd.path.dentry; 1690 dir = nd.path.dentry;
@@ -1725,7 +1725,7 @@ do_last:
1725 mnt_drop_write(nd.path.mnt); 1725 mnt_drop_write(nd.path.mnt);
1726 goto exit; 1726 goto exit;
1727 } 1727 }
1728 filp = nameidata_to_filp(&nd, open_flag); 1728 filp = nameidata_to_filp(&nd);
1729 mnt_drop_write(nd.path.mnt); 1729 mnt_drop_write(nd.path.mnt);
1730 if (nd.root.mnt) 1730 if (nd.root.mnt)
1731 path_put(&nd.root); 1731 path_put(&nd.root);
@@ -1789,7 +1789,7 @@ ok:
1789 mnt_drop_write(nd.path.mnt); 1789 mnt_drop_write(nd.path.mnt);
1790 goto exit; 1790 goto exit;
1791 } 1791 }
1792 filp = nameidata_to_filp(&nd, open_flag); 1792 filp = nameidata_to_filp(&nd);
1793 if (!IS_ERR(filp)) { 1793 if (!IS_ERR(filp)) {
1794 error = ima_path_check(&filp->f_path, filp->f_mode & 1794 error = ima_path_check(&filp->f_path, filp->f_mode &
1795 (MAY_READ | MAY_WRITE | MAY_EXEC)); 1795 (MAY_READ | MAY_WRITE | MAY_EXEC));
diff --git a/fs/open.c b/fs/open.c
index ca69241796bd..040cef72bc00 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -821,15 +821,14 @@ static inline int __get_file_write_access(struct inode *inode,
821} 821}
822 822
823static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, 823static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
824 int flags, struct file *f, 824 struct file *f,
825 int (*open)(struct inode *, struct file *), 825 int (*open)(struct inode *, struct file *),
826 const struct cred *cred) 826 const struct cred *cred)
827{ 827{
828 struct inode *inode; 828 struct inode *inode;
829 int error; 829 int error;
830 830
831 f->f_flags = flags; 831 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
832 f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | FMODE_LSEEK |
833 FMODE_PREAD | FMODE_PWRITE; 832 FMODE_PREAD | FMODE_PWRITE;
834 inode = dentry->d_inode; 833 inode = dentry->d_inode;
835 if (f->f_mode & FMODE_WRITE) { 834 if (f->f_mode & FMODE_WRITE) {
@@ -930,7 +929,6 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry
930 if (IS_ERR(dentry)) 929 if (IS_ERR(dentry))
931 goto out_err; 930 goto out_err;
932 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),
933 nd->intent.open.flags - 1,
934 nd->intent.open.file, 932 nd->intent.open.file,
935 open, cred); 933 open, cred);
936out: 934out:
@@ -949,7 +947,7 @@ EXPORT_SYMBOL_GPL(lookup_instantiate_filp);
949 * 947 *
950 * Note that this function destroys the original nameidata 948 * Note that this function destroys the original nameidata
951 */ 949 */
952struct file *nameidata_to_filp(struct nameidata *nd, int flags) 950struct file *nameidata_to_filp(struct nameidata *nd)
953{ 951{
954 const struct cred *cred = current_cred(); 952 const struct cred *cred = current_cred();
955 struct file *filp; 953 struct file *filp;
@@ -958,7 +956,7 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
958 filp = nd->intent.open.file; 956 filp = nd->intent.open.file;
959 /* Has the filesystem initialised the file for us? */ 957 /* Has the filesystem initialised the file for us? */
960 if (filp->f_path.dentry == NULL) 958 if (filp->f_path.dentry == NULL)
961 filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp, 959 filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp,
962 NULL, cred); 960 NULL, cred);
963 else 961 else
964 path_put(&nd->path); 962 path_put(&nd->path);
@@ -997,7 +995,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags,
997 return ERR_PTR(error); 995 return ERR_PTR(error);
998 } 996 }
999 997
1000 return __dentry_open(dentry, mnt, flags, f, NULL, cred); 998 f->f_flags = flags;
999 return __dentry_open(dentry, mnt, f, NULL, cred);
1001} 1000}
1002EXPORT_SYMBOL(dentry_open); 1001EXPORT_SYMBOL(dentry_open);
1003 1002
diff --git a/fs/signalfd.c b/fs/signalfd.c
index b07565c94386..1dabe4ee02fe 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -236,7 +236,7 @@ SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask,
236 * anon_inode_getfd() will install the fd. 236 * anon_inode_getfd() will install the fd.
237 */ 237 */
238 ufd = anon_inode_getfd("[signalfd]", &signalfd_fops, ctx, 238 ufd = anon_inode_getfd("[signalfd]", &signalfd_fops, ctx,
239 flags & (O_CLOEXEC | O_NONBLOCK)); 239 O_RDWR | (flags & (O_CLOEXEC | O_NONBLOCK)));
240 if (ufd < 0) 240 if (ufd < 0)
241 kfree(ctx); 241 kfree(ctx);
242 } else { 242 } else {
diff --git a/fs/timerfd.c b/fs/timerfd.c
index b042bd7034b1..1bfc95ad5f71 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -200,7 +200,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
200 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); 200 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS);
201 201
202 ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, 202 ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
203 flags & TFD_SHARED_FCNTL_FLAGS); 203 O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS));
204 if (ufd < 0) 204 if (ufd < 0)
205 kfree(ctx); 205 kfree(ctx);
206 206
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cca191933ff6..7e3012e0ac06 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1624,8 +1624,6 @@ struct super_operations {
1624 * on the bit address once it is done. 1624 * on the bit address once it is done.
1625 * 1625 *
1626 * Q: What is the difference between I_WILL_FREE and I_FREEING? 1626 * Q: What is the difference between I_WILL_FREE and I_FREEING?
1627 * Q: igrab() only checks on (I_FREEING|I_WILL_FREE). Should it also check on
1628 * I_CLEAR? If not, why?
1629 */ 1627 */
1630#define I_DIRTY_SYNC 1 1628#define I_DIRTY_SYNC 1
1631#define I_DIRTY_DATASYNC 2 1629#define I_DIRTY_DATASYNC 2
@@ -2464,5 +2462,8 @@ int proc_nr_files(struct ctl_table *table, int write,
2464 2462
2465int __init get_filesystem_list(char *buf); 2463int __init get_filesystem_list(char *buf);
2466 2464
2465#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
2466#define OPEN_FMODE(flag) ((__force fmode_t)((flag + 1) & O_ACCMODE))
2467
2467#endif /* __KERNEL__ */ 2468#endif /* __KERNEL__ */
2468#endif /* _LINUX_FS_H */ 2469#endif /* _LINUX_FS_H */
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 028946750289..05b441d93642 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -72,8 +72,6 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
72 72
73extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, 73extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
74 int (*open)(struct inode *, struct file *)); 74 int (*open)(struct inode *, struct file *));
75extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
76extern void release_open_intent(struct nameidata *);
77 75
78extern struct dentry *lookup_one_len(const char *, struct dentry *, int); 76extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
79 77
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/kernel/perf_event.c b/kernel/perf_event.c
index e0eb4a2fe183..1f38270f08c7 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -4724,7 +4724,7 @@ SYSCALL_DEFINE5(perf_event_open,
4724 if (IS_ERR(event)) 4724 if (IS_ERR(event))
4725 goto err_put_context; 4725 goto err_put_context;
4726 4726
4727 err = anon_inode_getfd("[perf_event]", &perf_fops, event, 0); 4727 err = anon_inode_getfd("[perf_event]", &perf_fops, event, O_RDWR);
4728 if (err < 0) 4728 if (err < 0)
4729 goto err_free_put_context; 4729 goto err_free_put_context;
4730 4730
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
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e1f2bf8d7b1e..b5af88167613 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1177,7 +1177,7 @@ static struct file_operations kvm_vcpu_fops = {
1177 */ 1177 */
1178static int create_vcpu_fd(struct kvm_vcpu *vcpu) 1178static int create_vcpu_fd(struct kvm_vcpu *vcpu)
1179{ 1179{
1180 return anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu, 0); 1180 return anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu, O_RDWR);
1181} 1181}
1182 1182
1183/* 1183/*
@@ -1638,7 +1638,7 @@ static int kvm_dev_ioctl_create_vm(void)
1638 kvm = kvm_create_vm(); 1638 kvm = kvm_create_vm();
1639 if (IS_ERR(kvm)) 1639 if (IS_ERR(kvm))
1640 return PTR_ERR(kvm); 1640 return PTR_ERR(kvm);
1641 fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, 0); 1641 fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, O_RDWR);
1642 if (fd < 0) 1642 if (fd < 0)
1643 kvm_put_kvm(kvm); 1643 kvm_put_kvm(kvm);
1644 1644