Skip to content

Commit 9b31e60

Browse files
ffainelliarndb
authored andcommitted
tools: Fixed MIPS builds due to struct flock re-definition
Building perf for MIPS failed after 9f79b8b ("uapi: simplify __ARCH_FLOCK{,64}_PAD a little") with the following error: CC /home/fainelli/work/buildroot/output/bmips/build/linux-custom/tools/perf/trace/beauty/fcntl.o In file included from ../../../../host/mipsel-buildroot-linux-gnu/sysroot/usr/include/asm/fcntl.h:77, from ../include/uapi/linux/fcntl.h:5, from trace/beauty/fcntl.c:10: ../include/uapi/asm-generic/fcntl.h:188:8: error: redefinition of 'struct flock' struct flock { ^~~~~ In file included from ../include/uapi/linux/fcntl.h:5, from trace/beauty/fcntl.c:10: ../../../../host/mipsel-buildroot-linux-gnu/sysroot/usr/include/asm/fcntl.h:63:8: note: originally defined here struct flock { ^~~~~ This is due to the local copy under tools/include/uapi/asm-generic/fcntl.h including the toolchain's kernel headers which already define 'struct flock' and define HAVE_ARCH_STRUCT_FLOCK to future inclusions make a decision as to whether re-defining 'struct flock' is appropriate or not. Make sure what do not re-define 'struct flock' when HAVE_ARCH_STRUCT_FLOCK is already defined. Fixes: 9f79b8b ("uapi: simplify __ARCH_FLOCK{,64}_PAD a little") Signed-off-by: Florian Fainelli <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> [arnd: sync with include/uapi/asm-generic/fcntl.h as well] Signed-off-by: Arnd Bergmann <[email protected]>
1 parent b13bacc commit 9b31e60

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/uapi/asm-generic/fcntl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ struct f_owner_ex {
192192

193193
#define F_LINUX_SPECIFIC_BASE 1024
194194

195+
#ifndef HAVE_ARCH_STRUCT_FLOCK
195196
struct flock {
196197
short l_type;
197198
short l_whence;
@@ -216,5 +217,6 @@ struct flock64 {
216217
__ARCH_FLOCK64_PAD
217218
#endif
218219
};
220+
#endif /* HAVE_ARCH_STRUCT_FLOCK */
219221

220222
#endif /* _ASM_GENERIC_FCNTL_H */

tools/include/uapi/asm-generic/fcntl.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
12
#ifndef _ASM_GENERIC_FCNTL_H
23
#define _ASM_GENERIC_FCNTL_H
34

@@ -90,7 +91,7 @@
9091

9192
/* a horrid kludge trying to make sure that this will fail on old kernels */
9293
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
93-
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
94+
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
9495

9596
#ifndef O_NDELAY
9697
#define O_NDELAY O_NONBLOCK
@@ -115,11 +116,13 @@
115116
#define F_GETSIG 11 /* for sockets. */
116117
#endif
117118

119+
#if __BITS_PER_LONG == 32 || defined(__KERNEL__)
118120
#ifndef F_GETLK64
119121
#define F_GETLK64 12 /* using 'struct flock64' */
120122
#define F_SETLK64 13
121123
#define F_SETLKW64 14
122124
#endif
125+
#endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */
123126

124127
#ifndef F_SETOWN_EX
125128
#define F_SETOWN_EX 15
@@ -178,13 +181,18 @@ struct f_owner_ex {
178181
blocking */
179182
#define LOCK_UN 8 /* remove lock */
180183

184+
/*
185+
* LOCK_MAND support has been removed from the kernel. We leave the symbols
186+
* here to not break legacy builds, but these should not be used in new code.
187+
*/
181188
#define LOCK_MAND 32 /* This is a mandatory flock ... */
182189
#define LOCK_READ 64 /* which allows concurrent read operations */
183190
#define LOCK_WRITE 128 /* which allows concurrent write operations */
184191
#define LOCK_RW 192 /* which allows concurrent read & write ops */
185192

186193
#define F_LINUX_SPECIFIC_BASE 1024
187194

195+
#ifndef HAVE_ARCH_STRUCT_FLOCK
188196
struct flock {
189197
short l_type;
190198
short l_whence;
@@ -209,5 +217,6 @@ struct flock64 {
209217
__ARCH_FLOCK64_PAD
210218
#endif
211219
};
220+
#endif /* HAVE_ARCH_STRUCT_FLOCK */
212221

213222
#endif /* _ASM_GENERIC_FCNTL_H */

0 commit comments

Comments
 (0)