OSDN Git Service

llseek: setup the correct seek for ext2fs_llseek
authorJP Abgrall <jpa@google.com>
Thu, 20 Mar 2014 02:31:35 +0000 (19:31 -0700)
committerJP Abgrall <jpa@google.com>
Thu, 20 Mar 2014 02:31:35 +0000 (19:31 -0700)
After
  http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/commit/lib/ext2fs/llseek.c?id=274d46e1d35af423d0292d63c4d0ad7a03be82ba

with
  __linux__
  defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE)
  SIZEOF_OFF_T >= SIZEOF_LONG_LONG
it leads to ext2fs_llseek() doing a "return lseek(fd, offset, origin);"
Which  fails for offsets > 32bit.

Also, with
  __linux__
  !(defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE))
  defined(HAVE_LLSEEK)
  SIZEOF_OFF_T == SIZEOF_LONG_LONG
my_llseek is not defined at all. And there is no need to define
llseek as lseek, as llseek is never used.
Luckily ext2fs_llseek() then does "return lseek(...);"
It would seem that my_llseek should be used in both places.

Bug: 13340735
Change-Id: Ie7330300c9c1ca103eaaef97536dcf10adbbba02
Signed-off-by: JP Abgrall <jpa@google.com>
lib/ext2fs/llseek.c

index 774d1d4..2bdb2e0 100644 (file)
@@ -48,7 +48,7 @@ extern long long llseek (int fd, long long offset, int origin);
 
 #if SIZEOF_LONG == SIZEOF_LONG_LONG
 
-#define llseek lseek
+#define my_llseek lseek
 
 #else /* SIZEOF_LONG != SIZEOF_LONG_LONG */
 
@@ -82,7 +82,7 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
        return (retval == -1 ? (ext2_loff_t) retval : result);
 }
 
-#endif /* __alpha__ || __ia64__ */
+#endif /* SIZE_LONG == SIZEOF_LONG_LONG */
 
 #endif /* HAVE_LLSEEK */
 #endif /* defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE) */
@@ -90,7 +90,7 @@ 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);
+       return my_llseek (fd, offset, origin);
 #else
        ext2_loff_t result;
        static int do_compat = 0;