summaryrefslogtreecommitdiff
path: root/lib/ext2fs/llseek.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext2fs/llseek.c')
-rw-r--r--lib/ext2fs/llseek.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c
index b0576e40..c3a98a2c 100644
--- a/lib/ext2fs/llseek.c
+++ b/lib/ext2fs/llseek.c
@@ -90,17 +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))))
- return lseek(fd, (off_t) offset, origin);
-
- if (do_compat) {
- errno = EINVAL;
- return -1;
- }
+ if (do_compat)
+ goto fallback;
result = my_llseek (fd, offset, origin);
if (result == -1 && errno == ENOSYS) {
@@ -109,9 +106,14 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
* which does not support the llseek system call
*/
do_compat++;
+ fallback:
+ if (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))
+ return lseek(fd, (off_t) offset, origin);
errno = EINVAL;
+ return -1;
}
return result;
+#endif
}
#else /* !linux */