* [PATCH] samples/vfs: Undefine conflicting AT_RENAME_* macros in test-statx
@ 2025-10-04 19:58 Madhur Kumar
0 siblings, 0 replies; only message in thread
From: Madhur Kumar @ 2025-10-04 19:58 UTC (permalink / raw)
To: brauner, jlayton, geert+renesas, arnd; +Cc: linux-kernel, Madhur Kumar
The test-statx program in samples/vfs/ includes both <stdio.h> and
usr/include/linux/fcntl.h, leading to redefinition errors for
AT_RENAME_NOREPLACE, AT_RENAME_EXCHANGE, and AT_RENAME_WHITEOUT. These
macros, defined in both glibc headers (via <stdio.h>, likely including
<fcntl.h>) and the kernel's usr/include/linux/fcntl.h, are not directly
used in test-statx.c but cause a build failure with -Werror due to
redefinition warnings like:
In file included from samples/vfs/test-statx.c:23:
usr/include/linux/fcntl.h:160:9: error: ‘AT_RENAME_NOREPLACE’ redefined [-Werror]
160 | #define AT_RENAME_NOREPLACE 0x0001
| ^~~~~~~~~~~~~~~~~~~
In file included from samples/vfs/test-statx.c:13:
/usr/include/stdio.h:171:10: note: this is the location of the previous definition
171 | # define AT_RENAME_NOREPLACE RENAME_NOREPLACE
| ^~~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:161:9: error: ‘AT_RENAME_EXCHANGE’ redefined [-Werror]
161 | #define AT_RENAME_EXCHANGE 0x0002
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:173:10: note: this is the location of the previous definition
173 | # define AT_RENAME_EXCHANGE RENAME_EXCHANGE
| ^~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:162:9: error: ‘AT_RENAME_WHITEOUT’ redefined [-Werror]
162 | #define AT_RENAME_WHITEOUT 0x0004
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:175:10: note: this is the location of the previous definition
175 | # define AT_RENAME_WHITEOUT RENAME_WHITEOUT
| ^~~~~~~~~~~~~~~~~~
Since test-statx relies on other kernel-specific definitions from
usr/include/linux/fcntl.h, this patch adds #undef directives for the
conflicting macros before including the kernel header, ensuring the
kernel's definitions are used without warnings.
Signed-off-by: Madhur Kumar <madhurkumar004@gmail.com>
---
samples/vfs/test-statx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
index 49c7a46cee07..17332100a2b5 100644
--- a/samples/vfs/test-statx.c
+++ b/samples/vfs/test-statx.c
@@ -20,6 +20,9 @@
#include <sys/syscall.h>
#include <sys/types.h>
#include <linux/stat.h>
+#undef AT_RENAME_NOREPLACE
+#undef AT_RENAME_EXCHANGE
+#undef AT_RENAME_WHITEOUT
#include <linux/fcntl.h>
#define statx foo
#define statx_timestamp foo_timestamp
--
2.51.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-10-04 19:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-04 19:58 [PATCH] samples/vfs: Undefine conflicting AT_RENAME_* macros in test-statx Madhur Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®