diff options
Diffstat (limited to 'cmds/dumpstate/utils.c')
-rw-r--r-- | cmds/dumpstate/utils.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index 14984ec..21526f9 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -28,6 +28,7 @@ #include <sys/stat.h> #include <sys/time.h> #include <sys/wait.h> +#include <sys/klog.h> #include <time.h> #include <unistd.h> @@ -96,6 +97,30 @@ out_close: return; } +void do_dmesg() { + printf("------ KERNEL LOG (dmesg) ------\n"); + int size = klogctl(10, NULL, 0); /* Get size of kernel buffer */ + if (size <= 0) { + printf("Unexpected klogctl return value: %d\n\n", size); + return; + } + char *buf = (char *) malloc(size + 1); + if (buf == NULL) { + printf("memory allocation failed\n\n"); + return; + } + int retval = klogctl(KLOG_READ_ALL, buf, size); + if (retval < 0) { + printf("klogctl failure\n\n"); + free(buf); + return; + } + buf[retval] = '\0'; + printf("%s\n\n", buf); + free(buf); + return; +} + void do_showmap(int pid, const char *name) { char title[255]; char arg[255]; |