Loading drivers/char/tty_io.c +283 −278 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ * -- Russell King <rmk@arm.linux.org.uk> * * Move do_SAK() into process context. Less stack use in devfs functions. * alloc_tty_struct() always uses kmalloc() -- Andrew Morton <andrewm@uow.edu.eu> 17Mar01 * alloc_tty_struct() always uses kmalloc() * -- Andrew Morton <andrewm@uow.edu.eu> 17Mar01 */ #include <linux/types.h> Loading Loading @@ -146,7 +147,8 @@ static void initialize_tty_struct(struct tty_struct *tty); static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *); static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *); ssize_t redirected_tty_write(struct file *, const char __user *, size_t, loff_t *); ssize_t redirected_tty_write(struct file *, const char __user *, size_t, loff_t *); static unsigned int tty_poll(struct file *, poll_table *); static int tty_open(struct inode *, struct file *); static int tty_release(struct inode *, struct file *); Loading Loading @@ -608,7 +610,8 @@ EXPORT_SYMBOL(tty_schedule_flip); * Locking: May call functions taking tty->buf.lock */ int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) { int space = tty_buffer_request_room(tty, size); if (likely(space)) { Loading Loading @@ -638,7 +641,8 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); * Locking: May call functions taking tty->buf.lock */ int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) { int space = tty_buffer_request_room(tty, size); if (likely(space)) { Loading Loading @@ -681,7 +685,8 @@ static void tty_set_termios_ldisc(struct tty_struct *tty, int num) static DEFINE_SPINLOCK(tty_ldisc_lock); static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait); static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /* line disc dispatch table */ /* Line disc dispatch table */ static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /** * tty_register_ldisc - install a line discipline Loading Loading @@ -771,15 +776,13 @@ struct tty_ldisc *tty_ldisc_get(int disc) ld = &tty_ldiscs[disc]; /* Check the entry is defined */ if(ld->flags & LDISC_FLAG_DEFINED) { if (ld->flags & LDISC_FLAG_DEFINED) { /* If the module is being unloaded we can't use it */ if (!try_module_get(ld->owner)) ld = NULL; else /* lock it */ ld->refcount++; } else } else ld = NULL; spin_unlock_irqrestore(&tty_ldisc_lock, flags); return ld; Loading Loading @@ -854,8 +857,7 @@ static int tty_ldisc_try(struct tty_struct *tty) spin_lock_irqsave(&tty_ldisc_lock, flags); ld = &tty->ldisc; if(test_bit(TTY_LDISC, &tty->flags)) { if (test_bit(TTY_LDISC, &tty->flags)) { ld->refcount++; ret = 1; } Loading Loading @@ -1031,8 +1033,8 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) * There are several reasons we may be busy, including * random momentary I/O traffic. We must therefore * retry. We could distinguish between blocking ops * and retries if we made tty_ldisc_wait() smarter. That * is up for discussion. * and retries if we made tty_ldisc_wait() smarter. * That is up for discussion. */ if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) return -ERESTARTSYS; Loading @@ -1046,9 +1048,10 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) goto restart; } } /* if the TTY_LDISC bit is set, then we are racing against another ldisc change */ /* * If the TTY_LDISC bit is set, then we are racing against * another ldisc change */ if (!test_bit(TTY_LDISC, &tty->flags)) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); tty_ldisc_put(ldisc); Loading @@ -1072,7 +1075,6 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) /* * Wait for ->hangup_work and ->buf.work handlers to terminate */ flush_scheduled_work(); /* Shutdown the current discipline. */ if (tty->ldisc.close) Loading Loading @@ -1387,13 +1389,14 @@ static void do_tty_hangup(struct work_struct *work) filp->f_op = &hung_up_tty_fops; } file_list_unlock(); /* FIXME! What are the locking issues here? This may me overdoing things.. * this question is especially important now that we've removed the irqlock. */ /* * FIXME! What are the locking issues here? This may me overdoing * things... This question is especially important now that we've * removed the irqlock. */ ld = tty_ldisc_ref(tty); if(ld != NULL) /* We may have no line discipline at this point */ { if (ld != NULL) { /* We may have no line discipline at this point */ if (ld->flush_buffer) ld->flush_buffer(tty); if (tty->driver->flush_buffer) Loading @@ -1404,20 +1407,18 @@ static void do_tty_hangup(struct work_struct *work) if (ld->hangup) ld->hangup(tty); } /* FIXME: Once we trust the LDISC code better we can wait here for ldisc completion and fix the driver call race */ /* * FIXME: Once we trust the LDISC code better we can wait here for * ldisc completion and fix the driver call race */ wake_up_interruptible(&tty->write_wait); wake_up_interruptible(&tty->read_wait); /* * Shutdown the current line discipline, and reset it to * N_TTY. */ if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) tty_reset_termios(tty); /* Defer ldisc switch */ /* tty_deferred_ldisc_switch(N_TTY); Loading Loading @@ -1462,12 +1463,12 @@ static void do_tty_hangup(struct work_struct *work) tty->driver->close(tty, cons_filp); } else if (tty->driver->hangup) (tty->driver->hangup)(tty); /* We don't want to have driver/ldisc interactions beyond the ones we did here. The driver layer expects no calls after ->hangup() from the ldisc side. However we can't yet guarantee all that */ /* * We don't want to have driver/ldisc interactions beyond * the ones we did here. The driver layer expects no * calls after ->hangup() from the ldisc side. However we * can't yet guarantee all that. */ set_bit(TTY_HUPPED, &tty->flags); if (ld) { tty_ldisc_enable(tty); Loading @@ -1490,7 +1491,6 @@ void tty_hangup(struct tty_struct * tty) { #ifdef TTY_DEBUG_HANGUP char buf[64]; printk(KERN_DEBUG "%s hangup...\n", tty_name(tty, buf)); #endif schedule_work(&tty->hangup_work); Loading @@ -1516,6 +1516,7 @@ void tty_vhangup(struct tty_struct * tty) #endif do_tty_hangup(&tty->hangup_work); } EXPORT_SYMBOL(tty_vhangup); /** Loading @@ -1535,7 +1536,11 @@ EXPORT_SYMBOL(tty_hung_up_p); /** * is_tty - checker whether file is a TTY * @filp: file handle that may be a tty * * Check if the file handle is a tty handle. */ int is_tty(struct file *filp) { return filp->f_op->read == tty_read Loading Loading @@ -1711,7 +1716,6 @@ void start_tty(struct tty_struct *tty) } if (tty->driver->start) (tty->driver->start)(tty); /* If we have a running line discipline it may need kicking */ tty_wakeup(tty); } Loading Loading @@ -1891,8 +1895,8 @@ static inline ssize_t do_tty_write( * kernel lock for historical reasons. New code should not rely on this. */ static ssize_t tty_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) static ssize_t tty_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct tty_struct *tty; struct inode *inode = file->f_path.dentry->d_inode; Loading @@ -1902,7 +1906,8 @@ static ssize_t tty_write(struct file * file, const char __user * buf, size_t cou tty = (struct tty_struct *)file->private_data; if (tty_paranoia_check(tty, inode, "tty_write")) return -EIO; if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags))) if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags))) return -EIO; ld = tty_ldisc_ref_wait(tty); Loading @@ -1914,8 +1919,8 @@ static ssize_t tty_write(struct file * file, const char __user * buf, size_t cou return ret; } ssize_t redirected_tty_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) ssize_t redirected_tty_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct file *p = NULL; Loading @@ -1932,7 +1937,6 @@ ssize_t redirected_tty_write(struct file * file, const char __user * buf, size_t fput(p); return res; } return tty_write(file, buf, count, ppos); } Loading Loading @@ -2109,9 +2113,8 @@ static int init_dev(struct tty_driver *driver, int idx, /* * Everything allocated ... set up the o_tty structure. */ if (!(driver->other->flags & TTY_DRIVER_DEVPTS_MEM)) { if (!(driver->other->flags & TTY_DRIVER_DEVPTS_MEM)) driver->other->ttys[idx] = o_tty; } if (!*o_tp_loc) *o_tp_loc = o_tp; if (!*o_ltp_loc) Loading @@ -2132,9 +2135,8 @@ static int init_dev(struct tty_driver *driver, int idx, * Failures after this point use release_tty to clean up, so * there's no need to null out the local pointers. */ if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) { if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) driver->ttys[idx] = tty; } if (!*tp_loc) *tp_loc = tp; Loading Loading @@ -2314,7 +2316,8 @@ static void release_dev(struct file * filp) unsigned long flags; tty = (struct tty_struct *)filp->private_data; if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "release_dev")) if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "release_dev")) return; check_tty_count(tty, "release_dev"); Loading Loading @@ -2531,8 +2534,7 @@ static void release_dev(struct file * filp) * side is zero. */ spin_lock_irqsave(&tty_ldisc_lock, flags); while(tty->ldisc.refcount) { while (tty->ldisc.refcount) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); wait_event(tty_ldisc_wait, tty->ldisc.refcount == 0); spin_lock_irqsave(&tty_ldisc_lock, flags); Loading Loading @@ -2679,7 +2681,8 @@ static int tty_open(struct inode * inode, struct file * filp) } filp->f_flags = saved_flags; if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) retval = -EBUSY; if (retval) { Loading Loading @@ -2723,7 +2726,7 @@ static int tty_open(struct inode * inode, struct file * filp) * Allocate a unix98 pty master device from the ptmx driver. * * Locking: tty_mutex protects theinit_dev work. tty->count should protect the rest. * protect the rest. * allocated_ptys_lock handles the list of free pty numbers */ Loading Loading @@ -3070,7 +3073,7 @@ static int tiocsctty(struct tty_struct *tty, int arg) * This tty is already the controlling * tty for another session group! */ if ((arg == 1) && capable(CAP_SYS_ADMIN)) { if (arg == 1 && capable(CAP_SYS_ADMIN)) { /* * Steal it away */ Loading Loading @@ -3428,7 +3431,6 @@ int tty_ioctl(struct inode * inode, struct file * file, case TIOCMGET: return tty_tiocmget(tty, file, p); case TIOCMSET: case TIOCMBIC: case TIOCMBIS: Loading Loading @@ -3622,7 +3624,8 @@ static void flush_to_ldisc(struct work_struct *work) return; spin_lock_irqsave(&tty->buf.lock, flags); set_bit(TTY_FLUSHING, &tty->flags); /* So we know a flush is running */ /* So we know a flush is running */ set_bit(TTY_FLUSHING, &tty->flags); head = tty->buf.head; if (head != NULL) { tty->buf.head = NULL; Loading Loading @@ -3795,7 +3798,8 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, void tty_unregister_device(struct tty_driver *driver, unsigned index) { device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); } EXPORT_SYMBOL(tty_register_device); Loading Loading @@ -3873,8 +3877,8 @@ int tty_register_driver(struct tty_driver *driver) } if (!driver->major) { error = alloc_chrdev_region(&dev, driver->minor_start, driver->num, driver->name); error = alloc_chrdev_region(&dev, driver->minor_start, driver->num, driver->name); if (!error) { driver->major = MAJOR(dev); driver->minor_start = MINOR(dev); Loading @@ -3891,7 +3895,8 @@ int tty_register_driver(struct tty_driver *driver) if (p) { driver->ttys = (struct tty_struct **)p; driver->termios = (struct ktermios **)(p + driver->num); driver->termios_locked = (struct ktermios **)(p + driver->num * 2); driver->termios_locked = (struct ktermios **) (p + driver->num * 2); } else { driver->ttys = NULL; driver->termios = NULL; Loading Loading
drivers/char/tty_io.c +283 −278 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ * -- Russell King <rmk@arm.linux.org.uk> * * Move do_SAK() into process context. Less stack use in devfs functions. * alloc_tty_struct() always uses kmalloc() -- Andrew Morton <andrewm@uow.edu.eu> 17Mar01 * alloc_tty_struct() always uses kmalloc() * -- Andrew Morton <andrewm@uow.edu.eu> 17Mar01 */ #include <linux/types.h> Loading Loading @@ -146,7 +147,8 @@ static void initialize_tty_struct(struct tty_struct *tty); static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *); static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *); ssize_t redirected_tty_write(struct file *, const char __user *, size_t, loff_t *); ssize_t redirected_tty_write(struct file *, const char __user *, size_t, loff_t *); static unsigned int tty_poll(struct file *, poll_table *); static int tty_open(struct inode *, struct file *); static int tty_release(struct inode *, struct file *); Loading Loading @@ -608,7 +610,8 @@ EXPORT_SYMBOL(tty_schedule_flip); * Locking: May call functions taking tty->buf.lock */ int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) { int space = tty_buffer_request_room(tty, size); if (likely(space)) { Loading Loading @@ -638,7 +641,8 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); * Locking: May call functions taking tty->buf.lock */ int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) { int space = tty_buffer_request_room(tty, size); if (likely(space)) { Loading Loading @@ -681,7 +685,8 @@ static void tty_set_termios_ldisc(struct tty_struct *tty, int num) static DEFINE_SPINLOCK(tty_ldisc_lock); static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait); static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /* line disc dispatch table */ /* Line disc dispatch table */ static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /** * tty_register_ldisc - install a line discipline Loading Loading @@ -771,15 +776,13 @@ struct tty_ldisc *tty_ldisc_get(int disc) ld = &tty_ldiscs[disc]; /* Check the entry is defined */ if(ld->flags & LDISC_FLAG_DEFINED) { if (ld->flags & LDISC_FLAG_DEFINED) { /* If the module is being unloaded we can't use it */ if (!try_module_get(ld->owner)) ld = NULL; else /* lock it */ ld->refcount++; } else } else ld = NULL; spin_unlock_irqrestore(&tty_ldisc_lock, flags); return ld; Loading Loading @@ -854,8 +857,7 @@ static int tty_ldisc_try(struct tty_struct *tty) spin_lock_irqsave(&tty_ldisc_lock, flags); ld = &tty->ldisc; if(test_bit(TTY_LDISC, &tty->flags)) { if (test_bit(TTY_LDISC, &tty->flags)) { ld->refcount++; ret = 1; } Loading Loading @@ -1031,8 +1033,8 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) * There are several reasons we may be busy, including * random momentary I/O traffic. We must therefore * retry. We could distinguish between blocking ops * and retries if we made tty_ldisc_wait() smarter. That * is up for discussion. * and retries if we made tty_ldisc_wait() smarter. * That is up for discussion. */ if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) return -ERESTARTSYS; Loading @@ -1046,9 +1048,10 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) goto restart; } } /* if the TTY_LDISC bit is set, then we are racing against another ldisc change */ /* * If the TTY_LDISC bit is set, then we are racing against * another ldisc change */ if (!test_bit(TTY_LDISC, &tty->flags)) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); tty_ldisc_put(ldisc); Loading @@ -1072,7 +1075,6 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) /* * Wait for ->hangup_work and ->buf.work handlers to terminate */ flush_scheduled_work(); /* Shutdown the current discipline. */ if (tty->ldisc.close) Loading Loading @@ -1387,13 +1389,14 @@ static void do_tty_hangup(struct work_struct *work) filp->f_op = &hung_up_tty_fops; } file_list_unlock(); /* FIXME! What are the locking issues here? This may me overdoing things.. * this question is especially important now that we've removed the irqlock. */ /* * FIXME! What are the locking issues here? This may me overdoing * things... This question is especially important now that we've * removed the irqlock. */ ld = tty_ldisc_ref(tty); if(ld != NULL) /* We may have no line discipline at this point */ { if (ld != NULL) { /* We may have no line discipline at this point */ if (ld->flush_buffer) ld->flush_buffer(tty); if (tty->driver->flush_buffer) Loading @@ -1404,20 +1407,18 @@ static void do_tty_hangup(struct work_struct *work) if (ld->hangup) ld->hangup(tty); } /* FIXME: Once we trust the LDISC code better we can wait here for ldisc completion and fix the driver call race */ /* * FIXME: Once we trust the LDISC code better we can wait here for * ldisc completion and fix the driver call race */ wake_up_interruptible(&tty->write_wait); wake_up_interruptible(&tty->read_wait); /* * Shutdown the current line discipline, and reset it to * N_TTY. */ if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) tty_reset_termios(tty); /* Defer ldisc switch */ /* tty_deferred_ldisc_switch(N_TTY); Loading Loading @@ -1462,12 +1463,12 @@ static void do_tty_hangup(struct work_struct *work) tty->driver->close(tty, cons_filp); } else if (tty->driver->hangup) (tty->driver->hangup)(tty); /* We don't want to have driver/ldisc interactions beyond the ones we did here. The driver layer expects no calls after ->hangup() from the ldisc side. However we can't yet guarantee all that */ /* * We don't want to have driver/ldisc interactions beyond * the ones we did here. The driver layer expects no * calls after ->hangup() from the ldisc side. However we * can't yet guarantee all that. */ set_bit(TTY_HUPPED, &tty->flags); if (ld) { tty_ldisc_enable(tty); Loading @@ -1490,7 +1491,6 @@ void tty_hangup(struct tty_struct * tty) { #ifdef TTY_DEBUG_HANGUP char buf[64]; printk(KERN_DEBUG "%s hangup...\n", tty_name(tty, buf)); #endif schedule_work(&tty->hangup_work); Loading @@ -1516,6 +1516,7 @@ void tty_vhangup(struct tty_struct * tty) #endif do_tty_hangup(&tty->hangup_work); } EXPORT_SYMBOL(tty_vhangup); /** Loading @@ -1535,7 +1536,11 @@ EXPORT_SYMBOL(tty_hung_up_p); /** * is_tty - checker whether file is a TTY * @filp: file handle that may be a tty * * Check if the file handle is a tty handle. */ int is_tty(struct file *filp) { return filp->f_op->read == tty_read Loading Loading @@ -1711,7 +1716,6 @@ void start_tty(struct tty_struct *tty) } if (tty->driver->start) (tty->driver->start)(tty); /* If we have a running line discipline it may need kicking */ tty_wakeup(tty); } Loading Loading @@ -1891,8 +1895,8 @@ static inline ssize_t do_tty_write( * kernel lock for historical reasons. New code should not rely on this. */ static ssize_t tty_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) static ssize_t tty_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct tty_struct *tty; struct inode *inode = file->f_path.dentry->d_inode; Loading @@ -1902,7 +1906,8 @@ static ssize_t tty_write(struct file * file, const char __user * buf, size_t cou tty = (struct tty_struct *)file->private_data; if (tty_paranoia_check(tty, inode, "tty_write")) return -EIO; if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags))) if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags))) return -EIO; ld = tty_ldisc_ref_wait(tty); Loading @@ -1914,8 +1919,8 @@ static ssize_t tty_write(struct file * file, const char __user * buf, size_t cou return ret; } ssize_t redirected_tty_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) ssize_t redirected_tty_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct file *p = NULL; Loading @@ -1932,7 +1937,6 @@ ssize_t redirected_tty_write(struct file * file, const char __user * buf, size_t fput(p); return res; } return tty_write(file, buf, count, ppos); } Loading Loading @@ -2109,9 +2113,8 @@ static int init_dev(struct tty_driver *driver, int idx, /* * Everything allocated ... set up the o_tty structure. */ if (!(driver->other->flags & TTY_DRIVER_DEVPTS_MEM)) { if (!(driver->other->flags & TTY_DRIVER_DEVPTS_MEM)) driver->other->ttys[idx] = o_tty; } if (!*o_tp_loc) *o_tp_loc = o_tp; if (!*o_ltp_loc) Loading @@ -2132,9 +2135,8 @@ static int init_dev(struct tty_driver *driver, int idx, * Failures after this point use release_tty to clean up, so * there's no need to null out the local pointers. */ if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) { if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) driver->ttys[idx] = tty; } if (!*tp_loc) *tp_loc = tp; Loading Loading @@ -2314,7 +2316,8 @@ static void release_dev(struct file * filp) unsigned long flags; tty = (struct tty_struct *)filp->private_data; if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "release_dev")) if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "release_dev")) return; check_tty_count(tty, "release_dev"); Loading Loading @@ -2531,8 +2534,7 @@ static void release_dev(struct file * filp) * side is zero. */ spin_lock_irqsave(&tty_ldisc_lock, flags); while(tty->ldisc.refcount) { while (tty->ldisc.refcount) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); wait_event(tty_ldisc_wait, tty->ldisc.refcount == 0); spin_lock_irqsave(&tty_ldisc_lock, flags); Loading Loading @@ -2679,7 +2681,8 @@ static int tty_open(struct inode * inode, struct file * filp) } filp->f_flags = saved_flags; if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) retval = -EBUSY; if (retval) { Loading Loading @@ -2723,7 +2726,7 @@ static int tty_open(struct inode * inode, struct file * filp) * Allocate a unix98 pty master device from the ptmx driver. * * Locking: tty_mutex protects theinit_dev work. tty->count should protect the rest. * protect the rest. * allocated_ptys_lock handles the list of free pty numbers */ Loading Loading @@ -3070,7 +3073,7 @@ static int tiocsctty(struct tty_struct *tty, int arg) * This tty is already the controlling * tty for another session group! */ if ((arg == 1) && capable(CAP_SYS_ADMIN)) { if (arg == 1 && capable(CAP_SYS_ADMIN)) { /* * Steal it away */ Loading Loading @@ -3428,7 +3431,6 @@ int tty_ioctl(struct inode * inode, struct file * file, case TIOCMGET: return tty_tiocmget(tty, file, p); case TIOCMSET: case TIOCMBIC: case TIOCMBIS: Loading Loading @@ -3622,7 +3624,8 @@ static void flush_to_ldisc(struct work_struct *work) return; spin_lock_irqsave(&tty->buf.lock, flags); set_bit(TTY_FLUSHING, &tty->flags); /* So we know a flush is running */ /* So we know a flush is running */ set_bit(TTY_FLUSHING, &tty->flags); head = tty->buf.head; if (head != NULL) { tty->buf.head = NULL; Loading Loading @@ -3795,7 +3798,8 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, void tty_unregister_device(struct tty_driver *driver, unsigned index) { device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); } EXPORT_SYMBOL(tty_register_device); Loading Loading @@ -3873,8 +3877,8 @@ int tty_register_driver(struct tty_driver *driver) } if (!driver->major) { error = alloc_chrdev_region(&dev, driver->minor_start, driver->num, driver->name); error = alloc_chrdev_region(&dev, driver->minor_start, driver->num, driver->name); if (!error) { driver->major = MAJOR(dev); driver->minor_start = MINOR(dev); Loading @@ -3891,7 +3895,8 @@ int tty_register_driver(struct tty_driver *driver) if (p) { driver->ttys = (struct tty_struct **)p; driver->termios = (struct ktermios **)(p + driver->num); driver->termios_locked = (struct ktermios **)(p + driver->num * 2); driver->termios_locked = (struct ktermios **) (p + driver->num * 2); } else { driver->ttys = NULL; driver->termios = NULL; Loading