summaryrefslogtreecommitdiffstats
path: root/drivers/char/pty.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
committer <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
commit19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch)
tree40b1cb534496a7f1ca0f5c314a523c69f1fee464 /drivers/char/pty.c
parent7206675c40394c78a90e74812bbdbf8cf3cca1be (diff)
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'drivers/char/pty.c')
-rw-r--r--drivers/char/pty.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 7c74d4524..8f1015397 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -4,14 +4,6 @@
* Copyright (C) 1991, 1992 Linus Torvalds
*/
-/*
- * pty.c
- *
- * This module exports the following pty function:
- *
- * int pty_open(struct tty_struct * tty, struct file * filp);
- */
-
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
@@ -21,6 +13,7 @@
#include <linux/string.h>
#include <linux/major.h>
#include <linux/mm.h>
+#include <linux/init.h>
#include <asm/uaccess.h>
#include <asm/system.h>
@@ -47,8 +40,8 @@ struct pty_struct {
static unsigned char *tmp_buf;
static struct semaphore tmp_buf_sem = MUTEX;
-struct tty_driver pty_driver, pty_slave_driver;
-struct tty_driver old_pty_driver, old_pty_slave_driver;
+static struct tty_driver pty_driver, pty_slave_driver;
+static struct tty_driver old_pty_driver, old_pty_slave_driver;
static int pty_refcount;
static struct tty_struct *pty_table[NR_PTYS];
@@ -74,8 +67,10 @@ static void pty_close(struct tty_struct * tty, struct file * filp)
}
wake_up_interruptible(&tty->read_wait);
wake_up_interruptible(&tty->write_wait);
+ tty->packet = 0;
if (!tty->link)
return;
+ tty->link->packet = 0;
wake_up_interruptible(&tty->link->read_wait);
wake_up_interruptible(&tty->link->write_wait);
set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
@@ -125,7 +120,12 @@ static int pty_write(struct tty_struct * tty, int from_user,
((tty->driver.subtype-1) * PTY_BUF_SIZE);
while (count > 0) {
n = MIN(count, PTY_BUF_SIZE);
- copy_from_user(temp_buffer, buf, n);
+ n -= copy_from_user(temp_buffer, buf, n);
+ if (!n) {
+ if (!c)
+ c = -EFAULT;
+ break;
+ }
r = to->ldisc.receive_room(to);
if (r <= 0)
break;
@@ -179,7 +179,7 @@ static void pty_flush_buffer(struct tty_struct *tty)
}
}
-int pty_open(struct tty_struct *tty, struct file * filp)
+static int pty_open(struct tty_struct *tty, struct file * filp)
{
int retval;
int line;
@@ -225,11 +225,12 @@ static void pty_set_termios(struct tty_struct *tty, struct termios *old_termios)
tty->termios->c_cflag |= (CS8 | CREAD);
}
-int pty_init(void)
+__initfunc(int pty_init(void))
{
memset(&pty_state, 0, sizeof(pty_state));
memset(&pty_driver, 0, sizeof(struct tty_driver));
pty_driver.magic = TTY_DRIVER_MAGIC;
+ pty_driver.driver_name = "pty_master";
pty_driver.name = "pty";
pty_driver.major = PTY_MASTER_MAJOR;
pty_driver.minor_start = 0;
@@ -258,6 +259,8 @@ int pty_init(void)
pty_driver.set_termios = pty_set_termios;
pty_slave_driver = pty_driver;
+ pty_slave_driver.driver_name = "pty_slave";
+ pty_slave_driver.proc_entry = 0;
pty_slave_driver.name = "ttyp";
pty_slave_driver.subtype = PTY_TYPE_SLAVE;
pty_slave_driver.major = PTY_SLAVE_MAJOR;
@@ -270,12 +273,16 @@ int pty_init(void)
pty_slave_driver.other = &pty_driver;
old_pty_driver = pty_driver;
+ old_pty_driver.driver_name = "compat_pty_master";
+ old_pty_driver.proc_entry = 0;
old_pty_driver.major = TTY_MAJOR;
old_pty_driver.minor_start = 128;
old_pty_driver.num = (NR_PTYS > 64) ? 64 : NR_PTYS;
old_pty_driver.other = &old_pty_slave_driver;
old_pty_slave_driver = pty_slave_driver;
+ old_pty_slave_driver.driver_name = "compat_pty_slave";
+ old_pty_slave_driver.proc_entry = 0;
old_pty_slave_driver.major = TTY_MAJOR;
old_pty_slave_driver.minor_start = 192;
old_pty_slave_driver.num = (NR_PTYS > 64) ? 64 : NR_PTYS;