public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] n_tty: honor opost flag for echoes
@ 2009-08-04 20:31 Joe Peterson
  2009-08-04 21:25 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Peterson @ 2009-08-04 20:31 UTC (permalink / raw)
  To: gregkh, Alan Cox, Andrew Morton; +Cc: Linux Kernel

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: n_tty-honor-opost-flag-for-echoes.patch --]
[-- Type: text/plain, Size: 3706 bytes --]

Fixes the following bug:

      http://bugs.linuxbase.org/show_bug.cgi?id=2692

Causes processing of echoed characters (output from the echo buffer) to
honor the O_OPOST flag.  This re-establishes this behavior.

Note that this and the next patch ("n_tty: move echoctl check and
clean up logic") were verified together by the bug reporters, and
all tty tests now pass.

Signed-off-by: Joe Peterson <joe@skyrush.com>
---

diff -Nurp a/drivers/char/n_tty.c b/drivers/char/n_tty.c
--- a/drivers/char/n_tty.c	2009-08-04 12:37:02.085287117 -0600
+++ b/drivers/char/n_tty.c	2009-08-04 12:37:14.515286140 -0600
@@ -292,54 +292,56 @@ static int do_output_char(unsigned char 
 	if (!space)
 		return -1;
 
-	switch (c) {
-	case '\n':
-		if (O_ONLRET(tty))
-			tty->column = 0;
-		if (O_ONLCR(tty)) {
-			if (space < 2)
-				return -1;
-			tty->canon_column = tty->column = 0;
-			tty_put_char(tty, '\r');
-			tty_put_char(tty, c);
-			return 2;
-		}
-		tty->canon_column = tty->column;
-		break;
-	case '\r':
-		if (O_ONOCR(tty) && tty->column == 0)
-			return 0;
-		if (O_OCRNL(tty)) {
-			c = '\n';
+	if (O_OPOST(tty)) {
+		switch (c) {
+		case '\n':
 			if (O_ONLRET(tty))
+				tty->column = 0;
+			if (O_ONLCR(tty)) {
+				if (space < 2)
+					return -1;
 				tty->canon_column = tty->column = 0;
+				tty_put_char(tty, '\r');
+				tty_put_char(tty, c);
+				return 2;
+			}
+			tty->canon_column = tty->column;
 			break;
-		}
-		tty->canon_column = tty->column = 0;
-		break;
-	case '\t':
-		spaces = 8 - (tty->column & 7);
-		if (O_TABDLY(tty) == XTABS) {
-			if (space < spaces)
-				return -1;
+		case '\r':
+			if (O_ONOCR(tty) && tty->column == 0)
+				return 0;
+			if (O_OCRNL(tty)) {
+				c = '\n';
+				if (O_ONLRET(tty))
+					tty->canon_column = tty->column = 0;
+				break;
+			}
+			tty->canon_column = tty->column = 0;
+			break;
+		case '\t':
+			spaces = 8 - (tty->column & 7);
+			if (O_TABDLY(tty) == XTABS) {
+				if (space < spaces)
+					return -1;
+				tty->column += spaces;
+				tty->ops->write(tty, "        ", spaces);
+				return spaces;
+			}
 			tty->column += spaces;
-			tty->ops->write(tty, "        ", spaces);
-			return spaces;
-		}
-		tty->column += spaces;
-		break;
-	case '\b':
-		if (tty->column > 0)
-			tty->column--;
-		break;
-	default:
-		if (!iscntrl(c)) {
-			if (O_OLCUC(tty))
-				c = toupper(c);
-			if (!is_continuation(c, tty))
-				tty->column++;
+			break;
+		case '\b':
+			if (tty->column > 0)
+				tty->column--;
+			break;
+		default:
+			if (!iscntrl(c)) {
+				if (O_OLCUC(tty))
+					c = toupper(c);
+				if (!is_continuation(c, tty))
+					tty->column++;
+			}
+			break;
 		}
-		break;
 	}
 
 	tty_put_char(tty, c);
@@ -351,8 +353,9 @@ static int do_output_char(unsigned char 
  *	@c: character (or partial unicode symbol)
  *	@tty: terminal device
  *
- *	Perform OPOST processing.  Returns -1 when the output device is
- *	full and the character must be retried.
+ *	Output a character (with OPOST processing if enabled).
+ *	Returns -1 if the output device is full and the character
+ *	must be retried.
  *
  *	Locking: output_lock to protect column state and space left
  *		 (also, this is called from n_tty_write under the
@@ -378,8 +381,11 @@ static int process_output(unsigned char 
 /**
  *	process_output_block		-	block post processor
  *	@tty: terminal device
- *	@inbuf: user buffer
- *	@nr: number of bytes
+ *	@buf: character buffer
+ *	@nr: number of bytes to output
+ *
+ *	Output a block of characters (with OPOST processing - assumed enabled).
+ *	Returns the number of characters output.
  *
  *	This path is used to speed up block console writes, among other
  *	things when processing blocks of output data. It handles only

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] n_tty: honor opost flag for echoes
  2009-08-04 20:31 [PATCH 1/2] n_tty: honor opost flag for echoes Joe Peterson
@ 2009-08-04 21:25 ` Greg KH
  2009-08-04 21:31   ` Joe Peterson
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2009-08-04 21:25 UTC (permalink / raw)
  To: Joe Peterson; +Cc: Alan Cox, Andrew Morton, Linux Kernel

On Tue, Aug 04, 2009 at 02:31:29PM -0600, Joe Peterson wrote:

> Fixes the following bug:
> 
>       http://bugs.linuxbase.org/show_bug.cgi?id=2692
> 
> Causes processing of echoed characters (output from the echo buffer) to
> honor the O_OPOST flag.  This re-establishes this behavior.
> 
> Note that this and the next patch ("n_tty: move echoctl check and
> clean up logic") were verified together by the bug reporters, and
> all tty tests now pass.

What "tty tests" would that be?  Have a pointer to them?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] n_tty: honor opost flag for echoes
  2009-08-04 21:25 ` Greg KH
@ 2009-08-04 21:31   ` Joe Peterson
  2009-08-04 23:52     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Peterson @ 2009-08-04 21:31 UTC (permalink / raw)
  To: Greg KH; +Cc: Alan Cox, Andrew Morton, Linux Kernel

Greg KH wrote:
> On Tue, Aug 04, 2009 at 02:31:29PM -0600, Joe Peterson wrote:
> 
>> Fixes the following bug:
>>
>>       http://bugs.linuxbase.org/show_bug.cgi?id=2692
>>
>> Causes processing of echoed characters (output from the echo buffer) to
>> honor the O_OPOST flag.  This re-establishes this behavior.
>>
>> Note that this and the next patch ("n_tty: move echoctl check and
>> clean up logic") were verified together by the bug reporters, and
>> all tty tests now pass.
> 
> What "tty tests" would that be?  Have a pointer to them?

It's the "Linux Standard Base" test suite:

	http://www.linuxfoundation.org/collaborate/workgroups/lsb

Here's a link to the specific code - got this from one of the reporters:

http://bzr.linux-foundation.org/lsb/devel/runtime-test?cmd=content;rev=cyeoh-20020312084903-a08971416c59e5d5;pathrevid=stewb%40linux-foundation.org-20090626205411-sfb23cc0tjj7jzgm;path=modules/vsx-pcts/tset/POSIX.os/devclass/c_lflag/c_lflag.c


						-Joe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] n_tty: honor opost flag for echoes
  2009-08-04 21:31   ` Joe Peterson
@ 2009-08-04 23:52     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2009-08-04 23:52 UTC (permalink / raw)
  To: Joe Peterson; +Cc: Alan Cox, Andrew Morton, Linux Kernel

On Tue, Aug 04, 2009 at 03:31:35PM -0600, Joe Peterson wrote:
> Greg KH wrote:
> > On Tue, Aug 04, 2009 at 02:31:29PM -0600, Joe Peterson wrote:
> > 
> >> Fixes the following bug:
> >>
> >>       http://bugs.linuxbase.org/show_bug.cgi?id=2692
> >>
> >> Causes processing of echoed characters (output from the echo buffer) to
> >> honor the O_OPOST flag.  This re-establishes this behavior.
> >>
> >> Note that this and the next patch ("n_tty: move echoctl check and
> >> clean up logic") were verified together by the bug reporters, and
> >> all tty tests now pass.
> > 
> > What "tty tests" would that be?  Have a pointer to them?
> 
> It's the "Linux Standard Base" test suite:
> 
> 	http://www.linuxfoundation.org/collaborate/workgroups/lsb
> 
> Here's a link to the specific code - got this from one of the reporters:
> 
> http://bzr.linux-foundation.org/lsb/devel/runtime-test?cmd=content;rev=cyeoh-20020312084903-a08971416c59e5d5;pathrevid=stewb%40linux-foundation.org-20090626205411-sfb23cc0tjj7jzgm;path=modules/vsx-pcts/tset/POSIX.os/devclass/c_lflag/c_lflag.c
> 

Ah, thanks, I'll dig through it.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-04 23:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-04 20:31 [PATCH 1/2] n_tty: honor opost flag for echoes Joe Peterson
2009-08-04 21:25 ` Greg KH
2009-08-04 21:31   ` Joe Peterson
2009-08-04 23:52     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox