]> code.ossystems Code Review - openembedded-core.git/blob
216fca7a2b64ad3e9f74b1debbf9409dc4c29742
[openembedded-core.git] /
1 commit ee5aa7b8b98774f408d20a2f61f97a89ac66c29b
2 Author: Joe Peterson <joe@skyrush.com>
3 Date:   Wed Sep 9 15:03:13 2009 -0600
4
5     n_tty: honor opost flag for echoes
6     
7     Fixes the following bug:
8     
9           http://bugs.linuxbase.org/show_bug.cgi?id=2692
10     
11     Causes processing of echoed characters (output from the echo buffer) to
12     honor the O_OPOST flag, which is consistent with the old behavior.
13     
14     Note that this and the next patch ("n_tty: move echoctl check and
15     clean up logic") were verified together by the bug reporters, and
16     the test now passes.
17     
18     Signed-off-by: Joe Peterson <joe@skyrush.com>
19     Cc: Linux Torvalds <torvalds@linux-foundation.org>
20     Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
21
22 diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
23 index 4e28b35..e6eeeb2 100644
24 --- a/drivers/char/n_tty.c
25 +++ b/drivers/char/n_tty.c
26 @@ -272,7 +272,8 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty)
27   *
28   *     This is a helper function that handles one output character
29   *     (including special characters like TAB, CR, LF, etc.),
30 - *     putting the results in the tty driver's write buffer.
31 + *     doing OPOST processing and putting the results in the
32 + *     tty driver's write buffer.
33   *
34   *     Note that Linux currently ignores TABDLY, CRDLY, VTDLY, FFDLY
35   *     and NLDLY.  They simply aren't relevant in the world today.
36 @@ -350,8 +351,9 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
37   *     @c: character (or partial unicode symbol)
38   *     @tty: terminal device
39   *
40 - *     Perform OPOST processing.  Returns -1 when the output device is
41 - *     full and the character must be retried.
42 + *     Output one character with OPOST processing.
43 + *     Returns -1 when the output device is full and the character
44 + *     must be retried.
45   *
46   *     Locking: output_lock to protect column state and space left
47   *              (also, this is called from n_tty_write under the
48 @@ -377,8 +379,11 @@ static int process_output(unsigned char c, struct tty_struct *tty)
49  /**
50   *     process_output_block            -       block post processor
51   *     @tty: terminal device
52 - *     @inbuf: user buffer
53 - *     @nr: number of bytes
54 + *     @buf: character buffer
55 + *     @nr: number of bytes to output
56 + *
57 + *     Output a block of characters with OPOST processing.
58 + *     Returns the number of characters output.
59   *
60   *     This path is used to speed up block console writes, among other
61   *     things when processing blocks of output data. It handles only
62 @@ -605,12 +610,18 @@ static void process_echoes(struct tty_struct *tty)
63                         if (no_space_left)
64                                 break;
65                 } else {
66 -                       int retval;
67 -
68 -                       retval = do_output_char(c, tty, space);
69 -                       if (retval < 0)
70 -                               break;
71 -                       space -= retval;
72 +                       if (O_OPOST(tty) &&
73 +                           !(test_bit(TTY_HW_COOK_OUT, &tty->flags))) {
74 +                               int retval = do_output_char(c, tty, space);
75 +                               if (retval < 0)
76 +                                       break;
77 +                               space -= retval;
78 +                       } else {
79 +                               if (!space)
80 +                                       break;
81 +                               tty_put_char(tty, c);
82 +                               space -= 1;
83 +                       }
84                         cp += 1;
85                         nr -= 1;
86                 }