chiark / gitweb /
2102a503e98fd9d23d2d14b71cfb7c4136ee04b2
[elogind.git] / klibc / klibc / llseek.c
1 /*
2  * llseek.c
3  *
4  * On 32-bit platforms, we need to use the _llseek() system call
5  * rather than lseek(), to be able to handle large disks.  _llseek()
6  * isn't just a normal syscall which takes a 64-bit argument; it needs
7  * to return a 64-bit value and so takes an extra pointer.
8  */
9
10 #include <unistd.h>
11 #include <sys/syscall.h>
12
13 #if BITSIZE == 32
14
15 extern int __llseek(int fd, unsigned long hi, unsigned long lo, off_t *res, int whence);
16
17 off_t lseek(int fd, off_t offset, int whence)
18 {
19   off_t result;
20   int rv;
21
22   rv = __llseek(fd, (unsigned long)(offset >> 32), (unsigned long)offset,
23                 &result, whence);
24   
25   return rv ? (off_t)-1 : result;
26 }
27
28 #endif
29