This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / s390 / char / sclp_tty.c
index 3491615..cd11cb1 100644 (file)
@@ -395,14 +395,36 @@ sclp_tty_write_string(const unsigned char *str, int count)
  * routine will return the number of characters actually accepted for writing.
  */
 static int
-sclp_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
+sclp_tty_write(struct tty_struct *tty, int from_user,
+              const unsigned char *buf, int count)
 {
+       int length, ret;
+
        if (sclp_tty_chars_count > 0) {
                sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count);
                sclp_tty_chars_count = 0;
        }
-       sclp_tty_write_string(buf, count);
-       return count;
+       if (!from_user) {
+               sclp_tty_write_string(buf, count);
+               return count;
+       }
+       ret = 0;
+       while (count > 0) {
+               length = count < SCLP_TTY_BUF_SIZE ?
+                       count : SCLP_TTY_BUF_SIZE;
+               length -= copy_from_user(sclp_tty_chars,
+                               (const unsigned char __user *)buf, length);
+               if (length == 0) {
+                       if (!ret)
+                               ret = -EFAULT;
+                       break;
+               }
+               sclp_tty_write_string(sclp_tty_chars, length);
+               buf += length;
+               count -= length;
+               ret += length;
+       }
+       return ret;
 }
 
 /*
@@ -601,7 +623,7 @@ sclp_get_input(unsigned char *start, unsigned char *end)
 
        /* if set in ioctl write operators input to console  */
        if (sclp_ioctls.echo)
-               sclp_tty_write(sclp_tty, start, count);
+               sclp_tty_write(sclp_tty, 0, start, count);
 
        /* transfer input to high level driver */
        sclp_tty_input(start, count);