[PATCH] Bionic lacks transparent LFS migrations; provide a workaround

Matt Whitlock busybox at mattwhitlock.name
Sat Apr 25 08:53:33 UTC 2015


This solves some of the problems arising from Bionic's off_t being 32 bits wide despite _FILE_OFFSET_BITS==64. See BusyBox bug #6908.

Note that this doesn't solve all such problems since Bionic lacks 64-bit variants of many standard I/O functions: open, creat, lockf, posix_fadvise, posix_fallocate, truncate, sendfile, getrlimit, setrlimit, fopen, freopen, fseeko, ftello, fgetpos, fsetpos, mkstemp.
---
 include/platform.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/platform.h b/include/platform.h
index 8896a6b..56dc02b 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -491,6 +491,27 @@ typedef unsigned smalluint;
 # undef HAVE_NET_ETHERNET_H
 #endif
 
+/* Bionic system headers lack transparent LFS migrations. */
+#if defined(__BIONIC__) && defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+/* Must include <stdio.h> before migrating off_t to off64_t. */
+#include <stdio.h>
+/* from <unistd.h> */
+# define lseek lseek64
+# define pread pread64
+# define pwrite pwrite64
+# define ftruncate ftruncate64
+/* from <sys/types.h> */
+# define off_t off64_t
+# define ino_t ino64_t
+# define blkcnt_t blkcnt64_t
+# define fsblkcnt_t fsblkcnt64_t
+# define fsfilcnt_t fsfilcnt64_t
+typedef uint64_t ino_t;
+typedef uint64_t blkcnt_t;
+typedef uint64_t fsblkcnt_t;
+typedef uint64_t fsfilcnt_t;
+#endif
+
 /*
  * Now, define prototypes for all the functions defined in platform.c
  * These must come after all the HAVE_* macros are defined (or not)
-- 
2.3.5



More information about the busybox mailing list