diff options
-rw-r--r-- | usr.bin/osh/osh.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index c45d9c8..9b4e9ab 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -49,6 +49,7 @@ "echo - Print the arguments to the console\n" \ "reboot - Reboot the machine\n" \ "shutdown - Power off the machine\n" \ + "kmsg - Print kernel message buffer\n" \ "exit - Exit the shell\n" #define PROMPT "[root::osmora]~ " @@ -87,6 +88,29 @@ cmd_shutdown(int fd, int argc, char *argv[]) } void +cmd_kmsg(int fd, int argc, char *argv[]) +{ + int mfd; + ssize_t retval; + char linebuf[256]; + + if ((mfd = open("/dev/kmsg", O_RDONLY)) < 0) { + return; + } + + for (;;) { + retval = read(mfd, linebuf, sizeof(linebuf) - 1); + if (retval <= 0) { + break; + } + linebuf[retval] = '\0'; + prcons(fd, linebuf); + } + + close(mfd); +} + +void cmd_echo(int fd, int argc, char *argv[]) { for (i = 1; i < argc; i++) { @@ -171,6 +195,7 @@ struct command cmds[] = { {"exit", cmd_exit}, {"reboot", cmd_reboot}, {"shutdown", cmd_shutdown}, + {"kmsg", cmd_kmsg}, {NULL, NULL} }; |