]>
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 extern long long ext2_llseek (unsigned int, long long, unsigned int);
20 #else /* HAVE_LLSEEK */
22 #if defined(__alpha__) || defined(__ia64__) || defined(__s390x__)
24 #define my_llseek lseek
27 #include <linux/unistd.h> /* for __NR__llseek */
29 static int _llseek (unsigned int, unsigned long,
30 unsigned long, long long *, unsigned int);
34 static _syscall5(int,_llseek
,unsigned int,fd
,unsigned long,offset_high
,
35 unsigned long, offset_low
,long long *,result
,
40 /* no __NR__llseek on compilation machine - might give it explicitly */
41 static int _llseek (unsigned int fd
, unsigned long oh
,
42 unsigned long ol
, long long *result
,
43 unsigned int origin
) {
50 static long long my_llseek (unsigned int fd
, long long offset
,
56 retval
= _llseek (fd
, ((unsigned long long) offset
) >> 32,
57 ((unsigned long long) offset
) & 0xffffffff,
59 return (retval
== -1 ? (long long) retval
: result
);
62 #endif /* __alpha__ */
64 #endif /* HAVE_LLSEEK */
66 long long ext2_llseek (unsigned int fd
, long long offset
,
70 static int do_compat
= 0;
73 result
= my_llseek (fd
, offset
, origin
);
74 if (!(result
== -1 && errno
== ENOSYS
))
78 * Just in case this code runs on top of an old kernel
79 * which does not support the llseek system call
83 * Now try ordinary lseek.
87 if ((sizeof(off_t
) >= sizeof(long long)) ||
88 (offset
< ((long long) 1 << ((sizeof(off_t
)*8) -1))))
89 return lseek(fd
, (off_t
) offset
, origin
);
97 long long ext2_llseek (unsigned int fd
, long long offset
,
100 if ((sizeof(off_t
) < sizeof(long long)) &&
101 (offset
>= ((long long) 1 << ((sizeof(off_t
)*8) -1)))) {
105 return lseek (fd
, (off_t
) offset
, origin
);