Le 20/12/2021 à 21:24, Richard Henderson a écrit :
The current api from safe_syscall_base() is to return -errno, which is
the interface provided by *some* linux kernel abis.  The wrapper macro,
safe_syscall(), detects error, stores into errno, and returns -1, to
match the api of the system syscall().

For those kernel abis that do not return -errno natively, this leads
to double syscall error detection.  E.g. Linux ppc64, which sets the
SO flag for error.

Simplify the usage from C by moving the error detection into assembly,
and usage from assembly by providing a C helper with which to set errno.

Reviewed-by: Warner Losh <i...@bsdimp.com>
Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
---
  linux-user/safe-syscall.h                  | 16 +++-------
  linux-user/safe-syscall-error.c            | 28 ++++++++++++++++
  linux-user/host/aarch64/safe-syscall.inc.S | 20 ++++++------
  linux-user/host/arm/safe-syscall.inc.S     | 27 ++++++++++------
  linux-user/host/i386/safe-syscall.inc.S    | 37 +++++++++++++++-------
  linux-user/host/ppc64/safe-syscall.inc.S   | 24 +++++++-------
  linux-user/host/riscv/safe-syscall.inc.S   | 20 ++++++------
  linux-user/host/s390x/safe-syscall.inc.S   | 32 ++++++++++++-------
  linux-user/host/x86_64/safe-syscall.inc.S  | 29 +++++++++--------
  linux-user/meson.build                     |  1 +
  10 files changed, 147 insertions(+), 87 deletions(-)
  create mode 100644 linux-user/safe-syscall-error.c



This patch breaks command execution in bash command line interface:

- if I run "chroot chroot/powerpc/jessie ls", it works

- if I run "echo ls |  chroot chroot/powerpc/jessie", it hangs

- if I run "chroot chroot/powerpc/jessie bash invalid_command",
  it does nothing whereas it should return "bash: invalid_command: No such file or 
directory".

I think the exit status of the command is not correctly detected by bash.

Thanks,
Laurent




Reply via email to