• Home
  • Raw
  • Download

Lines Matching refs:tty

35 # define tty_debug_hangup(tty, f, args...)	tty_debug(tty, f, ##args)  argument
37 # define tty_debug_hangup(tty, f, args...) do {} while (0) argument
46 static void pty_close(struct tty_struct *tty, struct file *filp) in pty_close() argument
48 BUG_ON(!tty); in pty_close()
49 if (tty->driver->subtype == PTY_TYPE_MASTER) in pty_close()
50 WARN_ON(tty->count > 1); in pty_close()
52 if (tty_io_error(tty)) in pty_close()
54 if (tty->count > 2) in pty_close()
57 set_bit(TTY_IO_ERROR, &tty->flags); in pty_close()
58 wake_up_interruptible(&tty->read_wait); in pty_close()
59 wake_up_interruptible(&tty->write_wait); in pty_close()
60 spin_lock_irq(&tty->ctrl_lock); in pty_close()
61 tty->packet = 0; in pty_close()
62 spin_unlock_irq(&tty->ctrl_lock); in pty_close()
64 if (!tty->link) in pty_close()
66 set_bit(TTY_OTHER_CLOSED, &tty->link->flags); in pty_close()
67 wake_up_interruptible(&tty->link->read_wait); in pty_close()
68 wake_up_interruptible(&tty->link->write_wait); in pty_close()
69 if (tty->driver->subtype == PTY_TYPE_MASTER) { in pty_close()
70 set_bit(TTY_OTHER_CLOSED, &tty->flags); in pty_close()
72 if (tty->driver == ptm_driver) { in pty_close()
74 if (tty->link->driver_data) in pty_close()
75 devpts_pty_kill(tty->link->driver_data); in pty_close()
79 tty_vhangup(tty->link); in pty_close()
93 static void pty_unthrottle(struct tty_struct *tty) in pty_unthrottle() argument
95 tty_wakeup(tty->link); in pty_unthrottle()
96 set_bit(TTY_THROTTLED, &tty->flags); in pty_unthrottle()
111 static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) in pty_write() argument
113 struct tty_struct *to = tty->link; in pty_write()
116 if (tty->stopped) in pty_write()
139 static int pty_write_room(struct tty_struct *tty) in pty_write_room() argument
141 if (tty->stopped) in pty_write_room()
143 return tty_buffer_space_avail(tty->link->port); in pty_write_room()
154 static int pty_chars_in_buffer(struct tty_struct *tty) in pty_chars_in_buffer() argument
160 static int pty_set_lock(struct tty_struct *tty, int __user *arg) in pty_set_lock() argument
166 set_bit(TTY_PTY_LOCK, &tty->flags); in pty_set_lock()
168 clear_bit(TTY_PTY_LOCK, &tty->flags); in pty_set_lock()
172 static int pty_get_lock(struct tty_struct *tty, int __user *arg) in pty_get_lock() argument
174 int locked = test_bit(TTY_PTY_LOCK, &tty->flags); in pty_get_lock()
179 static int pty_set_pktmode(struct tty_struct *tty, int __user *arg) in pty_set_pktmode() argument
186 spin_lock_irq(&tty->ctrl_lock); in pty_set_pktmode()
188 if (!tty->packet) { in pty_set_pktmode()
189 tty->link->ctrl_status = 0; in pty_set_pktmode()
191 tty->packet = 1; in pty_set_pktmode()
194 tty->packet = 0; in pty_set_pktmode()
195 spin_unlock_irq(&tty->ctrl_lock); in pty_set_pktmode()
201 static int pty_get_pktmode(struct tty_struct *tty, int __user *arg) in pty_get_pktmode() argument
203 int pktmode = tty->packet; in pty_get_pktmode()
208 static int pty_signal(struct tty_struct *tty, int sig) in pty_signal() argument
215 if (tty->link) { in pty_signal()
216 pgrp = tty_get_pgrp(tty->link); in pty_signal()
224 static void pty_flush_buffer(struct tty_struct *tty) in pty_flush_buffer() argument
226 struct tty_struct *to = tty->link; in pty_flush_buffer()
233 spin_lock_irq(&tty->ctrl_lock); in pty_flush_buffer()
234 tty->ctrl_status |= TIOCPKT_FLUSHWRITE; in pty_flush_buffer()
236 spin_unlock_irq(&tty->ctrl_lock); in pty_flush_buffer()
240 static int pty_open(struct tty_struct *tty, struct file *filp) in pty_open() argument
242 if (!tty || !tty->link) in pty_open()
245 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) in pty_open()
247 if (test_bit(TTY_PTY_LOCK, &tty->link->flags)) in pty_open()
249 if (tty->driver->subtype == PTY_TYPE_SLAVE && tty->link->count != 1) in pty_open()
252 clear_bit(TTY_IO_ERROR, &tty->flags); in pty_open()
253 clear_bit(TTY_OTHER_CLOSED, &tty->link->flags); in pty_open()
254 set_bit(TTY_THROTTLED, &tty->flags); in pty_open()
258 set_bit(TTY_IO_ERROR, &tty->flags); in pty_open()
262 static void pty_set_termios(struct tty_struct *tty, in pty_set_termios() argument
266 if (tty->link && tty->link->packet) { in pty_set_termios()
267 int extproc = (old_termios->c_lflag & EXTPROC) | L_EXTPROC(tty); in pty_set_termios()
271 int new_flow = (I_IXON(tty) && in pty_set_termios()
272 STOP_CHAR(tty) == '\023' && in pty_set_termios()
273 START_CHAR(tty) == '\021'); in pty_set_termios()
275 spin_lock_irq(&tty->ctrl_lock); in pty_set_termios()
277 tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); in pty_set_termios()
279 tty->ctrl_status |= TIOCPKT_DOSTOP; in pty_set_termios()
281 tty->ctrl_status |= TIOCPKT_NOSTOP; in pty_set_termios()
284 tty->ctrl_status |= TIOCPKT_IOCTL; in pty_set_termios()
285 spin_unlock_irq(&tty->ctrl_lock); in pty_set_termios()
286 wake_up_interruptible(&tty->link->read_wait); in pty_set_termios()
290 tty->termios.c_cflag &= ~(CSIZE | PARENB); in pty_set_termios()
291 tty->termios.c_cflag |= (CS8 | CREAD); in pty_set_termios()
303 static int pty_resize(struct tty_struct *tty, struct winsize *ws) in pty_resize() argument
306 struct tty_struct *pty = tty->link; in pty_resize()
309 mutex_lock(&tty->winsize_mutex); in pty_resize()
310 if (!memcmp(ws, &tty->winsize, sizeof(*ws))) in pty_resize()
314 pgrp = tty_get_pgrp(tty); in pty_resize()
325 tty->winsize = *ws; in pty_resize()
328 mutex_unlock(&tty->winsize_mutex); in pty_resize()
342 static void pty_start(struct tty_struct *tty) in pty_start() argument
346 if (tty->link && tty->link->packet) { in pty_start()
347 spin_lock_irqsave(&tty->ctrl_lock, flags); in pty_start()
348 tty->ctrl_status &= ~TIOCPKT_STOP; in pty_start()
349 tty->ctrl_status |= TIOCPKT_START; in pty_start()
350 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in pty_start()
351 wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN); in pty_start()
355 static void pty_stop(struct tty_struct *tty) in pty_stop() argument
359 if (tty->link && tty->link->packet) { in pty_stop()
360 spin_lock_irqsave(&tty->ctrl_lock, flags); in pty_stop()
361 tty->ctrl_status &= ~TIOCPKT_START; in pty_stop()
362 tty->ctrl_status |= TIOCPKT_STOP; in pty_stop()
363 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in pty_stop()
364 wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN); in pty_stop()
379 static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, in pty_common_install() argument
384 int idx = tty->index; in pty_common_install()
409 tty_init_termios(tty); in pty_common_install()
413 driver->ttys[idx] = tty; in pty_common_install()
415 memset(&tty->termios_locked, 0, sizeof(tty->termios_locked)); in pty_common_install()
416 tty->termios = driver->init_termios; in pty_common_install()
417 memset(&o_tty->termios_locked, 0, sizeof(tty->termios_locked)); in pty_common_install()
426 tty->link = o_tty; in pty_common_install()
427 o_tty->link = tty; in pty_common_install()
433 tty->port = ports[1]; in pty_common_install()
439 tty->count++; in pty_common_install()
451 static void pty_cleanup(struct tty_struct *tty) in pty_cleanup() argument
453 tty_port_put(tty->port); in pty_cleanup()
459 static int pty_install(struct tty_driver *driver, struct tty_struct *tty) in pty_install() argument
461 return pty_common_install(driver, tty, true); in pty_install()
464 static void pty_remove(struct tty_driver *driver, struct tty_struct *tty) in pty_remove() argument
466 struct tty_struct *pair = tty->link; in pty_remove()
467 driver->ttys[tty->index] = NULL; in pty_remove()
472 static int pty_bsd_ioctl(struct tty_struct *tty, in pty_bsd_ioctl() argument
477 return pty_set_lock(tty, (int __user *) arg); in pty_bsd_ioctl()
479 return pty_get_lock(tty, (int __user *)arg); in pty_bsd_ioctl()
481 return pty_set_pktmode(tty, (int __user *)arg); in pty_bsd_ioctl()
483 return pty_get_pktmode(tty, (int __user *)arg); in pty_bsd_ioctl()
485 return pty_signal(tty, (int) arg); in pty_bsd_ioctl()
493 static long pty_bsd_compat_ioctl(struct tty_struct *tty, in pty_bsd_compat_ioctl() argument
500 return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg)); in pty_bsd_compat_ioctl()
623 int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags) in ptm_open_peer() argument
630 if (tty->driver != ptm_driver) in ptm_open_peer()
640 path.mnt = devpts_mntget(master, tty->driver_data); in ptm_open_peer()
645 path.dentry = tty->link->driver_data; in ptm_open_peer()
663 static int pty_unix98_ioctl(struct tty_struct *tty, in pty_unix98_ioctl() argument
668 return pty_set_lock(tty, (int __user *)arg); in pty_unix98_ioctl()
670 return pty_get_lock(tty, (int __user *)arg); in pty_unix98_ioctl()
672 return pty_set_pktmode(tty, (int __user *)arg); in pty_unix98_ioctl()
674 return pty_get_pktmode(tty, (int __user *)arg); in pty_unix98_ioctl()
676 return put_user(tty->index, (unsigned int __user *)arg); in pty_unix98_ioctl()
678 return pty_signal(tty, (int) arg); in pty_unix98_ioctl()
685 static long pty_unix98_compat_ioctl(struct tty_struct *tty, in pty_unix98_compat_ioctl() argument
692 return pty_unix98_ioctl(tty, cmd, in pty_unix98_compat_ioctl()
727 struct tty_struct *tty; in pts_unix98_lookup() local
730 tty = devpts_get_priv(file->f_path.dentry); in pts_unix98_lookup()
733 if (!tty) in pts_unix98_lookup()
735 return tty; in pts_unix98_lookup()
738 static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty) in pty_unix98_install() argument
740 return pty_common_install(driver, tty, false); in pty_unix98_install()
744 static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) in pty_unix98_remove() argument
748 if (tty->driver->subtype == PTY_TYPE_MASTER) in pty_unix98_remove()
749 fsi = tty->driver_data; in pty_unix98_remove()
751 fsi = tty->link->driver_data; in pty_unix98_remove()
754 devpts_kill_index(fsi, tty->index); in pty_unix98_remove()
759 static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) in pty_show_fdinfo() argument
761 seq_printf(m, "tty-index:\t%d\n", tty->index); in pty_show_fdinfo()
814 struct tty_struct *tty; in ptmx_open() local
845 tty = tty_init_dev(ptm_driver, index); in ptmx_open()
850 retval = PTR_ERR(tty); in ptmx_open()
851 if (IS_ERR(tty)) in ptmx_open()
858 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ in ptmx_open()
859 tty->driver_data = fsi; in ptmx_open()
861 tty_add_file(tty, filp); in ptmx_open()
863 dentry = devpts_pty_new(fsi, index, tty->link); in ptmx_open()
868 tty->link->driver_data = dentry; in ptmx_open()
870 retval = ptm_driver->ops->open(tty, filp); in ptmx_open()
874 tty_debug_hangup(tty, "opening (count=%d)\n", tty->count); in ptmx_open()
876 tty_unlock(tty); in ptmx_open()
879 tty_unlock(tty); in ptmx_open()