Whamcloud - gitweb
e2fsck: fix incorrect interior node logical start values
[tools/e2fsprogs.git] / lib / ext2fs / llseek.c
index 17d3d08..b0576e4 100644 (file)
@@ -4,14 +4,15 @@
  * Copyright (C) 1994, 1995, 1996, 1997 Theodore Ts'o.
  *
  * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
  * %End-Header%
  */
 
 #define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
 
+#include "config.h"
 #if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -34,7 +35,8 @@
 
 #define my_llseek lseek64
 
-#elif defined(HAVE_LLSEEK)
+#else
+#if defined(HAVE_LLSEEK)
 #include <syscall.h>
 
 #ifndef HAVE_LLSEEK_PROTOTYPE
@@ -45,11 +47,11 @@ extern long long llseek (int fd, long long offset, int origin);
 
 #else  /* ! HAVE_LLSEEK */
 
-#if defined(__alpha__) || defined (__ia64__)
+#if SIZEOF_LONG == SIZEOF_LONG_LONG
 
 #define llseek lseek
 
-#else /* !__alpha__ && !__ia64__*/
+#else /* SIZEOF_LONG != SIZEOF_LONG_LONG */
 
 #include <linux/unistd.h>
 
@@ -73,7 +75,7 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
 
 #ifndef __i386__
        retval = _llseek(fd, ((unsigned long long) offset) >> 32,
-#else                    
+#else
        retval = syscall(__NR__llseek, fd, (unsigned long long) (offset >> 32),
 #endif
                          ((unsigned long long) offset) & 0xffffffff,
@@ -84,6 +86,7 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
 #endif /* __alpha__ || __ia64__ */
 
 #endif /* HAVE_LLSEEK */
+#endif /* defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE) */
 
 ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
 {
@@ -98,7 +101,7 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
                errno = EINVAL;
                return -1;
        }
-       
+
        result = my_llseek (fd, offset, origin);
        if (result == -1 && errno == ENOSYS) {
                /*
@@ -119,12 +122,16 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
 
 ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
 {
+#if defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE)
+       return lseek64 (fd, offset, origin);
+#else
        if ((sizeof(off_t) < sizeof(ext2_loff_t)) &&
            (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) {
                errno = EINVAL;
                return -1;
        }
        return lseek (fd, (off_t) offset, origin);
+#endif
 }
 
 #endif         /* linux */