diff mbox series

MIPS: Setup errno for {f,l,}xstat

Message ID 20210907053142.1774-1-jiaxun.yang@flygoat.com
State Committed
Headers show
Series MIPS: Setup errno for {f,l,}xstat | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Jiaxun Yang Sept. 7, 2021, 5:31 a.m. UTC
{f,l,}xstat stub for MIPS is using INTERNAL_SYSCALL
to do xstat syscall for glibc ver, However it leaves
errno untouched and thus giving bad errno output.

Setup errno properly when syscall returns non-zero.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 sysdeps/unix/sysv/linux/mips/fxstat.c | 4 +++-
 sysdeps/unix/sysv/linux/mips/lxstat.c | 4 +++-
 sysdeps/unix/sysv/linux/mips/xstat.c  | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

Comments

Adhemerval Zanella Sept. 7, 2021, 1:15 p.m. UTC | #1
On 07/09/2021 02:31, Jiaxun Yang wrote:
> {f,l,}xstat stub for MIPS is using INTERNAL_SYSCALL
> to do xstat syscall for glibc ver, However it leaves
> errno untouched and thus giving bad errno output.
> 
> Setup errno properly when syscall returns non-zero.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>


LGTM, thanks.  I fixed the code style (using space instead of
tabs as the current file is doing) and pushed upstream.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/unix/sysv/linux/mips/fxstat.c | 4 +++-
>  sysdeps/unix/sysv/linux/mips/lxstat.c | 4 +++-
>  sysdeps/unix/sysv/linux/mips/xstat.c  | 4 +++-
>  3 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/mips/fxstat.c b/sysdeps/unix/sysv/linux/mips/fxstat.c
> index 11511d30b3..6d2750adcd 100644
> --- a/sysdeps/unix/sysv/linux/mips/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
> @@ -35,7 +35,9 @@ __fxstat (int vers, int fd, struct stat *buf)
>        {
>  	struct kernel_stat kbuf;
>  	int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
> -	return r ?: __xstat_conv (vers, &kbuf, buf);
> +        if (r == 0)
> +          return  __xstat_conv (vers, &kbuf, buf);
> +        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
>        }
>      }
>  }
> diff --git a/sysdeps/unix/sysv/linux/mips/lxstat.c b/sysdeps/unix/sysv/linux/mips/lxstat.c
> index 871fb6c6c5..77656be276 100644
> --- a/sysdeps/unix/sysv/linux/mips/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
> @@ -35,7 +35,9 @@ __lxstat (int vers, const char *name, struct stat *buf)
>        {
>  	struct kernel_stat kbuf;
>  	int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
> -	return r ?: __xstat_conv (vers, &kbuf, buf);
> +        if (r == 0)
> +          return  __xstat_conv (vers, &kbuf, buf);
> +        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
>        }
>      }
>  }
> diff --git a/sysdeps/unix/sysv/linux/mips/xstat.c b/sysdeps/unix/sysv/linux/mips/xstat.c
> index 9d810b6f65..4c6fabb502 100644
> --- a/sysdeps/unix/sysv/linux/mips/xstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/xstat.c
> @@ -35,7 +35,9 @@ __xstat (int vers, const char *name, struct stat *buf)
>        {
>  	struct kernel_stat kbuf;
>  	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> -	return r ?: __xstat_conv (vers, &kbuf, buf);
> +        if (r == 0)
> +          return  __xstat_conv (vers, &kbuf, buf);
> +        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
>        }
>      }
>  }
>
YunQiang Su Sept. 7, 2021, 1:20 p.m. UTC | #2
Adhemerval Zanella <adhemerval.zanella@linaro.org> 于 2021年9月7日周二 下午9:15写道:

>
>
> On 07/09/2021 02:31, Jiaxun Yang wrote:
> > {f,l,}xstat stub for MIPS is using INTERNAL_SYSCALL
> > to do xstat syscall for glibc ver, However it leaves
> > errno untouched and thus giving bad errno output.
> >
> > Setup errno properly when syscall returns non-zero.
> >
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>
>
> LGTM, thanks.  I fixed the code style (using space instead of
> tabs as the current file is doing) and pushed upstream.
>

this problem introduced in 2.33.
is it possible to backport it to 2.33 and 2.34?


> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
>
> > ---
> >  sysdeps/unix/sysv/linux/mips/fxstat.c | 4 +++-
> >  sysdeps/unix/sysv/linux/mips/lxstat.c | 4 +++-
> >  sysdeps/unix/sysv/linux/mips/xstat.c  | 4 +++-
> >  3 files changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/sysdeps/unix/sysv/linux/mips/fxstat.c
> b/sysdeps/unix/sysv/linux/mips/fxstat.c
> > index 11511d30b3..6d2750adcd 100644
> > --- a/sysdeps/unix/sysv/linux/mips/fxstat.c
> > +++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
> > @@ -35,7 +35,9 @@ __fxstat (int vers, int fd, struct stat *buf)
> >        {
> >       struct kernel_stat kbuf;
> >       int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
> > -     return r ?: __xstat_conv (vers, &kbuf, buf);
> > +        if (r == 0)
> > +          return  __xstat_conv (vers, &kbuf, buf);
> > +        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
> >        }
> >      }
> >  }
> > diff --git a/sysdeps/unix/sysv/linux/mips/lxstat.c
> b/sysdeps/unix/sysv/linux/mips/lxstat.c
> > index 871fb6c6c5..77656be276 100644
> > --- a/sysdeps/unix/sysv/linux/mips/lxstat.c
> > +++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
> > @@ -35,7 +35,9 @@ __lxstat (int vers, const char *name, struct stat *buf)
> >        {
> >       struct kernel_stat kbuf;
> >       int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
> > -     return r ?: __xstat_conv (vers, &kbuf, buf);
> > +        if (r == 0)
> > +          return  __xstat_conv (vers, &kbuf, buf);
> > +        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
> >        }
> >      }
> >  }
> > diff --git a/sysdeps/unix/sysv/linux/mips/xstat.c
> b/sysdeps/unix/sysv/linux/mips/xstat.c
> > index 9d810b6f65..4c6fabb502 100644
> > --- a/sysdeps/unix/sysv/linux/mips/xstat.c
> > +++ b/sysdeps/unix/sysv/linux/mips/xstat.c
> > @@ -35,7 +35,9 @@ __xstat (int vers, const char *name, struct stat *buf)
> >        {
> >       struct kernel_stat kbuf;
> >       int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> > -     return r ?: __xstat_conv (vers, &kbuf, buf);
> > +        if (r == 0)
> > +          return  __xstat_conv (vers, &kbuf, buf);
> > +        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
> >        }
> >      }
> >  }
> >
>
Adhemerval Zanella Sept. 7, 2021, 2:04 p.m. UTC | #3
On 07/09/2021 10:20, YunQiang Su wrote:
> 
> 
> Adhemerval Zanella <adhemerval.zanella@linaro.org <mailto:adhemerval.zanella@linaro.org>> 于 2021年9月7日周二 下午9:15写道:
> 
> 
> 
>     On 07/09/2021 02:31, Jiaxun Yang wrote:
>     > {f,l,}xstat stub for MIPS is using INTERNAL_SYSCALL
>     > to do xstat syscall for glibc ver, However it leaves
>     > errno untouched and thus giving bad errno output.
>     >
>     > Setup errno properly when syscall returns non-zero.
>     >
>     > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com <mailto:jiaxun.yang@flygoat.com>>
> 
> 
>     LGTM, thanks.  I fixed the code style (using space instead of
>     tabs as the current file is doing) and pushed upstream.
> 
> 
> this problem introduced in 2.33.
> is it possible to backport it to 2.33 and 2.34?

Done.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/mips/fxstat.c b/sysdeps/unix/sysv/linux/mips/fxstat.c
index 11511d30b3..6d2750adcd 100644
--- a/sysdeps/unix/sysv/linux/mips/fxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
@@ -35,7 +35,9 @@  __fxstat (int vers, int fd, struct stat *buf)
       {
 	struct kernel_stat kbuf;
 	int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
-	return r ?: __xstat_conv (vers, &kbuf, buf);
+        if (r == 0)
+          return  __xstat_conv (vers, &kbuf, buf);
+        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
       }
     }
 }
diff --git a/sysdeps/unix/sysv/linux/mips/lxstat.c b/sysdeps/unix/sysv/linux/mips/lxstat.c
index 871fb6c6c5..77656be276 100644
--- a/sysdeps/unix/sysv/linux/mips/lxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
@@ -35,7 +35,9 @@  __lxstat (int vers, const char *name, struct stat *buf)
       {
 	struct kernel_stat kbuf;
 	int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
-	return r ?: __xstat_conv (vers, &kbuf, buf);
+        if (r == 0)
+          return  __xstat_conv (vers, &kbuf, buf);
+        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
       }
     }
 }
diff --git a/sysdeps/unix/sysv/linux/mips/xstat.c b/sysdeps/unix/sysv/linux/mips/xstat.c
index 9d810b6f65..4c6fabb502 100644
--- a/sysdeps/unix/sysv/linux/mips/xstat.c
+++ b/sysdeps/unix/sysv/linux/mips/xstat.c
@@ -35,7 +35,9 @@  __xstat (int vers, const char *name, struct stat *buf)
       {
 	struct kernel_stat kbuf;
 	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
-	return r ?: __xstat_conv (vers, &kbuf, buf);
+        if (r == 0)
+          return  __xstat_conv (vers, &kbuf, buf);
+        return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
       }
     }
 }