patch-2.0.21-2.1.0 linux/drivers/char/pty.c
Next file: linux/drivers/char/random.c
Previous file: linux/drivers/char/psaux.c
Back to the patch index
Back to the overall index
- Lines: 81
- Date:
Sat Sep 28 22:58:22 1996
- Orig file:
lx2.0/v2.0.21/linux/drivers/char/pty.c
- Orig date:
Wed Jul 17 15:10:03 1996
diff -u --recursive --new-file lx2.0/v2.0.21/linux/drivers/char/pty.c linux/drivers/char/pty.c
@@ -181,66 +181,41 @@
int pty_open(struct tty_struct *tty, struct file * filp)
{
-#if PTY_SLAVE_WAITS_ON_OPEN
- struct wait_queue wait = { current, NULL };
-#endif
int retval;
int line;
struct pty_struct *pty;
-
+
+ retval = -ENODEV;
if (!tty || !tty->link)
- return -ENODEV;
+ goto out;
line = MINOR(tty->device) - tty->driver.minor_start;
if ((line < 0) || (line >= NR_PTYS))
- return -ENODEV;
+ goto out;
pty = pty_state + line;
tty->driver_data = pty;
if (!tmp_buf) {
- unsigned long page = get_free_page(GFP_KERNEL);
+ unsigned long page = __get_free_page(GFP_KERNEL);
if (!tmp_buf) {
+ retval = -ENOMEM;
if (!page)
- return -ENOMEM;
+ goto out;
tmp_buf = (unsigned char *) page;
+ memset((void *) page, 0, PAGE_SIZE);
} else
free_page(page);
}
+ retval = -EIO;
+ if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
+ goto out;
+ if (tty->link->count != 1)
+ goto out;
clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
wake_up_interruptible(&pty->open_wait);
set_bit(TTY_THROTTLED, &tty->flags);
- if (filp->f_flags & O_NDELAY)
- return 0;
- /*
- * If we're opening the master pty, just return. If we're
- * trying to open the slave pty, then we have to wait for the
- * master pty to open.
- */
- if (tty->driver.subtype == PTY_TYPE_MASTER)
- return 0;
retval = 0;
-#if PTY_SLAVE_WAITS_ON_OPEN
- add_wait_queue(&pty->open_wait, &wait);
- while (1) {
- if (current->signal & ~current->blocked) {
- retval = -ERESTARTSYS;
- break;
- }
- /*
- * Block until the master is open...
- */
- current->state = TASK_INTERRUPTIBLE;
- if (tty->link->count &&
- !test_bit(TTY_OTHER_CLOSED, &tty->flags))
- break;
- schedule();
- }
- current->state = TASK_RUNNING;
- remove_wait_queue(&pty->open_wait, &wait);
-#else
- if (!tty->link->count || test_bit(TTY_OTHER_CLOSED, &tty->flags))
- retval = -EPERM;
-#endif
+out:
return retval;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov