Re: Patch to make serial module shut up.

Hans Lermen (lermen@elserv.ffm.fgan.de)
Mon, 29 Apr 1996 10:47:07 +0200 (MET DST)


On Sun, 28 Apr 1996, Russ Steffen wrote:

> I finally got sick of the the serial driver (which I have as a module)
> babbling at the console every time it's inserted. So, I made this
> patch that that adds a KERN_INFO priority to the "normal" printk's
> in the serial module.

There is a quite simpler solution, which also avoids other annoying
messages:

1. Patch the kernel to allow a lower MINIMUM_CONSOLE_LOGLEVEL (see below)

2. Redirect the printk() dups to a fix console (e.g 8) (see program below)

Having a 'klogconsole -l 1 -r 8' in your rc.local then lets you relax again.

Hans
<lermen@elserv.ffm.fgan.de>

---------------------------kernel patch-----------------------------
--- linux/kernel/printk.c~ Sun Mar 17 00:08:40 1996
+++ linux/kernel/printk.c Sun Mar 17 00:18:22 1996
@@ -33,7 +33,7 @@
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */

/* We show everything that is MORE important than this.. */
-#define MINIMUM_CONSOLE_LOGLEVEL 5 /* Minimum loglevel we let people use */
+#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */

unsigned long log_size = 0;
--------------------------------------------------------------------

-------------------------- klogconsole.c ---------------------------
/* (C) 1996 under GPL, Hans Lermen <lermen@elserv.ffm.fgan.de>,
* parts of switch_printk_console() stolen from Kevin Buhr <buhr@stat.wisc.edu>
*/
#include <stdio.h>
#include <unistd.h>
#include <linux/unistd.h>
#include <linux/termios.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>

static _syscall3(int, syslog, int, type, char *, bufp, int, len);

static void console_level(int level)
{
syslog(8,0,level);
}

static void switch_printk_console(int new_console)
{
int newvt;
int vt;

if ((new_console < 1) || (new_console > 8)) {
fprintf(stderr,"wrong console number\n");
exit(1);
}

newvt = (new_console << 8) | 11;
vt = open( "/dev/tty1", O_RDONLY );
if( vt == -1 ) {
perror("open(/dev/tty1)");
exit(1);
}
if( ioctl( vt, TIOCLINUX, &newvt ) ) {
perror("ioctl(TIOCLINUX)");
exit(1);
}
close(vt);
}

void usage(void)
{
printf(
"USAGE:\n"
" klogconsole [-l console_loglevel ] [ -r console ]\n\n"
" console_loglevel 0..7 (kernel may dissallow values <5)\n"
" console 1..8 console to which printk() dups messages\n"
);
exit(1);
}

main (int argc, char** argv, char** env)
{
int op,i;
extern char *optarg;
extern int optind, opterr;

if (argc <= 1) usage();
opterr = 0;
while ((op = getopt(argc, argv, "l:r:")) != EOF) {
switch (op) {
case 'l': {
i=atoi(optarg);
console_level(i);
break;
}
case 'r': {
i=atoi(optarg);
switch_printk_console(i);
break;
}
default: {
usage();
/* doesn't return */
}
}
}
return 0;
}
--------------------------------------------------------------------