Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934937AbZAPQr1 (ORCPT ); Fri, 16 Jan 2009 11:47:27 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757878AbZAPQqD (ORCPT ); Fri, 16 Jan 2009 11:46:03 -0500 Received: from mx2.redhat.com ([66.187.237.31]:39233 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756284AbZAPQp6 (ORCPT ); Fri, 16 Jan 2009 11:45:58 -0500 From: Gerd Hoffmann To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org Cc: aarcange@redhat.com, Gerd Hoffmann Subject: [PATCH 1/5] create compat_readv() Date: Fri, 16 Jan 2009 17:45:40 +0100 Message-Id: <1232124344-25892-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1232124344-25892-1-git-send-email-kraxel@redhat.com> References: <1232124344-25892-1-git-send-email-kraxel@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1777 Lines: 66 Factor out some code from compat_sys_readv() which can be shared with the upcoming compat_sys_preadv(). Signed-off-by: Gerd Hoffmann --- fs/compat.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/compat.c b/fs/compat.c index 65a070e..63738cc 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -1167,16 +1167,11 @@ out: return ret; } -asmlinkage ssize_t -compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen) +static size_t compat_readv(struct file *file, const struct compat_iovec __user *vec, + unsigned long vlen, loff_t *pos) { - struct file *file; ssize_t ret = -EBADF; - file = fget(fd); - if (!file) - return -EBADF; - if (!(file->f_mode & FMODE_READ)) goto out; @@ -1184,12 +1179,25 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsign if (!file->f_op || (!file->f_op->aio_read && !file->f_op->read)) goto out; - ret = compat_do_readv_writev(READ, file, vec, vlen, &file->f_pos); + ret = compat_do_readv_writev(READ, file, vec, vlen, pos); out: if (ret > 0) add_rchar(current, ret); inc_syscr(current); + return ret; +} + +asmlinkage ssize_t +compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen) +{ + struct file *file; + ssize_t ret; + + file = fget(fd); + if (!file) + return -EBADF; + ret = compat_readv(file, vec, vlen, &file->f_pos); fput(file); return ret; } -- 1.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/