MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tty_generic_ioctl

Function tty_generic_ioctl

freebsd/kern/tty.c:1625–1982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1623}
1624
1625static int
1626tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
1627 struct thread *td)
1628{
1629 int error;
1630
1631 switch (cmd) {
1632 /*
1633 * Modem commands.
1634 * The SER_* and TIOCM_* flags are the same, but one bit
1635 * shifted. I don't know why.
1636 */
1637 case TIOCSDTR:
1638 ttydevsw_modem(tp, SER_DTR, 0);
1639 return (0);
1640 case TIOCCDTR:
1641 ttydevsw_modem(tp, 0, SER_DTR);
1642 return (0);
1643 case TIOCMSET: {
1644 int bits = *(int *)data;
1645 ttydevsw_modem(tp,
1646 (bits & (TIOCM_DTR | TIOCM_RTS)) >> 1,
1647 ((~bits) & (TIOCM_DTR | TIOCM_RTS)) >> 1);
1648 return (0);
1649 }
1650 case TIOCMBIS: {
1651 int bits = *(int *)data;
1652 ttydevsw_modem(tp, (bits & (TIOCM_DTR | TIOCM_RTS)) >> 1, 0);
1653 return (0);
1654 }
1655 case TIOCMBIC: {
1656 int bits = *(int *)data;
1657 ttydevsw_modem(tp, 0, (bits & (TIOCM_DTR | TIOCM_RTS)) >> 1);
1658 return (0);
1659 }
1660 case TIOCMGET:
1661 *(int *)data = TIOCM_LE + (ttydevsw_modem(tp, 0, 0) << 1);
1662 return (0);
1663
1664 case FIOASYNC:
1665 if (*(int *)data)
1666 tp->t_flags |= TF_ASYNC;
1667 else
1668 tp->t_flags &= ~TF_ASYNC;
1669 return (0);
1670 case FIONBIO:
1671 /* This device supports non-blocking operation. */
1672 return (0);
1673 case FIONREAD:
1674 *(int *)data = ttyinq_bytescanonicalized(&tp->t_inq);
1675 return (0);
1676 case FIONWRITE:
1677 case TIOCOUTQ:
1678 *(int *)data = ttyoutq_bytesused(&tp->t_outq);
1679 return (0);
1680 case FIOSETOWN:
1681 if (tp->t_session != NULL && !tty_is_ctty(tp, td->td_proc))
1682 /* Not allowed to set ownership. */

Callers 1

tty_ioctlFunction · 0.85

Calls 15

ttydevsw_modemFunction · 0.85
ttyoutq_bytesusedFunction · 0.85
tty_is_cttyFunction · 0.85
fsetownFunction · 0.85
fgetownFunction · 0.85
tty_drainFunction · 0.85
tty_flushFunction · 0.85
ttydevsw_paramFunction · 0.85
tty_watermarksFunction · 0.85
ttydisc_optimizeFunction · 0.85
ttyinq_canonicalizeFunction · 0.85

Tested by

no test coverage detected