Description: Fix handling of O_LARGEFILE on various 64-bit arches
Author: James Cowgill <jcowgill@debian.org>
Bug-Debian: https://bugs.debian.org/775357
Bug-Debian: https://bugs.debian.org/791347
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/libexplain/ac/fcntl.h
+++ b/libexplain/ac/fcntl.h
@@ -53,12 +53,25 @@
 #endif
 
 /*
- * Even when O_LARGEFILE is not necessary, glibc adds one in for free.
- * The trouble is, this make things interesting when decoding
- * flags values returned by the kernel.
+ * On 64-bit linux, fcntl(F_GETFL) always returns O_LARGEFILE even if we don't
+ * request it. Unfortunately glibc does not expose this value so we have to
+ * handle it ourselves. Also the value changes across arches *sigh*.
+ *
+ * These values were taken from the asm/fcntl.h kernel header for each arch.
+ * We can't include this header because it conflicts with glibc's fcntl.h.
  */
 #if defined(__linux__) && (O_LARGEFILE == 0)
-#define O_LARGEFILE_HIDDEN 0100000
+# if defined(__aarch64__) || defined(__alpha__)
+#  define O_LARGEFILE_HIDDEN 0400000
+# elif defined(__mips64)
+#  define O_LARGEFILE_HIDDEN 0x2000
+# elif defined(__PPC64__)
+#  define O_LARGEFILE_HIDDEN 0200000
+# elif defined(__sparc__) && defined(__arch64__)
+#  define O_LARGEFILE_HIDDEN 0x40000
+# else
+#  define O_LARGEFILE_HIDDEN 0100000
+# endif
 #endif
 
 
