From 02917e5cbf7f6c27812b64fd6dc068201f6a110f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Fri, 9 May 2008 18:49:47 +0000 Subject: [PATCH] - mark BeOS-specific ioctls we support for legacy apps, - add 'wsiz' which is a private alias for TIOCSWINSZ, - add some we might want to implement (or not) as reminder, - add hw signal ioctls with a note for later (call driver service func), - implement 'ichr' undocumented ioctl that waits on N chars on input, this fixes behaviour of rhapsody IRC client and many other curses apps. Oddly it seems even our own curses still uses it, that should likely be fixed as we support select(). But we must keep this one in to support apps that have their own curses lib. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25400 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/tty/tty.cpp | 59 +++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/drivers/tty/tty.cpp b/src/add-ons/kernel/drivers/tty/tty.cpp index b4b89286c8..a28ae911f5 100644 --- a/src/add-ons/kernel/drivers/tty/tty.cpp +++ b/src/add-ons/kernel/drivers/tty/tty.cpp @@ -1319,6 +1319,7 @@ tty_ioctl(tty_cookie *cookie, uint32 op, void *buffer, size_t length) TRACE(("tty_ioctl: tty %p, op %lu, buffer %p, length %lu\n", tty, op, buffer, length)); MutexLocker locker(tty->lock); + // values marked BeOS are non-standard codes we support for legacy apps switch (op) { /* blocking/non-blocking mode */ @@ -1352,8 +1353,9 @@ tty_ioctl(tty_cookie *cookie, uint32 op, void *buffer, size_t length) case TIOCGPGRP: TRACE(("tty: get pgrp_id\n")); return user_memcpy(buffer, &tty->settings->pgrp_id, sizeof(pid_t)); + case TIOCSPGRP: - case 'pgid': + case 'pgid': // BeOS { TRACE(("tty: set pgrp_id\n")); pid_t groupID; @@ -1376,6 +1378,7 @@ tty_ioctl(tty_cookie *cookie, uint32 op, void *buffer, size_t length) sizeof(struct winsize)); case TIOCSWINSZ: + case 'wsiz': // BeOS { uint16 oldColumns = tty->settings->window_size.ws_col; uint16 oldRows = tty->settings->window_size.ws_row; @@ -1420,6 +1423,60 @@ tty_ioctl(tty_cookie *cookie, uint32 op, void *buffer, size_t length) return B_OK; } + + case 'ichr': // BeOS (int *) (pre- select() support) + { + int wanted; + int toRead; + + // help identify apps using it + //dprintf("tty: warning: legacy BeOS opcode 'ichr'\n"); + + if (user_memcpy(&wanted, buffer, sizeof(int)) != B_OK) + return B_BAD_ADDRESS; + + // release the mutex and grab a read lock + locker.Unlock(); + ReaderLocker readLocker(cookie); + + do { + status_t status = readLocker.AcquireReader(wanted == 0); + if (status != B_OK) + return status; + + toRead = readLocker.AvailableBytes(); + } while (toRead < wanted); + + if (user_memcpy(buffer, &toRead, sizeof(int)) != B_OK) + return B_BAD_ADDRESS; + + return B_OK; + } + + case TCWAITEVENT: // BeOS (uint *) + // wait for event (timeout if !NULL) + case TCVTIME: // BeOS (bigtime_t *) set highrez VTIME + dprintf("tty: unsupported legacy opcode %lu\n", op); + // TODO; + break; + + case TCXONC: // Unix, but even Linux doesn't handle it + dprintf("tty: unsupported TCXONC\n"); + break; + + case TCQUERYCONNECTED: // BeOS + case 'ochr': // BeOS (int *) same as ichr for write + dprintf("tty: unsupported legacy opcode %lu\n", op); + // BeOS didn't implement them anyway + break; + + case TCSETDTR: + case TCSETRTS: + case TCGETBITS: + // TODO: should call the driver service func here, + // for non-virtual tty. + // return tty->driver->service(); + break; } TRACE(("tty: unsupported opcode %lu\n", op));