compat: consolidate the compat_flock{,64} definition
authorChristoph Hellwig <hch@lst.de>
Tue, 5 Apr 2022 07:12:57 +0000 (15:12 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Tue, 26 Apr 2022 20:35:28 +0000 (13:35 -0700)
Provide a single common definition for the compat_flock and
compat_flock64 structures using the same tricks as for the native
variants.  Another extra define is added for the packing required on
x86.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Helge Deller <deller@gmx.de> # parisc
Link: https://lore.kernel.org/r/20220405071314.3225832-4-guoren@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/arm64/include/asm/compat.h
arch/mips/include/asm/compat.h
arch/parisc/include/asm/compat.h
arch/powerpc/include/asm/compat.h
arch/s390/include/asm/compat.h
arch/sparc/include/asm/compat.h
arch/x86/include/asm/compat.h
include/linux/compat.h

index 27632876540818bc32051b11720581dcc85b43c2..e0faec1984a1c0f3edc96034730af27c153ab697 100644 (file)
@@ -65,22 +65,6 @@ struct compat_stat {
        compat_ulong_t  __unused4[2];
 };
 
-struct compat_flock {
-       short           l_type;
-       short           l_whence;
-       compat_off_t    l_start;
-       compat_off_t    l_len;
-       compat_pid_t    l_pid;
-};
-
-struct compat_flock64 {
-       short           l_type;
-       short           l_whence;
-       compat_loff_t   l_start;
-       compat_loff_t   l_len;
-       compat_pid_t    l_pid;
-};
-
 struct compat_statfs {
        int             f_type;
        int             f_bsize;
index 6a350c1f70d7e7acbf289619334d9f6ba0b48fa3..6d6e5a451f4d9f1a940f77acb06e1c300ac9cd07 100644 (file)
@@ -55,23 +55,8 @@ struct compat_stat {
        s32             st_pad4[14];
 };
 
-struct compat_flock {
-       short           l_type;
-       short           l_whence;
-       compat_off_t    l_start;
-       compat_off_t    l_len;
-       s32             l_sysid;
-       compat_pid_t    l_pid;
-       s32             pad[4];
-};
-
-struct compat_flock64 {
-       short           l_type;
-       short           l_whence;
-       compat_loff_t   l_start;
-       compat_loff_t   l_len;
-       compat_pid_t    l_pid;
-};
+#define __ARCH_COMPAT_FLOCK_EXTRA_SYSID                s32 l_sysid;
+#define __ARCH_COMPAT_FLOCK_PAD                        s32 pad[4];
 
 struct compat_statfs {
        int             f_type;
index c04f5a637c390b9d84939f1476e497fd0a7d3649..a1e4534d805091a81d456a33252c8bec0963e914 100644 (file)
@@ -53,22 +53,6 @@ struct compat_stat {
        u32                     st_spare4[3];
 };
 
-struct compat_flock {
-       short                   l_type;
-       short                   l_whence;
-       compat_off_t            l_start;
-       compat_off_t            l_len;
-       compat_pid_t            l_pid;
-};
-
-struct compat_flock64 {
-       short                   l_type;
-       short                   l_whence;
-       compat_loff_t           l_start;
-       compat_loff_t           l_len;
-       compat_pid_t            l_pid;
-};
-
 struct compat_statfs {
        s32             f_type;
        s32             f_bsize;
index 83d8f70779cbc231a3346bd3caa045b4252503fa..5ef3c7c83c3434c43b5e4fb1cc77a047a2d6292f 100644 (file)
@@ -44,22 +44,6 @@ struct compat_stat {
        u32             __unused4[2];
 };
 
-struct compat_flock {
-       short           l_type;
-       short           l_whence;
-       compat_off_t    l_start;
-       compat_off_t    l_len;
-       compat_pid_t    l_pid;
-};
-
-struct compat_flock64 {
-       short           l_type;
-       short           l_whence;
-       compat_loff_t   l_start;
-       compat_loff_t   l_len;
-       compat_pid_t    l_pid;
-};
-
 struct compat_statfs {
        int             f_type;
        int             f_bsize;
index 0f14b3188b1bb27ac73aa250dede85a11960a3ed..07f04d37068b6e861db9eb103b47772036237ef4 100644 (file)
@@ -102,22 +102,6 @@ struct compat_stat {
        u32             __unused5;
 };
 
-struct compat_flock {
-       short           l_type;
-       short           l_whence;
-       compat_off_t    l_start;
-       compat_off_t    l_len;
-       compat_pid_t    l_pid;
-};
-
-struct compat_flock64 {
-       short           l_type;
-       short           l_whence;
-       compat_loff_t   l_start;
-       compat_loff_t   l_len;
-       compat_pid_t    l_pid;
-};
-
 struct compat_statfs {
        u32             f_type;
        u32             f_bsize;
index 108078751bb5a86f71e9fd34f8734ce841b858c8..d78fb44942e0f6b8dadf7cedaf4457c0fb10386a 100644 (file)
@@ -75,23 +75,7 @@ struct compat_stat64 {
        unsigned int    __unused5;
 };
 
-struct compat_flock {
-       short           l_type;
-       short           l_whence;
-       compat_off_t    l_start;
-       compat_off_t    l_len;
-       compat_pid_t    l_pid;
-       short           __unused;
-};
-
-struct compat_flock64 {
-       short           l_type;
-       short           l_whence;
-       compat_loff_t   l_start;
-       compat_loff_t   l_len;
-       compat_pid_t    l_pid;
-       short           __unused;
-};
+#define __ARCH_COMPAT_FLOCK_PAD                short __unused;
 
 struct compat_statfs {
        int             f_type;
index 8d19a212f4f266d40fdfb65a2ab5e1eefedb9760..de794d895866326d6f4f46325b6e9222b5311f67 100644 (file)
@@ -50,25 +50,11 @@ struct compat_stat {
        u32             __unused5;
 };
 
-struct compat_flock {
-       short           l_type;
-       short           l_whence;
-       compat_off_t    l_start;
-       compat_off_t    l_len;
-       compat_pid_t    l_pid;
-};
-
 /*
- * IA32 uses 4 byte alignment for 64 bit quantities,
- * so we need to pack this structure.
+ * IA32 uses 4 byte alignment for 64 bit quantities, so we need to pack the
+ * compat flock64 structure.
  */
-struct compat_flock64 {
-       short           l_type;
-       short           l_whence;
-       compat_loff_t   l_start;
-       compat_loff_t   l_len;
-       compat_pid_t    l_pid;
-} __attribute__((packed));
+#define __ARCH_NEED_COMPAT_FLOCK64_PACKED
 
 struct compat_statfs {
        int             f_type;
index 1c758b0e03598f672267110fa99bc447446896a1..a0481fe6c5d5199c4a129cca9a679a42a807bd9c 100644 (file)
@@ -258,6 +258,37 @@ struct compat_rlimit {
        compat_ulong_t  rlim_max;
 };
 
+#ifdef __ARCH_NEED_COMPAT_FLOCK64_PACKED
+#define __ARCH_COMPAT_FLOCK64_PACK     __attribute__((packed))
+#else
+#define __ARCH_COMPAT_FLOCK64_PACK
+#endif
+
+struct compat_flock {
+       short                   l_type;
+       short                   l_whence;
+       compat_off_t            l_start;
+       compat_off_t            l_len;
+#ifdef __ARCH_COMPAT_FLOCK_EXTRA_SYSID
+       __ARCH_COMPAT_FLOCK_EXTRA_SYSID
+#endif
+       compat_pid_t            l_pid;
+#ifdef __ARCH_COMPAT_FLOCK_PAD
+       __ARCH_COMPAT_FLOCK_PAD
+#endif
+};
+
+struct compat_flock64 {
+       short           l_type;
+       short           l_whence;
+       compat_loff_t   l_start;
+       compat_loff_t   l_len;
+       compat_pid_t    l_pid;
+#ifdef __ARCH_COMPAT_FLOCK64_PAD
+       __ARCH_COMPAT_FLOCK64_PAD
+#endif
+} __ARCH_COMPAT_FLOCK64_PACK;
+
 struct compat_rusage {
        struct old_timeval32 ru_utime;
        struct old_timeval32 ru_stime;