[PATCH] linux-user: Check if RESOLVE_CACHED flag is defined before using it

frank.chang@sifive.com posted 1 patch 1 month, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260212095449.683135-1-frank.chang@sifive.com
Maintainers: Laurent Vivier <laurent@vivier.eu>, Pierrick Bouvier <pierrick.bouvier@linaro.org>
linux-user/strace.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] linux-user: Check if RESOLVE_CACHED flag is defined before using it
Posted by frank.chang@sifive.com 1 month, 4 weeks ago
From: Frank Chang <frank.chang@sifive.com>

openat2.h was introduced in Linux kernel 5.6. However, RESOLVE_CACHED
flag was only added in kernel 5.12 and later. Therefore, we need to check
if RESOLVE_CACHED flag is defined before using it.

Signed-off-by: Frank Chang <frank.chang@sifive.com>
---
 linux-user/strace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 758c5d32b6c..a903b414fd2 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1125,7 +1125,9 @@ UNUSED static const struct flags openat2_resolve_flags[] = {
     FLAG_GENERIC(RESOLVE_NO_SYMLINKS),
     FLAG_GENERIC(RESOLVE_BENEATH),
     FLAG_GENERIC(RESOLVE_IN_ROOT),
+#ifdef RESOLVE_CACHED
     FLAG_GENERIC(RESOLVE_CACHED),
+#endif
 #endif
     FLAG_END,
 };
-- 
2.43.0
Re: [PATCH] linux-user: Check if RESOLVE_CACHED flag is defined before using it
Posted by Helge Deller 1 month ago
On 2/12/26 10:54, frank.chang@sifive.com wrote:
> From: Frank Chang <frank.chang@sifive.com>
> 
> openat2.h was introduced in Linux kernel 5.6. However, RESOLVE_CACHED
> flag was only added in kernel 5.12 and later. Therefore, we need to check
> if RESOLVE_CACHED flag is defined before using it.

Is there any documentation which states what the "minimum"
required kernel for building qemu is? If we require any kernel >5.12
anyway, then this patch isn't needed.

Otherwise it's of course correct, so:
Reviewed-by: Helge Deller <deller@gmx.de>

Helge

  
> Signed-off-by: Frank Chang <frank.chang@sifive.com>
> ---
>   linux-user/strace.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 758c5d32b6c..a903b414fd2 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1125,7 +1125,9 @@ UNUSED static const struct flags openat2_resolve_flags[] = {
>       FLAG_GENERIC(RESOLVE_NO_SYMLINKS),
>       FLAG_GENERIC(RESOLVE_BENEATH),
>       FLAG_GENERIC(RESOLVE_IN_ROOT),
> +#ifdef RESOLVE_CACHED
>       FLAG_GENERIC(RESOLVE_CACHED),
> +#endif
>   #endif
>       FLAG_END,
>   };