]> Pileus Git - ~andy/linux/blobdiff - drivers/tty/pty.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi...
[~andy/linux] / drivers / tty / pty.c
index c24b4db243b97fb97721730c6b5a7f57c2966ace..abfd9908978188ffe3bfd7a9c3aa3e8c6700c5d9 100644 (file)
@@ -244,14 +244,9 @@ static void pty_flush_buffer(struct tty_struct *tty)
 
 static int pty_open(struct tty_struct *tty, struct file *filp)
 {
-       int     retval = -ENODEV;
-
        if (!tty || !tty->link)
-               goto out;
-
-       set_bit(TTY_IO_ERROR, &tty->flags);
+               return -ENODEV;
 
-       retval = -EIO;
        if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
                goto out;
        if (test_bit(TTY_PTY_LOCK, &tty->link->flags))
@@ -262,9 +257,11 @@ static int pty_open(struct tty_struct *tty, struct file *filp)
        clear_bit(TTY_IO_ERROR, &tty->flags);
        clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
        set_bit(TTY_THROTTLED, &tty->flags);
-       retval = 0;
+       return 0;
+
 out:
-       return retval;
+       set_bit(TTY_IO_ERROR, &tty->flags);
+       return -EIO;
 }
 
 static void pty_set_termios(struct tty_struct *tty,
@@ -405,15 +402,8 @@ err:
        return retval;
 }
 
-/* this is called once with whichever end is closed last */
-static void pty_unix98_shutdown(struct tty_struct *tty)
-{
-       devpts_kill_index(tty->driver_data, tty->index);
-}
-
 static void pty_cleanup(struct tty_struct *tty)
 {
-       tty->port->itty = NULL;
        tty_port_put(tty->port);
 }
 
@@ -627,6 +617,12 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
 {
 }
 
+/* this is called once with whichever end is closed last */
+static void pty_unix98_shutdown(struct tty_struct *tty)
+{
+       devpts_kill_index(tty->driver_data, tty->index);
+}
+
 static const struct tty_operations ptm_unix98_ops = {
        .lookup = ptm_unix98_lookup,
        .install = pty_unix98_install,
@@ -682,6 +678,9 @@ static int ptmx_open(struct inode *inode, struct file *filp)
 
        nonseekable_open(inode, filp);
 
+       /* We refuse fsnotify events on ptmx, since it's a shared resource */
+       filp->f_mode |= FMODE_NONOTIFY;
+
        retval = tty_alloc_file(filp);
        if (retval)
                return retval;