vserver 1.9.5.x5
[linux-2.6.git] / drivers / char / n_tty.c
index 5a3be05..ae09412 100644 (file)
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 /* number of characters left in xmit buffer before select has we have room */
 #define WAKEUP_CHARS 256
@@ -152,7 +152,7 @@ static void reset_buffer_flags(struct tty_struct *tty)
  *     lock_kernel() still.
  */
  
-void n_tty_flush_buffer(struct tty_struct * tty)
+static void n_tty_flush_buffer(struct tty_struct * tty)
 {
        /* clear everything and unthrottle the driver */
        reset_buffer_flags(tty);
@@ -174,7 +174,7 @@ void n_tty_flush_buffer(struct tty_struct * tty)
  *     at this instant in time. 
  */
  
-ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
+static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
 {
        unsigned long flags;
        ssize_t n = 0;
@@ -270,7 +270,7 @@ static int opost(unsigned char c, struct tty_struct *tty)
                                if (space < spaces)
                                        return -1;
                                tty->column += spaces;
-                               tty->driver->write(tty, 0, "        ", spaces);
+                               tty->driver->write(tty, "        ", spaces);
                                return 0;
                        }
                        tty->column += spaces;
@@ -306,23 +306,17 @@ static int opost(unsigned char c, struct tty_struct *tty)
  */
  
 static ssize_t opost_block(struct tty_struct * tty,
-                      const unsigned char __user * inbuf, unsigned int nr)
+                      const unsigned char buf, unsigned int nr)
 {
-       char    buf[80];
        int     space;
        int     i;
-       char    *cp;
+       const unsigned char *cp;
 
        space = tty->driver->write_room(tty);
        if (!space)
                return 0;
        if (nr > space)
                nr = space;
-       if (nr > sizeof(buf))
-           nr = sizeof(buf);
-
-       if (copy_from_user(buf, inbuf, nr))
-               return -EFAULT;
 
        for (i = 0, cp = buf; i < nr; i++, cp++) {
                switch (*cp) {
@@ -336,12 +330,8 @@ static ssize_t opost_block(struct tty_struct * tty,
                case '\r':
                        if (O_ONOCR(tty) && tty->column == 0)
                                goto break_out;
-                       if (O_OCRNL(tty)) {
-                               *cp = '\n';
-                               if (O_ONLRET(tty))
-                                       tty->canon_column = tty->column = 0;
-                               break;
-                       }
+                       if (O_OCRNL(tty))
+                               goto break_out;
                        tty->canon_column = tty->column = 0;
                        break;
                case '\t':
@@ -352,7 +342,7 @@ static ssize_t opost_block(struct tty_struct * tty,
                        break;
                default:
                        if (O_OLCUC(tty))
-                               *cp = toupper(*cp);
+                               goto break_out;
                        if (!iscntrl(*cp))
                                tty->column++;
                        break;
@@ -361,7 +351,7 @@ static ssize_t opost_block(struct tty_struct * tty,
 break_out:
        if (tty->driver->flush_chars)
                tty->driver->flush_chars(tty);
-       i = tty->driver->write(tty, 0, buf, i); 
+       i = tty->driver->write(tty, buf, i);    
        return i;
 }
 
@@ -1151,13 +1141,13 @@ static inline int copy_from_read_buf(struct tty_struct *tty,
 
 {
        int retval;
-       ssize_t n;
+       size_t n;
        unsigned long flags;
 
        retval = 0;
        spin_lock_irqsave(&tty->read_lock, flags);
        n = min(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail);
-       n = min((ssize_t)*nr, n);
+       n = min(*nr, n);
        spin_unlock_irqrestore(&tty->read_lock, flags);
        if (n) {
                mb();
@@ -1435,9 +1425,9 @@ do_it_again:
  */
  
 static ssize_t write_chan(struct tty_struct * tty, struct file * file,
-                         const unsigned char __user * buf, size_t nr)
+                         const unsigned char * buf, size_t nr)
 {
-       const unsigned char __user *b = buf;
+       const unsigned char *b = buf;
        DECLARE_WAITQUEUE(wait, current);
        int c;
        ssize_t retval = 0;
@@ -1473,7 +1463,7 @@ static ssize_t write_chan(struct tty_struct * tty, struct file * file,
                                nr -= num;
                                if (nr == 0)
                                        break;
-                               get_user(c, b);
+                               c = *b;
                                if (opost(c, tty) < 0)
                                        break;
                                b++; nr--;
@@ -1481,7 +1471,7 @@ static ssize_t write_chan(struct tty_struct * tty, struct file * file,
                        if (tty->driver->flush_chars)
                                tty->driver->flush_chars(tty);
                } else {
-                       c = tty->driver->write(tty, 1, b, nr);
+                       c = tty->driver->write(tty, b, nr);
                        if (c < 0) {
                                retval = c;
                                goto break_out;