]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - fdisk/llseek.c
2 * llseek.c -- stub calling the llseek system call
4 * Copyright (C) 1994 Remy Card. This file may be redistributed
5 * under the terms of the GNU Public License.
13 #if defined(__GNUC__) || defined(HAS_LONG_LONG)
14 typedef long long ext2_loff_t
;
16 typedef long ext2_loff_t
;
19 extern ext2_loff_t
ext2_llseek (unsigned int, ext2_loff_t
, unsigned int);
26 #else /* HAVE_LLSEEK */
30 #define my_llseek lseek
33 #include <linux/unistd.h> /* for __NR__llseek */
35 static int _llseek (unsigned int, unsigned long,
36 unsigned long, ext2_loff_t
*, unsigned int);
38 static _syscall5(int,_llseek
,unsigned int,fd
,unsigned long,offset_high
,
39 unsigned long, offset_low
,ext2_loff_t
*,result
,
42 static ext2_loff_t
my_llseek (unsigned int fd
, ext2_loff_t offset
,
48 retval
= _llseek (fd
, ((unsigned long long) offset
) >> 32,
49 ((unsigned long long) offset
) & 0xffffffff,
51 return (retval
== -1 ? (ext2_loff_t
) retval
: result
);
54 #endif /* __alpha__ */
56 #endif /* HAVE_LLSEEK */
58 ext2_loff_t
ext2_llseek (unsigned int fd
, ext2_loff_t offset
,
62 static int do_compat
= 0;
65 result
= my_llseek (fd
, offset
, origin
);
66 if (!(result
== -1 && errno
== ENOSYS
))
70 * Just in case this code runs on top of an old kernel
71 * which does not support the llseek system call
75 * Now try ordinary lseek.
79 if ((sizeof(off_t
) >= sizeof(ext2_loff_t
)) ||
80 (offset
< ((ext2_loff_t
) 1 << ((sizeof(off_t
)*8) -1))))
81 return lseek(fd
, (off_t
) offset
, origin
);
89 ext2_loff_t
ext2_llseek (unsigned int fd
, ext2_loff_t offset
,
92 if ((sizeof(off_t
) < sizeof(ext2_loff_t
)) &&
93 (offset
>= ((ext2_loff_t
) 1 << ((sizeof(off_t
)*8) -1)))) {
97 return lseek (fd
, (off_t
) offset
, origin
);