2 * llseek.c -- stub calling the llseek system call
4 * Copyright (C) 1994, 1995, 1996, 1997 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
13 #include <sys/types.h>
24 #include "et/com_err.h"
25 #include "ext2fs/ext2_io.h"
35 #ifndef HAVE_LLSEEK_PROTOTYPE
36 extern long long llseek (int fd, long long offset, int origin);
39 #define my_llseek llseek
41 #else /* HAVE_LLSEEK */
47 #else /* !__alpha__ */
49 #include <linux/unistd.h>
52 #define __NR__llseek 140
56 static int _llseek (unsigned int, unsigned long,
57 unsigned long, ext2_loff_t *, unsigned int);
59 static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high,
60 unsigned long, offset_low,ext2_loff_t *,result,
64 static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
70 retval = _llseek(fd, ((unsigned long long) offset) >> 32,
72 retval = syscall(__NR__llseek, fd, (unsigned long long) (offset >> 32),
74 ((unsigned long long) offset) & 0xffffffff,
76 return (retval == -1 ? (ext2_loff_t) retval : result);
79 #endif /* HAVE_LLSEEK */
81 #endif /* __alpha__ */
83 ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
86 static int do_compat = 0;
88 if ((sizeof(off_t) >= sizeof(ext2_loff_t)) ||
89 (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1))))
90 return lseek(fd, (off_t) offset, origin);
97 result = my_llseek (fd, offset, origin);
98 if (result == -1 && errno == ENOSYS) {
100 * Just in case this code runs on top of an old kernel
101 * which does not support the llseek system call
111 ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
113 if ((sizeof(off_t) < sizeof(ext2_loff_t)) &&
114 (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) {
118 return lseek (fd, (off_t) offset, origin);