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>
18 #define __NR_klog __NR_syslog
20 #if defined(__GLIBC__)
24 static inline _syscall3 (int, klog, int, type, char *, b, int, len)
25 #endif /* __GLIBC__ */
29 static const char dmesg_usage[] = "dmesg [-c] [-n level]\n";
31 int dmesg_main (int argc, char **argv)
44 /* Parse any options */
45 while (argc && **argv == '-') {
55 level = atoi (*(++argv));
65 n = klog (cmd, NULL, level);
73 n = klog (cmd, buf, sizeof (buf));
80 for (i = 0; i < n; i++) {
81 if ((i == 0 || buf[i - 1] == '\n') && buf[i] == '<') {
83 while (buf[i] >= '0' && buf[i] <= '9')