@@ -32,5 +32,6 @@ typedef signed long off_t;
typedef signed long blksize_t;
typedef signed long blkcnt_t;
typedef signed long time_t;
+typedef long long loff_t;
#endif /* _NOLIBC_STD_H */
@@ -671,7 +671,25 @@ int link(const char *old, const char *new)
static __attribute__((unused))
off_t sys_lseek(int fd, off_t offset, int whence)
{
+#ifdef __NR_lseek
return my_syscall3(__NR_lseek, fd, offset, whence);
+#elif defined(__NR_llseek)
+ loff_t result;
+ off_t retval;
+ int ret;
+
+ ret = my_syscall5(__NR_llseek, fd, (long) (((uint64_t) (offset)) >> 32), (long) offset, &result, whence);
+ if (ret)
+ return ret;
+
+ retval = (off_t) result;
+ if (retval != result)
+ return -EOVERFLOW;
+
+ return retval;
+#else
+#error Neither __NR_lseek nor __NR_llseek defined, cannot implement sys_lseek()
+#endif
}
static __attribute__((unused))