From patchwork Thu Jan 24 16:21:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Susi X-Patchwork-Id: 215426 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EDC5A2C00AF for ; Fri, 25 Jan 2013 03:22:07 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754690Ab3AXQWG (ORCPT ); Thu, 24 Jan 2013 11:22:06 -0500 Received: from rrcs-67-78-168-186.se.biz.rr.com ([67.78.168.186]:40218 "EHLO iriserv.iradimed.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753065Ab3AXQWF (ORCPT ); Thu, 24 Jan 2013 11:22:05 -0500 Received: by iriserv.iradimed.com (Postfix, from userid 1000) id 1FF75514BF; Thu, 24 Jan 2013 11:22:02 -0500 (EST) From: Phillip Susi To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, Phillip Susi Subject: [PATCH] e2fslibs: fix llseek on i386 Date: Thu, 24 Jan 2013 11:21:56 -0500 Message-Id: <1359044517-18243-1-git-send-email-psusi@ubuntu.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ext2fs_llseek() was using lseek instead of lseek64. The only time it would use lseek64 is if passed an offset that overflowed 32 bits. This works for SEEK_SET, but not SEEK_CUR, which can apply a small offset to move the file pointer past the 32 bit limit. The code has been changed to instead try lseek64 first, and fall back to lseek if that fails. It also was doing a runtime check of the size of off_t. This has been moved to compile time. Signed-off-by: Phillip Susi --- configure.in | 3 +++ lib/config.h.in | 3 +++ lib/ext2fs/llseek.c | 13 +++++-------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index ac3cd92..181faeb 100644 --- a/configure.in +++ b/configure.in @@ -970,14 +970,17 @@ AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) +AC_CHECK_SIZEOF(off_t) SIZEOF_SHORT=$ac_cv_sizeof_short SIZEOF_INT=$ac_cv_sizeof_int SIZEOF_LONG=$ac_cv_sizeof_long SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long +SIZEOF_OFF_T=$ac_cv_sizeof_off_t AC_SUBST(SIZEOF_SHORT) AC_SUBST(SIZEOF_INT) AC_SUBST(SIZEOF_LONG) AC_SUBST(SIZEOF_LONG_LONG) +AC_SUBST(SIZEOF_OFF_T) AC_C_BIGENDIAN BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh ASM_TYPES_HEADER=./asm_types.h diff --git a/lib/config.h.in b/lib/config.h.in index 6f88c9c..eebb75d 100644 --- a/lib/config.h.in +++ b/lib/config.h.in @@ -552,6 +552,9 @@ /* The size of `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG +/* The size of `off_t', as computed by sizeof. */ +#undef SIZEOF_OFF_T + /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c index b0576e4..e5cb784 100644 --- a/lib/ext2fs/llseek.c +++ b/lib/ext2fs/llseek.c @@ -90,18 +90,14 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin) ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin) { +#if SIZEOF_OFF_T >= SIZEOF_LONG_LONG + return lseek (fd, offset, origin); +#else ext2_loff_t result; static int do_compat = 0; - if ((sizeof(off_t) >= sizeof(ext2_loff_t)) || - (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) + if (do_compat) return lseek(fd, (off_t) offset, origin); - - if (do_compat) { - errno = EINVAL; - return -1; - } - result = my_llseek (fd, offset, origin); if (result == -1 && errno == ENOSYS) { /* @@ -112,6 +108,7 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin) errno = EINVAL; } return result; +#endif } #else /* !linux */