aboutsummaryrefslogtreecommitdiffstats
path: root/fs/read_write.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-06-20 10:58:36 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-20 11:02:45 -0400
commit7995bd287134f6c8f80d94bebe7396f05a9bc42b (patch)
tree7e94bb13bb30b8549892ed93e0e5b11d8b642bc2 /fs/read_write.c
parentc9036e9f3b2b77f678572260e1ef1075fcb08c36 (diff)
splice: don't pass the address of ->f_pos to methods
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r--fs/read_write.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 03430008704e..2cefa417be34 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1064,6 +1064,7 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
1064 struct fd in, out; 1064 struct fd in, out;
1065 struct inode *in_inode, *out_inode; 1065 struct inode *in_inode, *out_inode;
1066 loff_t pos; 1066 loff_t pos;
1067 loff_t out_pos;
1067 ssize_t retval; 1068 ssize_t retval;
1068 int fl; 1069 int fl;
1069 1070
@@ -1077,12 +1078,14 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
1077 if (!(in.file->f_mode & FMODE_READ)) 1078 if (!(in.file->f_mode & FMODE_READ))
1078 goto fput_in; 1079 goto fput_in;
1079 retval = -ESPIPE; 1080 retval = -ESPIPE;
1080 if (!ppos) 1081 if (!ppos) {
1081 ppos = &in.file->f_pos; 1082 pos = in.file->f_pos;
1082 else 1083 } else {
1084 pos = *ppos;
1083 if (!(in.file->f_mode & FMODE_PREAD)) 1085 if (!(in.file->f_mode & FMODE_PREAD))
1084 goto fput_in; 1086 goto fput_in;
1085 retval = rw_verify_area(READ, in.file, ppos, count); 1087 }
1088 retval = rw_verify_area(READ, in.file, &pos, count);
1086 if (retval < 0) 1089 if (retval < 0)
1087 goto fput_in; 1090 goto fput_in;
1088 count = retval; 1091 count = retval;
@@ -1099,7 +1102,8 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
1099 retval = -EINVAL; 1102 retval = -EINVAL;
1100 in_inode = file_inode(in.file); 1103 in_inode = file_inode(in.file);
1101 out_inode = file_inode(out.file); 1104 out_inode = file_inode(out.file);
1102 retval = rw_verify_area(WRITE, out.file, &out.file->f_pos, count); 1105 out_pos = out.file->f_pos;
1106 retval = rw_verify_area(WRITE, out.file, &out_pos, count);
1103 if (retval < 0) 1107 if (retval < 0)
1104 goto fput_out; 1108 goto fput_out;
1105 count = retval; 1109 count = retval;
@@ -1107,7 +1111,6 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
1107 if (!max) 1111 if (!max)
1108 max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes); 1112 max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
1109 1113
1110 pos = *ppos;
1111 if (unlikely(pos + count > max)) { 1114 if (unlikely(pos + count > max)) {
1112 retval = -EOVERFLOW; 1115 retval = -EOVERFLOW;
1113 if (pos >= max) 1116 if (pos >= max)
@@ -1126,18 +1129,23 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
1126 if (in.file->f_flags & O_NONBLOCK) 1129 if (in.file->f_flags & O_NONBLOCK)
1127 fl = SPLICE_F_NONBLOCK; 1130 fl = SPLICE_F_NONBLOCK;
1128#endif 1131#endif
1129 retval = do_splice_direct(in.file, ppos, out.file, count, fl); 1132 retval = do_splice_direct(in.file, &pos, out.file, &out_pos, count, fl);
1130 1133
1131 if (retval > 0) { 1134 if (retval > 0) {
1132 add_rchar(current, retval); 1135 add_rchar(current, retval);
1133 add_wchar(current, retval); 1136 add_wchar(current, retval);
1134 fsnotify_access(in.file); 1137 fsnotify_access(in.file);
1135 fsnotify_modify(out.file); 1138 fsnotify_modify(out.file);
1139 out.file->f_pos = out_pos;
1140 if (ppos)
1141 *ppos = pos;
1142 else
1143 in.file->f_pos = pos;
1136 } 1144 }
1137 1145
1138 inc_syscr(current); 1146 inc_syscr(current);
1139 inc_syscw(current); 1147 inc_syscw(current);
1140 if (*ppos > max) 1148 if (pos > max)
1141 retval = -EOVERFLOW; 1149 retval = -EOVERFLOW;
1142 1150
1143fput_out: 1151fput_out: