aboutsummaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-10 14:35:36 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-10 14:35:36 -0500
commit4ba24fef3eb3b142197135223b90ced2f319cd53 (patch)
treea20c125b27740ec7b4c761b11d801108e1b316b2 /fs/open.c
parent47c1ffb2b6b630894e9a16442611c056ab21c057 (diff)
parent98a4a59ee31a12105a2b84f5b8b515ac2cb208ef (diff)
Merge branch 'next' into for-linus
Prepare first round of input updates for 3.20.
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/fs/open.c b/fs/open.c
index d6fd3acde134..813be037b412 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -222,7 +222,7 @@ SYSCALL_DEFINE2(ftruncate64, unsigned int, fd, loff_t, length)
222#endif /* BITS_PER_LONG == 32 */ 222#endif /* BITS_PER_LONG == 32 */
223 223
224 224
225int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 225int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
226{ 226{
227 struct inode *inode = file_inode(file); 227 struct inode *inode = file_inode(file);
228 long ret; 228 long ret;
@@ -295,9 +295,21 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
295 295
296 sb_start_write(inode->i_sb); 296 sb_start_write(inode->i_sb);
297 ret = file->f_op->fallocate(file, mode, offset, len); 297 ret = file->f_op->fallocate(file, mode, offset, len);
298
299 /*
300 * Create inotify and fanotify events.
301 *
302 * To keep the logic simple always create events if fallocate succeeds.
303 * This implies that events are even created if the file size remains
304 * unchanged, e.g. when using flag FALLOC_FL_KEEP_SIZE.
305 */
306 if (ret == 0)
307 fsnotify_modify(file);
308
298 sb_end_write(inode->i_sb); 309 sb_end_write(inode->i_sb);
299 return ret; 310 return ret;
300} 311}
312EXPORT_SYMBOL_GPL(vfs_fallocate);
301 313
302SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len) 314SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
303{ 315{
@@ -305,7 +317,7 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
305 int error = -EBADF; 317 int error = -EBADF;
306 318
307 if (f.file) { 319 if (f.file) {
308 error = do_fallocate(f.file, mode, offset, len); 320 error = vfs_fallocate(f.file, mode, offset, len);
309 fdput(f); 321 fdput(f);
310 } 322 }
311 return error; 323 return error;
@@ -516,7 +528,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
516 int err = -EBADF; 528 int err = -EBADF;
517 529
518 if (f.file) { 530 if (f.file) {
519 audit_inode(NULL, f.file->f_path.dentry, 0); 531 audit_file(f.file);
520 err = chmod_common(&f.file->f_path, mode); 532 err = chmod_common(&f.file->f_path, mode);
521 fdput(f); 533 fdput(f);
522 } 534 }
@@ -642,7 +654,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)
642 error = mnt_want_write_file(f.file); 654 error = mnt_want_write_file(f.file);
643 if (error) 655 if (error)
644 goto out_fput; 656 goto out_fput;
645 audit_inode(NULL, f.file->f_path.dentry, 0); 657 audit_file(f.file);
646 error = chown_common(&f.file->f_path, user, group); 658 error = chown_common(&f.file->f_path, user, group);
647 mnt_drop_write_file(f.file); 659 mnt_drop_write_file(f.file);
648out_fput: 660out_fput:
@@ -823,8 +835,7 @@ struct file *dentry_open(const struct path *path, int flags,
823 f = get_empty_filp(); 835 f = get_empty_filp();
824 if (!IS_ERR(f)) { 836 if (!IS_ERR(f)) {
825 f->f_flags = flags; 837 f->f_flags = flags;
826 f->f_path = *path; 838 error = vfs_open(path, f, cred);
827 error = do_dentry_open(f, NULL, cred);
828 if (!error) { 839 if (!error) {
829 /* from now on we need fput() to dispose of f */ 840 /* from now on we need fput() to dispose of f */
830 error = open_check_o_direct(f); 841 error = open_check_o_direct(f);
@@ -841,6 +852,26 @@ struct file *dentry_open(const struct path *path, int flags,
841} 852}
842EXPORT_SYMBOL(dentry_open); 853EXPORT_SYMBOL(dentry_open);
843 854
855/**
856 * vfs_open - open the file at the given path
857 * @path: path to open
858 * @filp: newly allocated file with f_flag initialized
859 * @cred: credentials to use
860 */
861int vfs_open(const struct path *path, struct file *filp,
862 const struct cred *cred)
863{
864 struct inode *inode = path->dentry->d_inode;
865
866 if (inode->i_op->dentry_open)
867 return inode->i_op->dentry_open(path->dentry, filp, cred);
868 else {
869 filp->f_path = *path;
870 return do_dentry_open(filp, NULL, cred);
871 }
872}
873EXPORT_SYMBOL(vfs_open);
874
844static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op) 875static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
845{ 876{
846 int lookup_flags = 0; 877 int lookup_flags = 0;