]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/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.
10 #include <sys/types.h>
15 #ifndef FOR_UTIL_LINUX
17 #include "et/com_err.h"
18 #include "ext2fs/io.h"
20 #else /* FOR_UTIL_LINUX */
22 #if defined(__GNUC__) || defined(HAS_LONG_LONG)
23 typedef long long ext2_loff_t
;
25 typedef long ext2_loff_t
;
28 ext2_loff_t
ext2_llseek (unsigned int, ext2_loff_t
, unsigned int);
30 #endif /* FOR_UTIL_LINUX */
37 #else /* HAVE_LLSEEK */
41 #define my_llseek lseek
45 #include <linux/unistd.h>
48 #define __NR__llseek 140
51 static int _llseek (unsigned int, unsigned long,
52 unsigned long, ext2_loff_t
*, unsigned int);
54 static _syscall5(int,_llseek
,unsigned int,fd
,unsigned long,offset_high
,
55 unsigned long, offset_low
,ext2_loff_t
*,result
,
58 static ext2_loff_t
my_llseek (unsigned int fd
, ext2_loff_t offset
,
64 retval
= _llseek (fd
, ((unsigned long long) offset
) >> 32,
65 ((unsigned long long) offset
) & 0xffffffff,
67 return (retval
== -1 ? (ext2_loff_t
) retval
: result
);
72 #error "llseek() is not available"
74 #endif /* __alpha__ */
76 #endif /* HAVE_LLSEEK */
78 ext2_loff_t
ext2_llseek (unsigned int fd
, ext2_loff_t offset
,
82 static int do_compat
= 0;
84 if ((sizeof(off_t
) >= sizeof(ext2_loff_t
)) ||
85 (offset
< ((ext2_loff_t
) 1 << ((sizeof(off_t
)*8) -1))))
86 return lseek(fd
, (off_t
) offset
, origin
);
93 result
= my_llseek (fd
, offset
, origin
);
94 if (result
== -1 && errno
== ENOSYS
) {
96 * Just in case this code runs on top of an old kernel
97 * which does not support the llseek system call
107 ext2_loff_t
ext2_llseek (unsigned int fd
, ext2_loff_t offset
,
110 if ((sizeof(off_t
) < sizeof(ext2_loff_t
)) &&
111 (offset
>= ((ext2_loff_t
) 1 << ((sizeof(off_t
)*8) -1)))) {
115 return lseek (fd
, (off_t
) offset
, origin
);