2 * linux/drivers/char/tty_ioctl.c
4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
6 * Modified by Fred N. van Kempen, 01/29/93, to add line disciplines
7 * which can be dynamically activated and de-activated by the line
8 * discipline handling modules (like SLIP).
11 #include <linux/types.h>
12 #include <linux/termios.h>
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/major.h>
17 #include <linux/tty.h>
18 #include <linux/fcntl.h>
19 #include <linux/string.h>
21 #include <linux/module.h>
22 #include <linux/bitops.h>
23 #include <linux/mutex.h>
26 #include <asm/uaccess.h>
27 #include <asm/system.h>
29 #undef TTY_DEBUG_WAIT_UNTIL_SENT
34 * Internal flag options for termios setting behavior
36 #define TERMIOS_FLUSH 1
37 #define TERMIOS_WAIT 2
38 #define TERMIOS_TERMIO 4
43 * tty_wait_until_sent - wait for I/O to finish
44 * @tty: tty we are waiting for
45 * @timeout: how long we will wait
47 * Wait for characters pending in a tty driver to hit the wire, or
48 * for a timeout to occur (eg due to flow control)
53 void tty_wait_until_sent(struct tty_struct * tty, long timeout)
55 #ifdef TTY_DEBUG_WAIT_UNTIL_SENT
58 printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf));
60 if (!tty->driver->chars_in_buffer)
63 timeout = MAX_SCHEDULE_TIMEOUT;
64 if (wait_event_interruptible_timeout(tty->write_wait,
65 !tty->driver->chars_in_buffer(tty), timeout))
67 if (tty->driver->wait_until_sent)
68 tty->driver->wait_until_sent(tty, timeout);
71 EXPORT_SYMBOL(tty_wait_until_sent);
73 static void unset_locked_termios(struct ktermios *termios,
75 struct ktermios *locked)
79 #define NOSET_MASK(x,y,z) (x = ((x) & ~(z)) | ((y) & (z)))
82 printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n");
86 NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag);
87 NOSET_MASK(termios->c_oflag, old->c_oflag, locked->c_oflag);
88 NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag);
89 NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag);
90 termios->c_line = locked->c_line ? old->c_line : termios->c_line;
91 for (i=0; i < NCCS; i++)
92 termios->c_cc[i] = locked->c_cc[i] ?
93 old->c_cc[i] : termios->c_cc[i];
94 /* FIXME: What should we do for i/ospeed */
98 * Routine which returns the baud rate of the tty
100 * Note that the baud_table needs to be kept in sync with the
101 * include/asm/termbits.h file.
103 static const speed_t baud_table[] = {
104 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
105 9600, 19200, 38400, 57600, 115200, 230400, 460800,
107 76800, 153600, 307200, 614400, 921600
109 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
110 2500000, 3000000, 3500000, 4000000
115 static const tcflag_t baud_bits[] = {
116 B0, B50, B75, B110, B134, B150, B200, B300, B600,
117 B1200, B1800, B2400, B4800, B9600, B19200, B38400,
118 B57600, B115200, B230400, B460800, B500000, B576000,
119 B921600, B1000000, B1152000, B1500000, B2000000, B2500000,
120 B3000000, B3500000, B4000000
123 static const tcflag_t baud_bits[] = {
124 B0, B50, B75, B110, B134, B150, B200, B300, B600,
125 B1200, B1800, B2400, B4800, B9600, B19200, B38400,
126 B57600, B115200, B230400, B460800, B76800, B153600,
127 B307200, B614400, B921600
131 static int n_baud_table = ARRAY_SIZE(baud_table);
134 * tty_termios_baud_rate
135 * @termios: termios structure
137 * Convert termios baud rate data into a speed. This should be called
138 * with the termios lock held if this termios is a terminal termios
139 * structure. May change the termios data. Device drivers can call this
140 * function but should use ->c_[io]speed directly as they are updated.
145 speed_t tty_termios_baud_rate(struct ktermios *termios)
149 cbaud = termios->c_cflag & CBAUD;
152 /* Magic token for arbitary speed via c_ispeed/c_ospeed */
154 return termios->c_ospeed;
156 if (cbaud & CBAUDEX) {
159 if (cbaud < 1 || cbaud + 15 > n_baud_table)
160 termios->c_cflag &= ~CBAUDEX;
164 return baud_table[cbaud];
167 EXPORT_SYMBOL(tty_termios_baud_rate);
170 * tty_termios_input_baud_rate
171 * @termios: termios structure
173 * Convert termios baud rate data into a speed. This should be called
174 * with the termios lock held if this termios is a terminal termios
175 * structure. May change the termios data. Device drivers can call this
176 * function but should use ->c_[io]speed directly as they are updated.
181 speed_t tty_termios_input_baud_rate(struct ktermios *termios)
184 unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD;
187 return tty_termios_baud_rate(termios);
189 /* Magic token for arbitary speed via c_ispeed*/
191 return termios->c_ispeed;
193 if (cbaud & CBAUDEX) {
196 if (cbaud < 1 || cbaud + 15 > n_baud_table)
197 termios->c_cflag &= ~(CBAUDEX << IBSHIFT);
201 return baud_table[cbaud];
203 return tty_termios_baud_rate(termios);
207 EXPORT_SYMBOL(tty_termios_input_baud_rate);
210 * tty_termios_encode_baud_rate
211 * @termios: ktermios structure holding user requested state
212 * @ispeed: input speed
213 * @ospeed: output speed
215 * Encode the speeds set into the passed termios structure. This is
216 * used as a library helper for drivers os that they can report back
217 * the actual speed selected when it differs from the speed requested
219 * For maximal back compatibility with legacy SYS5/POSIX *nix behaviour
220 * we need to carefully set the bits when the user does not get the
221 * desired speed. We allow small margins and preserve as much of possible
222 * of the input intent to keep compatiblity.
224 * Locking: Caller should hold termios lock. This is already held
225 * when calling this function from the driver termios handler.
227 * The ifdefs deal with platforms whose owners have yet to update them
228 * and will all go away once this is done.
231 void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud)
234 int ifound = -1, ofound = -1;
235 int iclose = ibaud/50, oclose = obaud/50;
238 if (obaud == 0) /* CD dropped */
239 ibaud = 0; /* Clear ibaud to be sure */
241 termios->c_ispeed = ibaud;
242 termios->c_ospeed = obaud;
245 /* If the user asked for a precise weird speed give a precise weird
246 answer. If they asked for a Bfoo speed they many have problems
247 digesting non-exact replies so fuzz a bit */
249 if ((termios->c_cflag & CBAUD) == BOTHER)
251 if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER)
253 if ((termios->c_cflag >> IBSHIFT) & CBAUD)
254 ibinput = 1; /* An input speed was specified */
256 termios->c_cflag &= ~CBAUD;
259 * Our goal is to find a close match to the standard baud rate
260 * returned. Walk the baud rate table and if we get a very close
261 * match then report back the speed as a POSIX Bxxxx value by
266 if (obaud - oclose >= baud_table[i] && obaud + oclose <= baud_table[i]) {
267 termios->c_cflag |= baud_bits[i];
270 if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= baud_table[i]) {
271 if (ofound == i && !ibinput)
276 termios->c_cflag |= (baud_bits[i] << IBSHIFT);
280 } while (++i < n_baud_table);
283 * If we found no match then use BOTHER if provided or warn
284 * the user their platform maintainer needs to wake up if not.
288 termios->c_cflag |= BOTHER;
289 /* Set exact input bits only if the input and output differ or the
291 if (ifound == -1 && (ibaud != obaud || ibinput))
292 termios->c_cflag |= (BOTHER << IBSHIFT);
294 if (ifound == -1 || ofound == -1) {
297 printk(KERN_WARNING "tty: Unable to return correct "
298 "speed data as your architecture needs updating.\n");
302 EXPORT_SYMBOL_GPL(tty_termios_encode_baud_rate);
304 void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud)
306 tty_termios_encode_baud_rate(tty->termios, ibaud, obaud);
308 EXPORT_SYMBOL_GPL(tty_encode_baud_rate);
311 * tty_get_baud_rate - get tty bit rates
314 * Returns the baud rate as an integer for this terminal. The
315 * termios lock must be held by the caller and the terminal bit
316 * flags may be updated.
321 speed_t tty_get_baud_rate(struct tty_struct *tty)
323 speed_t baud = tty_termios_baud_rate(tty->termios);
325 if (baud == 38400 && tty->alt_speed) {
327 printk(KERN_WARNING "Use of setserial/setrocket to "
328 "set SPD_* flags is deprecated\n");
331 baud = tty->alt_speed;
337 EXPORT_SYMBOL(tty_get_baud_rate);
340 * tty_termios_copy_hw - copy hardware settings
344 * Propogate the hardware specific terminal setting bits from
345 * the old termios structure to the new one. This is used in cases
346 * where the hardware does not support reconfiguration or as a helper
347 * in some cases where only minimal reconfiguration is supported
350 void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old)
352 /* The bits a dumb device handles in software. Smart devices need
353 to always provide a set_termios method */
354 new->c_cflag &= HUPCL | CREAD | CLOCAL;
355 new->c_cflag |= old->c_cflag & ~(HUPCL | CREAD | CLOCAL);
356 new->c_ispeed = old->c_ispeed;
357 new->c_ospeed = old->c_ospeed;
360 EXPORT_SYMBOL(tty_termios_copy_hw);
363 * change_termios - update termios values
364 * @tty: tty to update
365 * @new_termios: desired new value
367 * Perform updates to the termios values set on this terminal. There
368 * is a bit of layering violation here with n_tty in terms of the
369 * internal knowledge of this function.
371 * Locking: termios_sem
374 static void change_termios(struct tty_struct * tty, struct ktermios * new_termios)
377 struct ktermios old_termios = *tty->termios;
378 struct tty_ldisc *ld;
381 * Perform the actual termios internal changes under lock.
385 /* FIXME: we need to decide on some locking/ordering semantics
386 for the set_termios notification eventually */
387 mutex_lock(&tty->termios_mutex);
389 *tty->termios = *new_termios;
390 unset_locked_termios(tty->termios, &old_termios, tty->termios_locked);
391 canon_change = (old_termios.c_lflag ^ tty->termios->c_lflag) & ICANON;
393 memset(&tty->read_flags, 0, sizeof tty->read_flags);
394 tty->canon_head = tty->read_tail;
399 /* This bit should be in the ldisc code */
400 if (canon_change && !L_ICANON(tty) && tty->read_cnt)
401 /* Get characters left over from canonical mode. */
402 wake_up_interruptible(&tty->read_wait);
404 /* See if packet mode change of state. */
405 if (tty->link && tty->link->packet) {
406 int old_flow = ((old_termios.c_iflag & IXON) &&
407 (old_termios.c_cc[VSTOP] == '\023') &&
408 (old_termios.c_cc[VSTART] == '\021'));
409 int new_flow = (I_IXON(tty) &&
410 STOP_CHAR(tty) == '\023' &&
411 START_CHAR(tty) == '\021');
412 if (old_flow != new_flow) {
413 tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
415 tty->ctrl_status |= TIOCPKT_DOSTOP;
417 tty->ctrl_status |= TIOCPKT_NOSTOP;
418 wake_up_interruptible(&tty->link->read_wait);
422 if (tty->driver->set_termios)
423 (*tty->driver->set_termios)(tty, &old_termios);
425 tty_termios_copy_hw(tty->termios, &old_termios);
427 ld = tty_ldisc_ref(tty);
430 (ld->set_termios)(tty, &old_termios);
433 mutex_unlock(&tty->termios_mutex);
437 * set_termios - set termios values for a tty
438 * @tty: terminal device
440 * @opt: option information
442 * Helper function to prepare termios data and run neccessary other
443 * functions before using change_termios to do the actual changes.
446 * Called functions take ldisc and termios_sem locks
449 static int set_termios(struct tty_struct * tty, void __user *arg, int opt)
451 struct ktermios tmp_termios;
452 struct tty_ldisc *ld;
453 int retval = tty_check_change(tty);
458 memcpy(&tmp_termios, tty->termios, sizeof(struct ktermios));
460 if (opt & TERMIOS_TERMIO) {
461 if (user_termio_to_kernel_termios(&tmp_termios,
462 (struct termio __user *)arg))
465 } else if (opt & TERMIOS_OLD) {
466 if (user_termios_to_kernel_termios_1(&tmp_termios,
467 (struct termios __user *)arg))
470 if (user_termios_to_kernel_termios(&tmp_termios,
471 (struct termios2 __user *)arg))
475 } else if (user_termios_to_kernel_termios(&tmp_termios,
476 (struct termios __user *)arg))
480 /* If old style Bfoo values are used then load c_ispeed/c_ospeed with the real speed
481 so its unconditionally usable */
482 tmp_termios.c_ispeed = tty_termios_input_baud_rate(&tmp_termios);
483 tmp_termios.c_ospeed = tty_termios_baud_rate(&tmp_termios);
485 ld = tty_ldisc_ref(tty);
488 if ((opt & TERMIOS_FLUSH) && ld->flush_buffer)
489 ld->flush_buffer(tty);
493 if (opt & TERMIOS_WAIT) {
494 tty_wait_until_sent(tty, 0);
495 if (signal_pending(current))
499 change_termios(tty, &tmp_termios);
501 /* FIXME: Arguably if tmp_termios == tty->termios AND the
502 actual requested termios was not tmp_termios then we may
503 want to return an error as no user requested change has
508 static int get_termio(struct tty_struct * tty, struct termio __user * termio)
510 if (kernel_termios_to_user_termio(termio, tty->termios))
515 static unsigned long inq_canon(struct tty_struct * tty)
519 if (!tty->canon_data || !tty->read_buf)
521 head = tty->canon_head;
522 tail = tty->read_tail;
523 nr = (head - tail) & (N_TTY_BUF_SIZE-1);
524 /* Skip EOF-chars.. */
525 while (head != tail) {
526 if (test_bit(tail, tty->read_flags) &&
527 tty->read_buf[tail] == __DISABLED_CHAR)
529 tail = (tail+1) & (N_TTY_BUF_SIZE-1);
536 * These are deprecated, but there is limited support..
538 * The "sg_flags" translation is a joke..
540 static int get_sgflags(struct tty_struct * tty)
544 if (!(tty->termios->c_lflag & ICANON)) {
545 if (tty->termios->c_lflag & ISIG)
546 flags |= 0x02; /* cbreak */
548 flags |= 0x20; /* raw */
550 if (tty->termios->c_lflag & ECHO)
551 flags |= 0x08; /* echo */
552 if (tty->termios->c_oflag & OPOST)
553 if (tty->termios->c_oflag & ONLCR)
554 flags |= 0x10; /* crmod */
558 static int get_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
562 mutex_lock(&tty->termios_mutex);
563 tmp.sg_ispeed = tty->termios->c_ispeed;
564 tmp.sg_ospeed = tty->termios->c_ospeed;
565 tmp.sg_erase = tty->termios->c_cc[VERASE];
566 tmp.sg_kill = tty->termios->c_cc[VKILL];
567 tmp.sg_flags = get_sgflags(tty);
568 mutex_unlock(&tty->termios_mutex);
570 return copy_to_user(sgttyb, &tmp, sizeof(tmp)) ? -EFAULT : 0;
573 static void set_sgflags(struct ktermios * termios, int flags)
575 termios->c_iflag = ICRNL | IXON;
576 termios->c_oflag = 0;
577 termios->c_lflag = ISIG | ICANON;
578 if (flags & 0x02) { /* cbreak */
579 termios->c_iflag = 0;
580 termios->c_lflag &= ~ICANON;
582 if (flags & 0x08) { /* echo */
583 termios->c_lflag |= ECHO | ECHOE | ECHOK |
584 ECHOCTL | ECHOKE | IEXTEN;
586 if (flags & 0x10) { /* crmod */
587 termios->c_oflag |= OPOST | ONLCR;
589 if (flags & 0x20) { /* raw */
590 termios->c_iflag = 0;
591 termios->c_lflag &= ~(ISIG | ICANON);
593 if (!(termios->c_lflag & ICANON)) {
594 termios->c_cc[VMIN] = 1;
595 termios->c_cc[VTIME] = 0;
600 * set_sgttyb - set legacy terminal values
601 * @tty: tty structure
602 * @sgttyb: pointer to old style terminal structure
604 * Updates a terminal from the legacy BSD style terminal information
607 * Locking: termios_sem
610 static int set_sgttyb(struct tty_struct * tty, struct sgttyb __user * sgttyb)
614 struct ktermios termios;
616 retval = tty_check_change(tty);
620 if (copy_from_user(&tmp, sgttyb, sizeof(tmp)))
623 mutex_lock(&tty->termios_mutex);
624 termios = *tty->termios;
625 termios.c_cc[VERASE] = tmp.sg_erase;
626 termios.c_cc[VKILL] = tmp.sg_kill;
627 set_sgflags(&termios, tmp.sg_flags);
628 /* Try and encode into Bfoo format */
630 tty_termios_encode_baud_rate(&termios, termios.c_ispeed, termios.c_ospeed);
632 mutex_unlock(&tty->termios_mutex);
633 change_termios(tty, &termios);
639 static int get_tchars(struct tty_struct * tty, struct tchars __user * tchars)
643 tmp.t_intrc = tty->termios->c_cc[VINTR];
644 tmp.t_quitc = tty->termios->c_cc[VQUIT];
645 tmp.t_startc = tty->termios->c_cc[VSTART];
646 tmp.t_stopc = tty->termios->c_cc[VSTOP];
647 tmp.t_eofc = tty->termios->c_cc[VEOF];
648 tmp.t_brkc = tty->termios->c_cc[VEOL2]; /* what is brkc anyway? */
649 return copy_to_user(tchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
652 static int set_tchars(struct tty_struct * tty, struct tchars __user * tchars)
656 if (copy_from_user(&tmp, tchars, sizeof(tmp)))
658 tty->termios->c_cc[VINTR] = tmp.t_intrc;
659 tty->termios->c_cc[VQUIT] = tmp.t_quitc;
660 tty->termios->c_cc[VSTART] = tmp.t_startc;
661 tty->termios->c_cc[VSTOP] = tmp.t_stopc;
662 tty->termios->c_cc[VEOF] = tmp.t_eofc;
663 tty->termios->c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */
669 static int get_ltchars(struct tty_struct * tty, struct ltchars __user * ltchars)
673 tmp.t_suspc = tty->termios->c_cc[VSUSP];
674 tmp.t_dsuspc = tty->termios->c_cc[VSUSP]; /* what is dsuspc anyway? */
675 tmp.t_rprntc = tty->termios->c_cc[VREPRINT];
676 tmp.t_flushc = tty->termios->c_cc[VEOL2]; /* what is flushc anyway? */
677 tmp.t_werasc = tty->termios->c_cc[VWERASE];
678 tmp.t_lnextc = tty->termios->c_cc[VLNEXT];
679 return copy_to_user(ltchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
682 static int set_ltchars(struct tty_struct * tty, struct ltchars __user * ltchars)
686 if (copy_from_user(&tmp, ltchars, sizeof(tmp)))
689 tty->termios->c_cc[VSUSP] = tmp.t_suspc;
690 tty->termios->c_cc[VEOL2] = tmp.t_dsuspc; /* what is dsuspc anyway? */
691 tty->termios->c_cc[VREPRINT] = tmp.t_rprntc;
692 tty->termios->c_cc[VEOL2] = tmp.t_flushc; /* what is flushc anyway? */
693 tty->termios->c_cc[VWERASE] = tmp.t_werasc;
694 tty->termios->c_cc[VLNEXT] = tmp.t_lnextc;
700 * send_prio_char - send priority character
702 * Send a high priority character to the tty even if stopped
704 * Locking: none for xchar method, write ordering for write method.
707 static int send_prio_char(struct tty_struct *tty, char ch)
709 int was_stopped = tty->stopped;
711 if (tty->driver->send_xchar) {
712 tty->driver->send_xchar(tty, ch);
716 if (tty_write_lock(tty, 0) < 0)
721 tty->driver->write(tty, &ch, 1);
724 tty_write_unlock(tty);
728 int n_tty_ioctl(struct tty_struct * tty, struct file * file,
729 unsigned int cmd, unsigned long arg)
731 struct tty_struct * real_tty;
732 void __user *p = (void __user *)arg;
734 struct tty_ldisc *ld;
736 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
737 tty->driver->subtype == PTY_TYPE_MASTER)
738 real_tty = tty->link;
745 return get_sgttyb(real_tty, (struct sgttyb __user *) arg);
748 return set_sgttyb(real_tty, (struct sgttyb __user *) arg);
752 return get_tchars(real_tty, p);
754 return set_tchars(real_tty, p);
758 return get_ltchars(real_tty, p);
760 return set_ltchars(real_tty, p);
763 return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT | TERMIOS_OLD);
765 return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_OLD);
767 return set_termios(real_tty, p, TERMIOS_OLD);
770 if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios))
775 if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios))
779 if (kernel_termios_to_user_termios((struct termios2 __user *)arg, real_tty->termios))
783 return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT);
785 return set_termios(real_tty, p, TERMIOS_WAIT);
787 return set_termios(real_tty, p, 0);
790 return get_termio(real_tty, p);
792 return set_termios(real_tty, p, TERMIOS_FLUSH | TERMIOS_WAIT | TERMIOS_TERMIO);
794 return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_TERMIO);
796 return set_termios(real_tty, p, TERMIOS_TERMIO);
798 retval = tty_check_change(tty);
803 if (!tty->flow_stopped) {
804 tty->flow_stopped = 1;
809 if (tty->flow_stopped) {
810 tty->flow_stopped = 0;
815 if (STOP_CHAR(tty) != __DISABLED_CHAR)
816 return send_prio_char(tty, STOP_CHAR(tty));
819 if (START_CHAR(tty) != __DISABLED_CHAR)
820 return send_prio_char(tty, START_CHAR(tty));
827 retval = tty_check_change(tty);
831 ld = tty_ldisc_ref(tty);
834 if (ld && ld->flush_buffer)
835 ld->flush_buffer(tty);
838 if (ld && ld->flush_buffer)
839 ld->flush_buffer(tty);
842 if (tty->driver->flush_buffer)
843 tty->driver->flush_buffer(tty);
852 return put_user(tty->driver->chars_in_buffer ?
853 tty->driver->chars_in_buffer(tty) : 0,
856 retval = tty->read_cnt;
858 retval = inq_canon(tty);
859 return put_user(retval, (unsigned int __user *) arg);
862 if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios_locked))
867 if (!capable(CAP_SYS_ADMIN))
869 if (user_termios_to_kernel_termios(real_tty->termios_locked, (struct termios __user *) arg))
874 if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios_locked))
879 if (!capable(CAP_SYS_ADMIN))
881 if (user_termios_to_kernel_termios_1(real_tty->termios_locked, (struct termios __user *) arg))
890 if (tty->driver->type != TTY_DRIVER_TYPE_PTY ||
891 tty->driver->subtype != PTY_TYPE_MASTER)
893 if (get_user(pktmode, (int __user *) arg))
898 tty->link->ctrl_status = 0;
905 return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)arg);
907 if (get_user(arg, (unsigned int __user *) arg))
909 mutex_lock(&tty->termios_mutex);
910 tty->termios->c_cflag =
911 ((tty->termios->c_cflag & ~CLOCAL) |
913 mutex_unlock(&tty->termios_mutex);
920 EXPORT_SYMBOL(n_tty_ioctl);