MIPS: Setup errno for {f,l,}xstat
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
{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
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);
> }
> }
> }
>
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);
> > }
> > }
> > }
> >
>
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.
@@ -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);
}
}
}
@@ -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);
}
}
}
@@ -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);
}
}
}