Index: uspace/lib/posix/include/posix/sys/types.h
===================================================================
--- uspace/lib/posix/include/posix/sys/types.h	(revision 631281dedb2b080d5b5af149d4e4b05369d66c34)
+++ uspace/lib/posix/include/posix/sys/types.h	(revision 42da5ed63dc4e81e1aed2c903e5dbd1b1045978c)
@@ -43,5 +43,4 @@
 typedef unsigned int uid_t;
 typedef unsigned int gid_t;
-typedef int64_t off_t;
 typedef long blksize_t;
 typedef long blkcnt_t;
@@ -49,4 +48,14 @@
 typedef sysarg_t dev_t;
 typedef unsigned int mode_t;
+
+#if _FILE_OFFSET_BITS == 64
+typedef int64_t off_t;
+#else
+typedef long off_t;
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+typedef int64_t off64_t;
+#endif
 
 /* PThread Types */
Index: uspace/lib/posix/include/posix/unistd.h
===================================================================
--- uspace/lib/posix/include/posix/unistd.h	(revision 631281dedb2b080d5b5af149d4e4b05369d66c34)
+++ uspace/lib/posix/include/posix/unistd.h	(revision 42da5ed63dc4e81e1aed2c903e5dbd1b1045978c)
@@ -80,6 +80,4 @@
 extern ssize_t read(int fildes, void *buf, size_t nbyte);
 extern ssize_t write(int fildes, const void *buf, size_t nbyte);
-extern off_t lseek(int fildes,
-    off_t offset, int whence);
 extern int fsync(int fildes);
 extern int ftruncate(int fildes, off_t length);
@@ -88,4 +86,22 @@
 extern int dup(int fildes);
 extern int dup2(int fildes, int fildes2);
+
+#ifdef _LARGEFILE64_SOURCE
+extern off64_t lseek64(int fildes, off64_t offset, int whence);
+#endif
+
+#if _FILE_OFFSET_BITS == 64
+static inline off_t lseek(int fildes, off_t offset, int whence)
+{
+	/* Declarations visible in this function body only. */
+	typedef int64_t off64_t;
+	extern off64_t lseek64(int fildes, off64_t offset, int whence);
+
+	/* With _FILE_OFFSET_BITS == 64, lseek is actually lseek64. */
+	return lseek64(fildes, offset, whence);
+}
+#else
+extern off_t lseek(int fildes, off_t offset, int whence);
+#endif
 
 /* Standard Streams */
