* [PATCH] MIPS: Setup errno for {f,l,}xstat
@ 2021-09-07 5:31 Jiaxun Yang
2021-09-07 13:15 ` Adhemerval Zanella via Libc-alpha
0 siblings, 1 reply; 4+ messages in thread
From: Jiaxun Yang @ 2021-09-07 5:31 UTC (permalink / raw)
To: libc-alpha; +Cc: syq, xry111, Jiaxun Yang
{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(-)
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);
}
}
}
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] MIPS: Setup errno for {f,l,}xstat
2021-09-07 5:31 [PATCH] MIPS: Setup errno for {f,l,}xstat Jiaxun Yang
@ 2021-09-07 13:15 ` Adhemerval Zanella via Libc-alpha
2021-09-07 13:20 ` YunQiang Su
0 siblings, 1 reply; 4+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-09-07 13:15 UTC (permalink / raw)
To: Jiaxun Yang, libc-alpha; +Cc: syq, xry111
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);
> }
> }
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] MIPS: Setup errno for {f,l,}xstat
2021-09-07 13:15 ` Adhemerval Zanella via Libc-alpha
@ 2021-09-07 13:20 ` YunQiang Su
2021-09-07 14:04 ` Adhemerval Zanella via Libc-alpha
0 siblings, 1 reply; 4+ messages in thread
From: YunQiang Su @ 2021-09-07 13:20 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha, Xi Ruoyao, Jiaxun Yang
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);
> > }
> > }
> > }
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] MIPS: Setup errno for {f,l,}xstat
2021-09-07 13:20 ` YunQiang Su
@ 2021-09-07 14:04 ` Adhemerval Zanella via Libc-alpha
0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-09-07 14:04 UTC (permalink / raw)
To: YunQiang Su; +Cc: libc-alpha, Xi Ruoyao, Jiaxun Yang
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-07 14:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 5:31 [PATCH] MIPS: Setup errno for {f,l,}xstat Jiaxun Yang
2021-09-07 13:15 ` Adhemerval Zanella via Libc-alpha
2021-09-07 13:20 ` YunQiang Su
2021-09-07 14:04 ` Adhemerval Zanella via Libc-alpha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).