Use struct termios in ttynvt_t and drop static one.
Also set termios on pty slave on init.
This commit is contained in:
@@ -487,6 +487,11 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
|
||||
if ((fd = open(slave_name, O_RDWR | O_NOCTTY)) < 0) /* open slave */
|
||||
goto open_err;
|
||||
|
||||
ioctl(fd, TCGETS, &tty->tio);
|
||||
tty->tio.c_cflag &= ~(CSIZE | PARENB);
|
||||
tty->tio.c_cflag |= B115200 | CS8 | CREAD | CLOCAL;
|
||||
ioctl(fd, TCSETS, &tty->tio);
|
||||
|
||||
tty->fds[FD_SLAVE].fd = fd;
|
||||
tty->fds[FD_SLAVE].events = POLLIN;
|
||||
|
||||
@@ -683,12 +688,10 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
|
||||
const void *in_buf, size_t in_bufsz, size_t out_bufsz)
|
||||
{
|
||||
ttynvt_t *tty = (ttynvt_t *) (uintptr_t) info->fh;
|
||||
struct termios *tio = &tty->tio;
|
||||
struct winsize ws;
|
||||
unsigned int tiocm = 0;
|
||||
int mcr;
|
||||
static struct termios tio = {
|
||||
.c_cflag = B115200 | CS8 | PARODD | CREAD | CLOCAL,
|
||||
};
|
||||
int val;
|
||||
int res;
|
||||
|
||||
@@ -706,46 +709,46 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
|
||||
speed_t speed;
|
||||
int csize, par, sb;
|
||||
|
||||
memcpy(&tio, in_buf, in_bufsz);
|
||||
memcpy(tio, in_buf, in_bufsz);
|
||||
|
||||
speed = tio.c_cflag & (CBAUD | CBAUDEX);
|
||||
speed = tio->c_cflag & (CBAUD | CBAUDEX);
|
||||
val = htonl(baudrate(speed));
|
||||
telnet_rfc2217_cfg(tty->tn, TNS_SET_BAUDRATE, &val, 4);
|
||||
|
||||
if ((tio.c_cflag & CSIZE) == CS5)
|
||||
if ((tio->c_cflag & CSIZE) == CS5)
|
||||
csize = 5;
|
||||
else if ((tio.c_cflag & CSIZE) == CS6)
|
||||
else if ((tio->c_cflag & CSIZE) == CS6)
|
||||
csize = 6;
|
||||
else if ((tio.c_cflag & CSIZE) == CS7)
|
||||
else if ((tio->c_cflag & CSIZE) == CS7)
|
||||
csize = 7;
|
||||
else
|
||||
csize = 8;
|
||||
telnet_rfc2217_cfg(tty->tn, TNS_SET_DATASIZE, &csize, 1);
|
||||
|
||||
if (tio.c_cflag & PARENB && tio.c_iflag & IGNPAR)
|
||||
if (tio->c_cflag & PARENB && tio->c_iflag & IGNPAR)
|
||||
par = 1;
|
||||
#ifdef CMSPAR
|
||||
else if (tio.c_cflag & PARENB && tio.c_iflag & CMSPAR)
|
||||
else if (tio->c_cflag & PARENB && tio->c_iflag & CMSPAR)
|
||||
{
|
||||
if (tio.c_cflag & PARODD)
|
||||
if (tio->c_cflag & PARODD)
|
||||
par = 4;
|
||||
else
|
||||
par = 5;
|
||||
}
|
||||
#endif
|
||||
else if (tio.c_cflag & PARENB)
|
||||
else if (tio->c_cflag & PARENB)
|
||||
par = 3;
|
||||
else
|
||||
par = 1;
|
||||
telnet_rfc2217_cfg(tty->tn, TNS_SET_PARITY, &par, 1);
|
||||
|
||||
if (tio.c_cflag & CSTOPB)
|
||||
if (tio->c_cflag & CSTOPB)
|
||||
sb = 2;
|
||||
else
|
||||
sb = 1;
|
||||
telnet_rfc2217_cfg(tty->tn, TNS_SET_STOPSIZE, &sb, 1);
|
||||
|
||||
if (tio.c_cflag & CRTSCTS)
|
||||
if (tio->c_cflag & CRTSCTS)
|
||||
telnet_rfc2217_ctl(tty->tn, TNS_CTL_CTSRTS);
|
||||
|
||||
if (!(tty->cmcr & TIOCM_DTR) && speed != B0)
|
||||
@@ -756,19 +759,19 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
|
||||
|
||||
DBG("termios: %u%c%u%u %cCTSRTS %cCREAD %cHUPCL %cCLOCAL\n",
|
||||
baudrate(speed), pstr[par], csize, sb,
|
||||
tio.c_cflag & CRTSCTS ? '+' : '-',
|
||||
tio.c_cflag & CREAD ? '+' : '-',
|
||||
tio.c_cflag & HUPCL ? '+' : '-',
|
||||
tio.c_cflag & CLOCAL ? '+' : '-');
|
||||
tio->c_cflag & CRTSCTS ? '+' : '-',
|
||||
tio->c_cflag & CREAD ? '+' : '-',
|
||||
tio->c_cflag & HUPCL ? '+' : '-',
|
||||
tio->c_cflag & CLOCAL ? '+' : '-');
|
||||
|
||||
ioctl(tty->fds[FD_SLAVE].fd, cmd, &tio);
|
||||
ioctl(tty->fds[FD_SLAVE].fd, cmd, tio);
|
||||
|
||||
fuse_reply_ioctl(req, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
case TCGETS:
|
||||
CHECK_BUF_OUT(sizeof(struct termios));
|
||||
fuse_reply_ioctl(req, 0, &tio, sizeof(struct termios));
|
||||
fuse_reply_ioctl(req, 0, tio, sizeof(struct termios));
|
||||
break;
|
||||
case TIOCINQ: /* Get the number of bytes in the input
|
||||
* buffer */
|
||||
|
||||
Reference in New Issue
Block a user