[PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions

Masaharu Noguchi posted 2 patches 1 month, 1 week ago
[PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
Posted by Masaharu Noguchi 1 month, 1 week ago
Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
---
 samples/vfs/test-statx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
index 49c7a46cee07..eabea80e9db8 100644
--- a/samples/vfs/test-statx.c
+++ b/samples/vfs/test-statx.c
@@ -20,6 +20,15 @@
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <linux/stat.h>
+#ifdef AT_RENAME_NOREPLACE
+#undef AT_RENAME_NOREPLACE
+#endif
+#ifdef AT_RENAME_EXCHANGE
+#undef AT_RENAME_EXCHANGE
+#endif
+#ifdef AT_RENAME_WHITEOUT
+#undef AT_RENAME_WHITEOUT
+#endif
 #include <linux/fcntl.h>
 #define statx foo
 #define statx_timestamp foo_timestamp
-- 
2.51.1
Re: [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
Posted by David Laight 1 month, 1 week ago
On Sun,  9 Nov 2025 16:13:04 +0900
Masaharu Noguchi <nogunix@gmail.com> wrote:

> Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
> ---
>  samples/vfs/test-statx.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
> index 49c7a46cee07..eabea80e9db8 100644
> --- a/samples/vfs/test-statx.c
> +++ b/samples/vfs/test-statx.c
> @@ -20,6 +20,15 @@
>  #include <sys/syscall.h>
>  #include <sys/types.h>
>  #include <linux/stat.h>
> +#ifdef AT_RENAME_NOREPLACE
> +#undef AT_RENAME_NOREPLACE
> +#endif
> +#ifdef AT_RENAME_EXCHANGE
> +#undef AT_RENAME_EXCHANGE
> +#endif
> +#ifdef AT_RENAME_WHITEOUT
> +#undef AT_RENAME_WHITEOUT
> +#endif

There is no need for the #if, just #undef the symbols.
It is probably worthy of a short comment.

	David

>  #include <linux/fcntl.h>
>  #define statx foo
>  #define statx_timestamp foo_timestamp