[PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0

Helge Deller posted 12 patches 3 years, 4 months ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Richard Henderson <richard.henderson@linaro.org>
[PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0
Posted by Helge Deller 3 years, 4 months ago
If the mode parameter of chmod() is zero, this value isn't shown
when stracing a program:
    chmod("filename",)
This patch fixes it up to show the zero-value as well:
    chmod("filename",000)

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 5ac64df02b..2f539845bb 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1505,6 +1505,11 @@ print_file_mode(abi_long mode, int last)
     const char *sep = "";
     const struct flags *m;

+    if (mode == 0) {
+        qemu_log("000%s", get_comma(last));
+        return;
+    }
+
     for (m = &mode_flags[0]; m->f_string != NULL; m++) {
         if ((m->f_value & mode) == m->f_value) {
             qemu_log("%s%s", m->f_string, sep);
--
2.37.3
Re: [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0
Posted by Laurent Vivier 3 years, 4 months ago
Le 18/09/2022 à 21:45, Helge Deller a écrit :
> If the mode parameter of chmod() is zero, this value isn't shown
> when stracing a program:
>      chmod("filename",)
> This patch fixes it up to show the zero-value as well:
>      chmod("filename",000)
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 5ac64df02b..2f539845bb 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1505,6 +1505,11 @@ print_file_mode(abi_long mode, int last)
>       const char *sep = "";
>       const struct flags *m;
> 
> +    if (mode == 0) {
> +        qemu_log("000%s", get_comma(last));
> +        return;
> +    }
> +
>       for (m = &mode_flags[0]; m->f_string != NULL; m++) {
>           if ((m->f_value & mode) == m->f_value) {
>               qemu_log("%s%s", m->f_string, sep);
> --
> 2.37.3
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> 


Re: [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0
Posted by Philippe Mathieu-Daudé via 3 years, 4 months ago
On 18/9/22 21:45, Helge Deller wrote:
> If the mode parameter of chmod() is zero, this value isn't shown
> when stracing a program:
>      chmod("filename",)
> This patch fixes it up to show the zero-value as well:
>      chmod("filename",000)
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 5ac64df02b..2f539845bb 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1505,6 +1505,11 @@ print_file_mode(abi_long mode, int last)
>       const char *sep = "";
>       const struct flags *m;
> 
> +    if (mode == 0) {
> +        qemu_log("000%s", get_comma(last));

I'd use either 0 or 0000, not 000...

Preferably using a single 0:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> +        return;
> +    }
> +
>       for (m = &mode_flags[0]; m->f_string != NULL; m++) {
>           if ((m->f_value & mode) == m->f_value) {
>               qemu_log("%s%s", m->f_string, sep);
> --
> 2.37.3
> 
>