From tytso@Athena.MIT.EDU Sat May  8 00:10:02 1993
Received: from ATHENA-AS-WELL.MIT.EDU by e40-po.MIT.EDU (5.61/4.7) id AA18849; Thu, 29 Apr 93 08:22:08 EDT
Received: from SOS.MIT.EDU by Athena.MIT.EDU with SMTP
	id AA06610; Thu, 29 Apr 93 08:22:07 EDT
Received: by SOS (5.57/4.7) id AA22570; Thu, 29 Apr 93 08:22:06 -0400
Date: Thu, 29 Apr 93 08:22:06 -0400
From: Theodore Ts'o <tytso@Athena.MIT.EDU>
Message-Id: <9304291222.AA22570@SOS>
To: eichin@Athena.MIT.EDU ("Mark W. Eichin")
In-Reply-To: "Mark W. Eichin"'s message of Wed, 28 Apr 93 21:02:37 EDT,
	<9304290102.AA00732@tsx-11.MIT.EDU>
Subject: Re: dmesg.c
Address: 1 Amherst St., Cambridge, MA 02139
Phone: (617) 253-8091
SUB: Re: dmesg.c
SUM: Theodore Ts'o <tytso>->eichin ("Mark W. Eichin")

Here you go.....

/*
 * dmesg.c --- prints out the contents of the Kernel ring buffer 
 */

#include <linux/unistd.h>
#include <stdio.h>

#define __NR_klog	__NR_syslog

static inline _syscall3(int,klog,int,type,char *,b,int,len)

main(argc, argv)
	int	argc;
	char	**argv;
{
	char buf[4096];
	int	i;
	int	cmd = 3;

	if (argc > 2) {
		fprintf(stderr, "Usage: %s [-c]\n", argv[0]);
		exit(1);
	}
	if (argc > 1 && !strcmp(argv[1], "-c")) {
		cmd = 4;
	}
	i = klog(cmd, buf, sizeof(buf));
	if (i < 0) {
		perror("klog");
		exit(1);
	}
	write(1, buf, i);
	exit(0);
}

	

