From b5d7a75a22dfed59750434c0c8ce1d517ba4598c Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 26 Dec 2011 20:12:48 +0100 Subject: [PATCH] Return ECHO flag from TIOCGETA ioctl This patch sets the ECHO flag for the TIOCGETA ioctrl operation. This flag is examined by libreadline to control the policy of echoing user input. This patch in needed to run bash in interactive mode in Noux. --- ports/src/lib/libc_noux/plugin.cc | 25 ++++++++++++++++++++++++- ports/src/noux-pkg/bash/target.mk | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ports/src/lib/libc_noux/plugin.cc b/ports/src/lib/libc_noux/plugin.cc index 872d7abbe1..718e2c857a 100644 --- a/ports/src/lib/libc_noux/plugin.cc +++ b/ports/src/lib/libc_noux/plugin.cc @@ -34,6 +34,7 @@ #include #include #include +#include @@ -365,6 +366,10 @@ namespace { sysio()->open_in.mode = flags; if (!noux()->syscall(Noux::Session::SYSCALL_OPEN)) { + /* + * XXX we should return meaningful errno values + */ + errno = ENOENT; return 0; } @@ -474,7 +479,24 @@ namespace { sysio()->ioctl_in.request = Noux::Sysio::Ioctl_in::OP_TIOCGWINSZ; break; + case TIOCGETA: + { + PDBG("TIOCGETA - argp=0x%p", argp); + ::termios *termios = (::termios *)argp; + + /* + * Set 'ECHO' flag, needed by libreadline. Otherwise, echoing + * user input doesn't work in bash. + */ + termios->c_lflag = ECHO; + return 0; + } + + break; + default: + + PWRN("unsupported ioctl (request=0x%x", request); break; } @@ -535,6 +557,7 @@ namespace { break; case F_GETFL: + PINF("fcntl: F_GETFL for libc_fd=%d", fd->libc_fd); sysio()->fcntl_in.cmd = Noux::Sysio::FCNTL_CMD_GET_FILE_STATUS_FLAGS; break; @@ -546,7 +569,7 @@ namespace { /* invoke system call */ if (!noux()->syscall(Noux::Session::SYSCALL_FCNTL)) { - PWRN("fcntl failed"); + PWRN("fcntl failed (libc_fd= %d, cmd=%x)", fd->libc_fd, cmd); /* XXX read error code from sysio */ errno = EINVAL; return -1; diff --git a/ports/src/noux-pkg/bash/target.mk b/ports/src/noux-pkg/bash/target.mk index e36757b7c8..5d71c69769 100644 --- a/ports/src/noux-pkg/bash/target.mk +++ b/ports/src/noux-pkg/bash/target.mk @@ -1,4 +1,4 @@ -NOUX_CONFIGURE_ARGS = --disable-readline --without-bash-malloc +NOUX_CONFIGURE_ARGS = --without-bash-malloc NOUX_CFLAGS += -Dsh_xfree=free #