diff options
-rw-r--r-- | fs/compat.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/compat.c b/fs/compat.c index e99048c21c56..e04b4660db84 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1232,15 +1232,12 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, | |||
1232 | return ret; | 1232 | return ret; |
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | asmlinkage ssize_t | 1235 | static size_t compat_writev(struct file *file, |
1236 | compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen) | 1236 | const struct compat_iovec __user *vec, |
1237 | unsigned long vlen, loff_t *pos) | ||
1237 | { | 1238 | { |
1238 | struct file *file; | ||
1239 | ssize_t ret = -EBADF; | 1239 | ssize_t ret = -EBADF; |
1240 | 1240 | ||
1241 | file = fget(fd); | ||
1242 | if (!file) | ||
1243 | return -EBADF; | ||
1244 | if (!(file->f_mode & FMODE_WRITE)) | 1241 | if (!(file->f_mode & FMODE_WRITE)) |
1245 | goto out; | 1242 | goto out; |
1246 | 1243 | ||
@@ -1248,12 +1245,26 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, unsig | |||
1248 | if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write)) | 1245 | if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write)) |
1249 | goto out; | 1246 | goto out; |
1250 | 1247 | ||
1251 | ret = compat_do_readv_writev(WRITE, file, vec, vlen, &file->f_pos); | 1248 | ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos); |
1252 | 1249 | ||
1253 | out: | 1250 | out: |
1254 | if (ret > 0) | 1251 | if (ret > 0) |
1255 | add_wchar(current, ret); | 1252 | add_wchar(current, ret); |
1256 | inc_syscw(current); | 1253 | inc_syscw(current); |
1254 | return ret; | ||
1255 | } | ||
1256 | |||
1257 | asmlinkage ssize_t | ||
1258 | compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, | ||
1259 | unsigned long vlen) | ||
1260 | { | ||
1261 | struct file *file; | ||
1262 | ssize_t ret; | ||
1263 | |||
1264 | file = fget(fd); | ||
1265 | if (!file) | ||
1266 | return -EBADF; | ||
1267 | ret = compat_writev(file, vec, vlen, &file->f_pos); | ||
1257 | fput(file); | 1268 | fput(file); |
1258 | return ret; | 1269 | return ret; |
1259 | } | 1270 | } |