From: gregg@netcom.com (gregg weber)
Newsgroups: comp.os.linux.announce
Subject: program to disable console kernel messages
Date: 28 Jul 1993 21:44:29 -0400
Approved: linux-announce@tc.cornell.edu (Matt Welsh)
Message-ID: <237a1t$i5i@theory.TC.Cornell.EDU>

For those of us who use the console in a production environment, and
other users use the floppy drive, VFS: disk change detected messages
can be annoying. So, here is a syslogk that will disable those messages.
The syslogk with my version of SLS (1.02) did not work, so I am
contributing this modified version. The file below is called
syslogk.c, and in SLS, it resides in /usr/src.

===== snip snip ==========
/* modified 7-28-93 by gregg weber gregg@netcom.com
 modified to work with 0.99pl10. Not tried with other versions.
 see printk.c sys_syslog() for how this program affects the kernel
 to use, become root. Compile this file. Copy syslogk to /usr/bin.
 put appropriate line in /etc/rc.local,
 E.G. if [ -x /usr/bin/syslogk]; then
           /usr/bin/syslogk on >/usr/log/kernel.
 make sure the directory /usr/log exists.
 reboot, and no more printk's on the console. 8-)
 */


usage()
{
	puts("capture kernel messages and write them to standard");
   	puts("out,  which can be redirected to a file or tty."); 
   	puts("usage: syslogk on");
	puts("       syslogk off");
	exit(-1);
}

#define __LIBRARY__
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <linux/unistd.h>

static _syscall3(int,syslog,int,type,char *,buf,int,size);

char buffer[1024];

int main(int argc, char ** argv)
{
        int i;

        errno = 0;
        if (argc == 2 && !strcmp("off",argv[1]))
                syslog(0,0,0);
        else if (argc == 2 && !strcmp("on",argv[1]))
	{
                syslog(1,0,0); /* initialize log (see printk.c) */
		syslog(6,0,0); /* disable console messages */
                while (1) {
                        i = syslog(2,buffer,1024);
                        if (i < 0)
                                if (errno == EINTR)
                                        continue;
                                else
                                        break;
                        write(1,buffer,i);
                }
		syslog(7,0,0); /* turn on console messages (I assume they were
 on to start with. This may become a bug in the future if console messages are
 turned off by some other process. */
	}
	else
		usage();
        if (errno)
                perror("syslog");
        return errno;
}
-- 

-- 
Send submissions for comp.os.linux.announce to: linux-announce@tc.cornell.edu
