Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

uapi: always define F_GETLK64/F_SETLK64/F_SETLKW64 in fcntl.h

The F_GETLK64/F_SETLK64/F_SETLKW64 fcntl opcodes are only implemented
for the 32-bit syscall APIs, but are also needed for compat handling
on 64-bit kernels.

Consolidate them in unistd.h instead of definining the internal compat
definitions in compat.h, which is rather error prone (e.g. parisc
gets the values wrong currently).

Note that before this change they were never visible to userspace due
to the fact that CONFIG_64BIT is only set for kernel builds.

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>
Link: https://lore.kernel.org/r/20220405071314.3225832-3-guoren@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

authored by

Christoph Hellwig and committed by
Palmer Dabbelt
306f7cc1 9f79b8b7

+4 -30
-4
arch/arm64/include/asm/compat.h
··· 73 73 compat_pid_t l_pid; 74 74 }; 75 75 76 - #define F_GETLK64 12 /* using 'struct flock64' */ 77 - #define F_SETLK64 13 78 - #define F_SETLKW64 14 79 - 80 76 struct compat_flock64 { 81 77 short l_type; 82 78 short l_whence;
-4
arch/mips/include/asm/compat.h
··· 65 65 s32 pad[4]; 66 66 }; 67 67 68 - #define F_GETLK64 33 69 - #define F_SETLK64 34 70 - #define F_SETLKW64 35 71 - 72 68 struct compat_flock64 { 73 69 short l_type; 74 70 short l_whence;
+2 -2
arch/mips/include/uapi/asm/fcntl.h
··· 44 44 #define F_SETOWN 24 /* for sockets. */ 45 45 #define F_GETOWN 23 /* for sockets. */ 46 46 47 - #ifndef __mips64 47 + #if __BITS_PER_LONG == 32 || defined(__KERNEL__) 48 48 #define F_GETLK64 33 /* using 'struct flock64' */ 49 49 #define F_SETLK64 34 50 50 #define F_SETLKW64 35 51 - #endif 51 + #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ 52 52 53 53 #if _MIPS_SIM != _MIPS_SIM_ABI64 54 54 #define __ARCH_FLOCK_EXTRA_SYSID long l_sysid;
-4
arch/powerpc/include/asm/compat.h
··· 52 52 compat_pid_t l_pid; 53 53 }; 54 54 55 - #define F_GETLK64 12 /* using 'struct flock64' */ 56 - #define F_SETLK64 13 57 - #define F_SETLKW64 14 58 - 59 55 struct compat_flock64 { 60 56 short l_type; 61 57 short l_whence;
-4
arch/s390/include/asm/compat.h
··· 110 110 compat_pid_t l_pid; 111 111 }; 112 112 113 - #define F_GETLK64 12 114 - #define F_SETLK64 13 115 - #define F_SETLKW64 14 116 - 117 113 struct compat_flock64 { 118 114 short l_type; 119 115 short l_whence;
-4
arch/sparc/include/asm/compat.h
··· 84 84 short __unused; 85 85 }; 86 86 87 - #define F_GETLK64 12 88 - #define F_SETLK64 13 89 - #define F_SETLKW64 14 90 - 91 87 struct compat_flock64 { 92 88 short l_type; 93 89 short l_whence;
-4
arch/x86/include/asm/compat.h
··· 58 58 compat_pid_t l_pid; 59 59 }; 60 60 61 - #define F_GETLK64 12 /* using 'struct flock64' */ 62 - #define F_SETLK64 13 63 - #define F_SETLKW64 14 64 - 65 61 /* 66 62 * IA32 uses 4 byte alignment for 64 bit quantities, 67 63 * so we need to pack this structure.
+2 -2
include/uapi/asm-generic/fcntl.h
··· 116 116 #define F_GETSIG 11 /* for sockets. */ 117 117 #endif 118 118 119 - #ifndef CONFIG_64BIT 119 + #if __BITS_PER_LONG == 32 || defined(__KERNEL__) 120 120 #ifndef F_GETLK64 121 121 #define F_GETLK64 12 /* using 'struct flock64' */ 122 122 #define F_SETLK64 13 123 123 #define F_SETLKW64 14 124 124 #endif 125 - #endif 125 + #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ 126 126 127 127 #ifndef F_SETOWN_EX 128 128 #define F_SETOWN_EX 15
-2
tools/include/uapi/asm-generic/fcntl.h
··· 115 115 #define F_GETSIG 11 /* for sockets. */ 116 116 #endif 117 117 118 - #ifndef CONFIG_64BIT 119 118 #ifndef F_GETLK64 120 119 #define F_GETLK64 12 /* using 'struct flock64' */ 121 120 #define F_SETLK64 13 122 121 #define F_SETLKW64 14 123 - #endif 124 122 #endif 125 123 126 124 #ifndef F_SETOWN_EX