| * dmesg - display/control kernel ring buffer. |
| * Copyright 2006 Rob Landley <rob@landley.net> |
| * Copyright 2006 Bernhard Reutner-Fischer <rep.nop@aon.at> |
| * Licensed under GPLv2, see file LICENSE in this tarball for details. |
| int dmesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| int dmesg_main(int argc UNUSED_PARAM, char **argv) |
| opt_complementary = "s+:n+"; /* numeric */ |
| opts = getopt32(argv, "cs:n:", &len, &level); |
| if (klogctl(8, NULL, (long) level)) |
| bb_perror_msg_and_die("klogctl"); |
| len = klogctl(10, NULL, 0); /* read ring buffer size */ |
| len = klogctl(3 + (opts & OPT_c), buf, len); /* read ring buffer */ |
| bb_perror_msg_and_die("klogctl"); |
| /* Skip <#> at the start of lines, and make sure we end with a newline */ |
| if (ENABLE_FEATURE_DMESG_PRETTY) { |
| if (last == '\n' && buf[in] == '<') |
| full_write(STDOUT_FILENO, buf, len); |
| if (ENABLE_FEATURE_CLEAN_UP) free(buf); |