--- ttynvt.c.orig	2020-07-13 23:39:20.446708550 +0200
+++ ttynvt.c	2020-07-16 19:12:04.471359604 +0200
@@ -66,7 +66,7 @@
     char            net_buf[NET_BUF_SIZE];
     int             net_cnt;
 
-    struct termios  tio;
+    struct termios2  tio;
 
     int             cmcr;       /* Commanded by ioctl */
     volatile int    smcr;       /* Status from modem */
@@ -420,7 +420,7 @@
 {
     ttynvt_t       *tty;
     char           *slave_name;
-    struct termios  ios;
+    struct termios2  ios;
     int             sockfd;
     int             fd;
     int             res;
@@ -623,6 +623,7 @@
     else if (res != (int)size)
     {
         tty->pollout = 0;
+        DBG("CAUTION: tty->pollout set to 0");
     }
 
     fuse_reply_write(req, res);
@@ -660,9 +661,13 @@
         snprintf(buf, sizeof(buf), "0x%x", cmd);
         return buf;
         CASE(TCSETSF);
+        CASE(TCSETSF2); // Shad's mod
         CASE(TCSETSW);
+        CASE(TCSETSW2); // Shad's mod
         CASE(TCSETS);
+        CASE(TCSETS2); // Shad's mod
         CASE(TCGETS);
+        CASE(TCGETS2); // Shad's mod
         CASE(TIOCINQ);
         CASE(TIOCOUTQ);
         CASE(TCFLSH);
@@ -688,7 +693,7 @@
     }
 }
 
-static unsigned int _tio_parity(const struct termios *tio)
+static unsigned int _tio_parity(const struct termios2 *tio)
 {
     unsigned int    par;
 
@@ -711,12 +716,17 @@
     return par;
 }
 
-static unsigned int _tio_baud(const struct termios *tio)
+static unsigned int _tio_baud(const struct termios2 *tio)
 {
     return baudrate(tio->c_cflag & (CBAUD | CBAUDEX));
 }
 
-static unsigned int _tio_csize(const struct termios *tio)
+static unsigned int _tio2_baud(const struct termios2 *tio2)
+{
+    return tio2->c_ospeed;
+}
+
+static unsigned int _tio_csize(const struct termios2 *tio)
 {
     unsigned int    csize;
 
@@ -732,7 +742,7 @@
     return csize;
 }
 
-static unsigned int _tio_stopb(const struct termios *tio)
+static unsigned int _tio_stopb(const struct termios2 *tio)
 {
     unsigned int    stopb;
 
@@ -744,7 +754,7 @@
     return stopb;
 }
 
-static void _show_termios(const char *txt, const struct termios *tio)
+static void _show_termios(const char *txt, const struct termios2 *tio)
 {
     DBG("%s: %u%c%u%u %cCTSRTS %cCREAD %cHUPCL %cCLOCAL\n", txt,
         _tio_baud(tio), pstr[_tio_parity(tio)], _tio_csize(tio),
@@ -753,6 +763,16 @@
         tio->c_cflag & HUPCL ? '+' : '-', tio->c_cflag & CLOCAL ? '+' : '-');
 }
 
+static void _show_termios2(const char *txt, const struct termios2 *tio)
+{
+    DBG("%s: %u%c%u%u %cCTSRTS %cCREAD %cHUPCL %cCLOCAL\n", txt,
+        _tio2_baud(tio), pstr[_tio_parity(tio)], _tio_csize(tio),
+        _tio_stopb(tio),
+        tio->c_cflag & CRTSCTS ? '+' : '-', tio->c_cflag & CREAD ? '+' : '-',
+        tio->c_cflag & HUPCL ? '+' : '-', tio->c_cflag & CLOCAL ? '+' : '-');
+}
+
+
 #define CHECK_BUF_IN(sz) \
     if (in_bufsz < sz)  do { in_bufsz  = sz; goto retry_in;  } while(0)
 #define CHECK_BUF_OUT(sz) \
@@ -764,7 +784,7 @@
              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 termios2 *tio = &tty->tio;
     struct winsize  ws;
     unsigned int    tiocm = 0;
     int             mcr;
@@ -782,11 +802,26 @@
     case TCSETSF:
     case TCSETSW:
     case TCSETS:
-        CHECK_BUF_IN(sizeof(struct termios));
-        {
-            memcpy(tio, in_buf, in_bufsz);
-
-            byte4 = htonl(_tio_baud(tio));
+    case TCSETSF2: // Shad's mod - BEWARE of tio/tio2 buf structure difference!
+    case TCSETSW2: // Shad's mod - BEWARE of tio/tio2 buf structure difference!
+    case TCSETS2:  // Shad's mod - BEWARE of tio/tio2 buf structure difference!
+        {
+            switch (cmd){
+              case TCSETSF:
+              case TCSETSW:
+              case TCSETS:
+                  CHECK_BUF_IN(sizeof(struct termios));
+                  memcpy(tio, in_buf, in_bufsz);
+                  byte4 = htonl(_tio_baud(tio));
+                  break;
+              case TCSETSF2:
+              case TCSETSW2:
+              case TCSETS2:
+                  CHECK_BUF_IN(sizeof(struct termios2));
+                  memcpy(tio, in_buf, in_bufsz);
+                  byte4 = htonl(_tio2_baud(tio));
+                  break;
+            }
             telnet_rfc2217_cfg(tty->tn, TNS_SET_BAUDRATE, &byte4, 4);
 
             byte = _tio_csize(tio);
@@ -815,11 +850,22 @@
                 telnet_rfc2217_ctl(tty->tn, TNS_CTL_DTR_ON);
             }
 
-            _show_termios("TCSETS", tio);
+            switch (cmd){
+              case TCSETSF:
+              case TCSETSW:
+              case TCSETS:
+                  _show_termios("TCSETS", tio);
+              case TCSETSF2:
+              case TCSETSW2:
+              case TCSETS2:
+                  _show_termios2("TCSETS2", tio);
+            }
             ioctl(tty->fds[FD_SLAVE].fd, cmd, tio);
 
             if (cmd == TCSETSF)
                 tty->slave_suspended = 0;       /* Re-enable polling of Slave */
+            if (cmd == TCSETSF2)
+                tty->slave_suspended = 0;       /* Re-enable polling of Slave */
 
             fuse_reply_ioctl(req, 0, 0, 0);
         }
@@ -830,6 +876,12 @@
         _show_termios("TCGETS", tio);
         fuse_reply_ioctl(req, 0, tio, sizeof(struct termios));
         break;
+    case TCGETS2: // Shad's mod
+        CHECK_BUF_OUT(sizeof(struct termios2));
+        ioctl(tty->fds[FD_SLAVE].fd, TCGETS2, tio);
+        _show_termios2("TCGETS2", tio);
+        fuse_reply_ioctl(req, 0, tio, sizeof(struct termios2));
+        break;
     case TIOCINQ:              /* Get the number of bytes in the input
                                  * buffer */
         CHECK_BUF_OUT(sizeof(int));
@@ -983,6 +1035,7 @@
             fuse_reply_ioctl(req, 0, &val, sizeof(int));
         break;
     default:
+        DBG("ERR:unsupported IOCTL");
         fuse_reply_err(req, ENOSYS);
         break;
 
