6 /* dmesg.c -- Print out the contents of the kernel ring buffer
7 * Created: Sat Oct 9 16:19:47 1993
8 * Revised: Thu Oct 28 21:52:17 1993 by faith@cs.unc.edu
9 * Copyright 1993 Theodore Ts'o (tytso@athena.mit.edu)
10 * This program comes with ABSOLUTELY NO WARRANTY.
11 * Modifications by Rick Sladkey (jrs@world.std.com)
12 * from util-linux; adapted for busybox
15 #include <linux/unistd.h>
19 #define __NR_klog __NR_syslog
21 #if defined(__GLIBC__)
25 static inline _syscall3(int,klog,int,type,char *,b,int,len)
26 #endif /* __GLIBC__ */
28 const char dmesg_usage[] = "dmesg";
31 dmesg_main(struct FileInfo * info, int argc, char * * argv)
42 while ((c = getopt( argc, argv, "cn:" )) != EOF) {
66 n = klog( cmd, NULL, level );
74 n = klog( cmd, buf, sizeof( buf ) );
81 for (i = 0; i < n; i++) {
82 if ((i == 0 || buf[i - 1] == '\n') && buf[i] == '<') {
84 while (buf[i] >= '0' && buf[i] <= '9')