diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-04-02 19:59:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-02 22:05:07 -0400 |
commit | 6949a6318e60aeb9c755679ac7f978aefe8c1722 (patch) | |
tree | 97fdbd5d494c5bc99145d5caed28be4ad0e467db /fs | |
parent | dac1213842f5caf081804a11d87d2a39a21d6f55 (diff) |
preadv/pwritev: create compat_writev()
Factor out some code from compat_sys_writev() which can be shared with the
upcoming compat_sys_pwritev().
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: <linux-api@vger.kernel.org>
Cc: <linux-arch@vger.kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-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 | } |