aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2019-01-21 03:39:34 +0000
committerBen Hutchings <ben@decadent.org.uk>2019-01-21 03:45:04 +0000
commit11bd4ea5f3d960c4d208180deae91d88aa940149 (patch)
tree472e5c90ec545fe1a6f3625a0bab9ce3bcfd4292
parentfb7fdfa873f980d71b3acafea381af77e927cace (diff)
downloadklibc-11bd4ea5f3d960c4d208180deae91d88aa940149.tar.gz
[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>
-rw-r--r--usr/include/fcntl.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/usr/include/fcntl.h b/usr/include/fcntl.h
index b08c7c8c60eeb..ed703a62d6c1b 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