[klibc] fcntl: Fix struct flock for 32-bit architectures

In Linux 2.6.30 the definition of struct flock stopped using
off_t (which we define) in favour of __kernel_off_t.  This
meant we started using a 32-bit struct flock with 64-bit fcntl
numbers.

Disable the kernel's definition of struct flock and define
it ourselves with 64-bit offsets.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
diff --git a/usr/include/fcntl.h b/usr/include/fcntl.h
index b08c7c8..ed703a6 100644
--- a/usr/include/fcntl.h
+++ b/usr/include/fcntl.h
@@ -11,17 +11,30 @@
 #include <sys/types.h>
 #if defined(__mips__) && ! defined(__mips64)
 # include <klibc/archfcntl.h>
+#elif _BITSIZE == 32
+/* We want a struct flock with 64-bit offsets, which we define below */
+# define HAVE_ARCH_STRUCT_FLOCK
 #endif
 #include <linux/fcntl.h>
 #include <bitsize.h>
 
-#if _BITSIZE == 32
+#if !defined(__mips__) && _BITSIZE == 32
 
-/* This is ugly, but "struct flock" has actually been defined with
-   a long off_t, so it's really "struct flock64".  It just happens
-   to work.  Gag.  Barf.
+/*
+ * <linux/fcntl.h> defines struct flock with offsets of type
+ * __kernel_off_t (= long) and struct flock64 with offsets of
+ * type __kernel_loff_t (= long long).  We want struct flock
+ * to have 64-bit offsets, so we define it here.
+ */
 
-   This happens to work on all 32-bit architectures except MIPS. */
+struct flock {
+	short  l_type;
+	short  l_whence;
+	__kernel_loff_t l_start;
+	__kernel_loff_t l_len;
+	__kernel_pid_t  l_pid;
+        __ARCH_FLOCK64_PAD
+};
 
 #ifdef F_GETLK64
 # undef F_GETLK