minicom [non-] bug and linux kernel 2.6.25.4

R.L. Horn lists at eastcheap.org
Fri Jun 20 07:29:16 UTC 2008


On Wed, 18 Jun 2008, Adam Lackorzynski wrote:

> Now, what to do about minicom itself? Just leave it as is and tell
> people to use .25.8 (if it will be in there) or apply a fix? What do you
> think?

Well, there are already eight buggy (stable) versions of the kernel, at 
least one of which has found its way into a distribution.  In light of the 
fact that there's been no major outcry over this, I think the bug's 
probably going to have to be accommodated for awhile, if only as a 
courtesy to the relatively small legacy hardware/minicom "community."

Perhaps more importantly, as always, the sooner you release an updated 
version, the less likely it is that your work will be mangled by 
distributors (somehow, I suspect that that's one of the reasons linux 
releases are so darn rushed).

I favor checking that the kernel is behaving as it should, and logging a 
warning if not (while putting things right).  Something like the enclosed 
patch.

If you release, say, a 2.3.1 now, it will probably have blown over by the 
time there's a 2.4 or 2.5 (you know, when gcc 5 refuses to compile the 
older version :-)), and the check can be removed.
-------------- next part --------------
--- minicom-2.3/src/sysdep1.c	2007-10-10 15:18:20.000000000 -0500
+++ minicom-new/src/sysdep1.c	2008-06-20 01:23:46.000000000 -0500
@@ -38,6 +38,7 @@
 
 #include "sysdep.h"
 #include "minicom.h"
+#include "intl.h"
 
 /* Set hardware flow control. */
 void m_sethwf(int fd, int on)
@@ -122,6 +123,17 @@
     /* Posix - set baudrate to 0 and back */
     struct termios tty, old;
 
+#   if defined(TIOCMODG) && defined(TIOCMODS) \
+         && defined(TIOCM_RTS) && defined(TIOCM_DTR)
+
+    int mcs, dtrrtsstate;
+
+    /* Save the DTR/RTS state */
+    ioctl(fd, TIOCMODG, &dtrrtsstate);
+    dtrrtsstate &= (TIOCM_DTR | TIOCM_RTS);
+
+#   endif
+
     tcgetattr(fd, &tty);
     tcgetattr(fd, &old);
     cfsetospeed(&tty, B0);
@@ -130,6 +142,21 @@
     if (sec > 0) {
       sleep(sec);
       tcsetattr(fd, TCSANOW, &old);
+
+#   if defined(TIOCMODG) && defined(TIOCMODS) \
+         && defined(TIOCM_RTS) && defined(TIOCM_DTR)
+
+      /* Check that DTR and RTS are unchanged.  If not, restore saved state and
+       * log a warning. */
+      ioctl(fd, TIOCMODG, &mcs);
+      if ((mcs & (TIOCM_DTR | TIOCM_RTS)) != dtrrtsstate) {
+        do_log(_("DTR and/or RTS state changed after restoring baud rate from B0.  Possible kernel bug."));
+	/* Restore previous state. */
+	mcs |= dtrrtsstate;
+	ioctl(fd, TIOCMODS, &mcs);
+      }
+
+#   endif
     }
 
 #  else /* POSIX */


More information about the minicom-devel mailing list