Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c5c34d4862e18ef07c1276d233507f540fb5a532 Commit: c5c34d4862e18ef07c1276d233507f540fb5a532 Parent: e3bf460f3eb86cdbc76725a0dac1f191e796676c Author: Paul Fulghum <[EMAIL PROTECTED]> AuthorDate: Sat May 12 10:36:55 2007 -0700 Committer: Linus Torvalds <[EMAIL PROTECTED]> CommitDate: Sat May 12 10:55:39 2007 -0700
tty: flush flip buffer on ldisc input queue flush Flush the tty flip buffer when the line discipline input queue is flushed, including the user call tcflush(TCIFLUSH/TCIOFLUSH). This prevents unexpected stale data after a user application calls tcflush(). Signed-off-by: Alan Cox <[EMAIL PROTECTED]> Cc: Antonino Ingargiola <[EMAIL PROTECTED]> Signed-off-by: Paul Fulghum <[EMAIL PROTECTED]> Cc: Theodore Ts'o <[EMAIL PROTECTED]> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]> Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]> --- drivers/char/tty_io.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index bc84995..75d2a46 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -369,6 +369,29 @@ static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b) } /** + * tty_buffer_flush - flush full tty buffers + * @tty: tty to flush + * + * flush all the buffers containing receive data + * + * Locking: none + */ + +static void tty_buffer_flush(struct tty_struct *tty) +{ + struct tty_buffer *thead; + unsigned long flags; + + spin_lock_irqsave(&tty->buf.lock, flags); + while((thead = tty->buf.head) != NULL) { + tty->buf.head = thead->next; + tty_buffer_free(tty, thead); + } + tty->buf.tail = NULL; + spin_unlock_irqrestore(&tty->buf.lock, flags); +} + +/** * tty_buffer_find - find a free tty buffer * @tty: tty owning the buffer * @size: characters wanted @@ -1248,6 +1271,7 @@ void tty_ldisc_flush(struct tty_struct *tty) ld->flush_buffer(tty); tty_ldisc_deref(ld); } + tty_buffer_flush(tty); } EXPORT_SYMBOL_GPL(tty_ldisc_flush); @@ -3350,6 +3374,15 @@ int tty_ioctl(struct inode * inode, struct file * file, case TIOCMBIC: case TIOCMBIS: return tty_tiocmset(tty, file, cmd, p); + case TCFLSH: + switch (arg) { + case TCIFLUSH: + case TCIOFLUSH: + /* flush tty buffer and allow ldisc to process ioctl */ + tty_buffer_flush(tty); + break; + } + break; } if (tty->driver->ioctl) { retval = (tty->driver->ioctl)(tty, file, cmd, arg); - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html