Some little bugs in 2.0.5

Piercarlo Grandi (piercarl@sabi.demon.co.uk)
Thu, 11 Jul 1996 12:00:34 +0100


Here are four patches for some small bugs in 2.0.5 (and probably also in
all 2.0.x releases so far.

The first is that for some reason, as originally reported by Bob Riggs:

Date: Sat, 24 Feb 1996 14:36:14 +0200
From: Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
Message-Id: <199602241236.OAA11644@keos.cs.Helsinki.FI>
In-Reply-To: Robert Riggs's message as of Feb 24, 5:04
To: rriggs@tesser.com
Subject: Re: [BUG] ppp/slip fails with 1.3.6[78]
Cc: Linux-Kernel Mailing List <linux-kernel@vger.rutgers.edu>
Sender: owner-linux-kernel@vger.rutgers.edu
Precedence: bulk
Status: RO
Robert Riggs: "[BUG] ppp/slip fails with 1.3.6[78]" (Feb 24, 5:04):
> I traced my problems with ppp/slip not working to this
> section of the 1.3.67 patch:
>
> --- include/asm-i386/termios.h Sat Feb 24 04:23:03 1996
> +++ include/asm-i386/termios.h.new Fri Feb 23 11:35:15 1996
> @@ -268,6 +268,8 @@
>
> #ifdef __KERNEL__
>
> +#include <linux/string.h>
> +
> /*
> * Translate a "termio" structure into a "termios". Ugh.
> */
>
>
> Reversing this allows slip/ppp to connect.
That definitely does not make sense. What compiler are you using? The
only way I see for the above patch to break anything at all is a
compiler bug when compiling the kernel.
Or maybe some old out-of-date object file just got re-compiled correctly
when you changed termios.h?
Linus

I know too it does not make sense -- but I have had the same problem,
that termio calls fail, as reported by Bob originally, as I have had it
since 1.3.69:

With the patch in, I get the following errors in the syslog:

with pppd...
Feb 24 03:59:30 diamond pppd[544]: pppd 2.2.0 started by rob, uid 0
Feb 24 03:59:30 diamond pppd[544]: tcgetattr: I/O error
Feb 24 03:59:30 diamond pppd[544]: Exit.
with dip...
Feb 24 04:01:43 diamond dip[554]: DIP: tty: get_state: I/O error

And an strace of pppd shows this:

open("/dev/cua2", RDWR|NDELAY) = 7
fcntl(7, F_GETFL, 0) = 2050
fcntl(7, F_SETFL, 0x2) = 0
ioctl(7, TCGETS, 0xbffffa80) = -1 (I/O error)
time(0xbfffee54) = 825159972
getpid() = 571
write(5, "<27>Feb 24 04:06:12 pppd[571]: t".., 52) = 52
ioctl(7, TIOCMBIC, [0x2]) = -1 (I/O error)
fcntl(7, F_SETFL, 0x2) = 0
close(7) = 0
time(0xbfffee48) = 825159972
getpid() = 571
write(5, "<30>Feb 24 04:06:12 pppd[571]: E".., 37) = 37
exit(1) = ?

The solution is to use '__builtin_memcpy':

========================================================================
--- linux/include/asm-i386/termios.h~ Mon Apr 1 08:46:30 1996
+++ linux/include/asm-i386/termios.h Sun Jun 30 17:46:03 1996
@@ -55,7 +55,9 @@

#ifdef __KERNEL__

-#include <linux/string.h>
+#if 0 /* For some reason the 'memcpy' below fails */
+# include <linux/string.h>
+#endif

/*
* Translate a "termio" structure into a "termios". Ugh.
@@ -69,7 +71,7 @@
SET_LOW_BITS(termios->c_cflag, termio->c_cflag);
SET_LOW_BITS(termios->c_lflag, termio->c_lflag);
#undef SET_LOW_BITS
- memcpy(termios->c_cc, termio->c_cc, NCC);
+ __builtin_memcpy(termios->c_cc, termio->c_cc, NCC);
}

/*
@@ -83,7 +85,7 @@
termio->c_cflag = termios->c_cflag;
termio->c_lflag = termios->c_lflag;
termio->c_line = termios->c_line;
- memcpy(termio->c_cc, termios->c_cc, NCC);
+ __builtin_memcpy(termio->c_cc, termios->c_cc, NCC);
}

#endif /* __KERNEL__ */
========================================================================

Another little bug happens in 'dmasound.c' in the sound driver, simply
that 'bootinfo.h' should be included only on amigas and ataris (I
think):

========================================================================
--- linux/drivers/sound/dmasound.c~ Sat Jul 6 09:31:43 1996
+++ linux/drivers/sound/dmasound.c Thu Jul 11 02:23:55 1996
@@ -78,13 +78,14 @@
#include <asm/system.h>
#include <asm/irq.h>
#include <asm/pgtable.h>
-#include <asm/bootinfo.h>

#ifdef CONFIG_ATARI
+#include <asm/bootinfo.h>
#include <asm/atarihw.h>
#include <asm/atariints.h>
#endif /* CONFIG_ATARI */
#ifdef CONFIG_AMIGA
+#include <asm/bootinfo.h>
#include <asm/amigahw.h>
#include <asm/amigaints.h>
#endif /* CONFIG_AMIGA */
========================================================================

Then compiling the kernel as ELF fails to produce a compressed version
on intel machines because 'arch/i386/boot/compressed/Makefile' does not
include the rules file, and thus the config information:

========================================================================
--- linux/arch/i386/boot/Makefile~ Sun May 5 07:05:58 1996
+++ linux/arch/i386/boot/Makefile Wed Jul 10 21:36:48 1996
@@ -94,3 +94,5 @@
rm -f zImage tools/build compressed/vmlinux.out
rm -f bzImage tools/bbuild compressed/bvmlinux.out
@$(MAKE) -C compressed clean
+
+include $(TOPDIR)/Rules.make
========================================================================

Finally, a little problem with defining a symbol within '__KERNEL__' and
then using it outside it:

========================================================================
--- linux/include/net/route.h~ Tue Jun 4 14:56:30 1996
+++ linux/include/net/route.h Sun Jun 30 18:01:39 1996
@@ -60,7 +60,6 @@

#ifdef __KERNEL__
#define RTF_LOCAL 0x8000
-#endif

struct rtable
{
@@ -173,5 +172,6 @@
return rt;
}

+#endif

#endif /* _ROUTE_H */
========================================================================

I still have some terrible problem with my PPP connections dropping
every few minutes (at random) while the line stays up; this happens both
an ISP (demon) and with SLiRP 1.0c, and leads me to suspect that the
problem is within the PPP code (either ppp-2.2.0f or ther kernel PPP
code).