This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / char / tty_io.c
index 91f530c..5e49ad3 100644 (file)
@@ -345,12 +345,18 @@ EXPORT_SYMBOL(tty_check_change);
 static ssize_t hung_up_tty_read(struct file * file, char __user * buf,
                                size_t count, loff_t *ppos)
 {
+       /* Can't seek (pread) on ttys.  */
+       if (ppos != &file->f_pos)
+               return -ESPIPE;
        return 0;
 }
 
 static ssize_t hung_up_tty_write(struct file * file, const char __user * buf,
                                 size_t count, loff_t *ppos)
 {
+       /* Can't seek (pwrite) on ttys.  */
+       if (ppos != &file->f_pos)
+               return -ESPIPE;
        return -EIO;
 }
 
@@ -642,6 +648,10 @@ static ssize_t tty_read(struct file * file, char __user * buf, size_t count,
        struct tty_struct * tty;
        struct inode *inode;
 
+       /* Can't seek (pread) on ttys.  */
+       if (ppos != &file->f_pos)
+               return -ESPIPE;
+
        tty = (struct tty_struct *)file->private_data;
        inode = file->f_dentry->d_inode;
        if (tty_paranoia_check(tty, inode, "tty_read"))
@@ -716,6 +726,10 @@ static ssize_t tty_write(struct file * file, const char __user * buf, size_t cou
        struct tty_struct * tty;
        struct inode *inode = file->f_dentry->d_inode;
 
+       /* Can't seek (pwrite) on ttys.  */
+       if (ppos != &file->f_pos)
+               return -ESPIPE;
+
        tty = (struct tty_struct *)file->private_data;
        if (tty_paranoia_check(tty, inode, "tty_write"))
                return -EIO;
@@ -741,6 +755,9 @@ ssize_t redirected_tty_write(struct file * file, const char __user * buf, size_t
 
        if (p) {
                ssize_t res;
+               /* Can't seek (pwrite) on ttys.  */
+               if (ppos != &file->f_pos)
+                       return -ESPIPE;
                res = vfs_write(p, buf, count, &p->f_pos);
                fput(p);
                return res;
@@ -1051,7 +1068,7 @@ static void release_dev(struct file * filp)
 {
        struct tty_struct *tty, *o_tty;
        int     pty_master, tty_closing, o_tty_closing, do_sleep;
-       int     devpts_master, devpts;
+       int     devpts_master;
        int     idx;
        char    buf[64];
        
@@ -1066,8 +1083,7 @@ static void release_dev(struct file * filp)
        idx = tty->index;
        pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
                      tty->driver->subtype == PTY_TYPE_MASTER);
-       devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0;
-       devpts_master = pty_master && devpts;
+       devpts_master = pty_master && (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM);
        o_tty = tty->link;
 
 #ifdef TTY_PARANOIA_CHECK
@@ -1292,7 +1308,7 @@ static void release_dev(struct file * filp)
 
 #ifdef CONFIG_UNIX98_PTYS
        /* Make this pty number available for reallocation */
-       if (devpts) {
+       if (devpts_master) {
                down(&allocated_ptys_lock);
                idr_remove(&allocated_ptys, idx);
                up(&allocated_ptys_lock);
@@ -1322,7 +1338,6 @@ static int tty_open(struct inode * inode, struct file * filp)
        dev_t device = inode->i_rdev;
        unsigned short saved_flags = filp->f_flags;
 
-       nonseekable_open(inode, filp);
 retry_open:
        noctty = filp->f_flags & O_NOCTTY;
        index  = -1;