aboutsummaryrefslogtreecommitdiffstats
path: root/fs/read_write.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/read_write.c')
-rw-r--r--fs/read_write.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 69128b378646..9d7952a6829b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -527,6 +527,20 @@ ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, lo
527 527
528EXPORT_SYMBOL(new_sync_write); 528EXPORT_SYMBOL(new_sync_write);
529 529
530ssize_t __vfs_write(struct file *file, const char __user *p, size_t count,
531 loff_t *pos)
532{
533 if (file->f_op->write)
534 return file->f_op->write(file, p, count, pos);
535 else if (file->f_op->aio_write)
536 return do_sync_write(file, p, count, pos);
537 else if (file->f_op->write_iter)
538 return new_sync_write(file, p, count, pos);
539 else
540 return -EINVAL;
541}
542EXPORT_SYMBOL(__vfs_write);
543
530ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos) 544ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos)
531{ 545{
532 mm_segment_t old_fs; 546 mm_segment_t old_fs;
@@ -541,12 +555,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
541 p = (__force const char __user *)buf; 555 p = (__force const char __user *)buf;
542 if (count > MAX_RW_COUNT) 556 if (count > MAX_RW_COUNT)
543 count = MAX_RW_COUNT; 557 count = MAX_RW_COUNT;
544 if (file->f_op->write) 558 ret = __vfs_write(file, p, count, pos);
545 ret = file->f_op->write(file, p, count, pos);
546 else if (file->f_op->aio_write)
547 ret = do_sync_write(file, p, count, pos);
548 else
549 ret = new_sync_write(file, p, count, pos);
550 set_fs(old_fs); 559 set_fs(old_fs);
551 if (ret > 0) { 560 if (ret > 0) {
552 fsnotify_modify(file); 561 fsnotify_modify(file);
@@ -573,12 +582,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
573 if (ret >= 0) { 582 if (ret >= 0) {
574 count = ret; 583 count = ret;
575 file_start_write(file); 584 file_start_write(file);
576 if (file->f_op->write) 585 ret = __vfs_write(file, buf, count, pos);
577 ret = file->f_op->write(file, buf, count, pos);
578 else if (file->f_op->aio_write)
579 ret = do_sync_write(file, buf, count, pos);
580 else
581 ret = new_sync_write(file, buf, count, pos);
582 if (ret > 0) { 586 if (ret > 0) {
583 fsnotify_modify(file); 587 fsnotify_modify(file);
584 add_wchar(current, ret); 588 add_wchar(current, ret);