From 5d3815b0ffa8ac21da2adcacbbd4b086322ce2a4 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Mon, 12 Nov 2018 20:53:52 -0400 Subject: [PATCH] Added manual page and options for readbootlog. --- doc/Changelog | 6 +++++ man/bootlogd.8.todo | 52 ---------------------------------------- man/readbootlog.1 | 58 +++++++++++++++++++++++++++++++++++++++++++++ src/Makefile | 7 ++++-- src/readbootlog.c | 28 +++++++++++++++++++++- 5 files changed, 96 insertions(+), 55 deletions(-) delete mode 100644 man/bootlogd.8.todo create mode 100644 man/readbootlog.1 diff --git a/doc/Changelog b/doc/Changelog index 05439b4..ab724de 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -48,6 +48,12 @@ sysvinit (2.92) unreleased; urgency=low style formating. Closes Debian bug #571590 Thanks to Philipp Marek for the patch. + * Added new tool (readbootlog) which will read the /var/log/boot file + produced by bootlogd. The output is displayed cleaned up so there + are no control characters. This avoids the need to use sed or related + tools to try to clean up the contents of the log. + * Added manual page for readbootlog program. + sysvinit (2.91) world; urgency=low diff --git a/man/bootlogd.8.todo b/man/bootlogd.8.todo deleted file mode 100644 index 4f24cfc..0000000 --- a/man/bootlogd.8.todo +++ /dev/null @@ -1,52 +0,0 @@ -'\" -*- coding: UTF-8 -*- -.\" Copyright (C) 1998-1999 Miquel van Smoorenburg. -.\" -.\" This program is free software; you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation; either version 2 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program; if not, write to the Free Software -.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -.\" -.TH BOOTLOGD 8 "Aug 24, 1999" "" "Linux System Administrator's Manual" -.SH NAME -bootlogd \- record boot messages -.SH SYNOPSIS -.B /sbin/bootlogd -.RB [ \-d ] -.RB [ \-r ] -.RB [ \-v ] -.RB [ " -l logfile " ] -.RB [ " -p pidfile " ] -.SH DESCRIPTION -\fBBootlogd\fP runs in the background and copies all strings sent to the -\fI/dev/console\fP device to a logfile. If the logfile is not accessible, -the messages will be buffered in-memory until it is. -.SH OPTIONS -.IP \fB\-d\fP -Do not fork and run in the background. -.IP \fB\-r\fP -If there is an existing logfile called \fIlogfile\fP rename it to -\fIlogfile~\fP unless \fIlogfile~\fP already exists. -.IP \fB\-v\fP -Show version. -.IP \fB\-l logfile\fP -Log to this logfile. The default is \fI/var/log/boot.log\fP. -.IP \fB\-p pidfile\fP -Put process-id in this file. The default is no pidfile. -.SH NOTES -There is no standard way to find out the real console device if you have -a new-style \fI/dev/console\fP device (major 5, minor 1). \fBBootlogd\fP -might have some difficulties to do this, especially under very old -or very new kernels. -.SH AUTHOR -Miquel van Smoorenburg, miquels@cistron.nl -.SH "SEE ALSO" -.BR dmesg (8) diff --git a/man/readbootlog.1 b/man/readbootlog.1 new file mode 100644 index 0000000..c95369b --- /dev/null +++ b/man/readbootlog.1 @@ -0,0 +1,58 @@ +'\" -*- coding: UTF-8 -*- +.\" Copyright (C) 1998-2004 Miquel van Smoorenburg. +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program; if not, write to the Free Software +.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +.\" +.\"{{{}}} +.\"{{{ Title +.TH READBOOTLOG 1 "NOV 12, 2018" "" "Linux System Administrator's Manual" +.\"}}} +.\"{{{ Name +.SH NAME +readbootlog \- show contents of the boot log, stripping away control characters +.\"}}} +.\"{{{ Synopsis +.SH SYNOPSIS +.B readbootlog +.RB [ \-h ] +.RB "[ \-\fBf\fP \fIfile\fP ]" +.br +.\"}}} +.\"{{{ Description +.SH DESCRIPTION +.B readbootlog +is a tool for reading the boot log (by default /var/log/boot). The program +strips away control characters and non-human readable contents from the log +file. Output is dumped to the terminal where it can be piped or redirected +to a file. +.\"}}} +.\"{{{ Options +.SH OPTIONS +.IP "\fB\-f\fP \fIfile\fP" +Tells \fBreadbootlog\fP to use a specific file instead of \fB/var/log/boot\fP. +.IP \fB\-h\fP +Displays a brief help message. +.\"{{{ Files +.SH FILES +/var/log/boot +.\"}}} +.\"{{{ Author +.SH AUTHOR +Jesse Smith +.\"}}} +.\"{{{ See also +.SH "SEE ALSO" +.BR bootlogd (8) +.\"}}} diff --git a/src/Makefile b/src/Makefile index 7b5b622..3c93783 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,9 +24,9 @@ MNTPOINT= # For some known distributions we do not build all programs, otherwise we do. BIN = SBIN = init halt shutdown runlevel killall5 fstab-decode -USRBIN = last mesg +USRBIN = last mesg readbootlog -MAN1 = last.1 lastb.1 mesg.1 +MAN1 = last.1 lastb.1 mesg.1 readbootlog.1 MAN5 = initscript.5 inittab.5 initctl.5 MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8 MAN8 += shutdown.8 telinit.8 fstab-decode.8 @@ -139,6 +139,9 @@ shutdown: dowall.o shutdown.o utmp.o bootlogd: LDLIBS += -lutil $(STATIC) bootlogd: bootlogd.o bootlogd.h +readbootlog: LDLIBS += $(STATIC) +readbootlog: readbootlog.o bootlogd.h + fstab-decode: LDLIBS += $(STATIC) fstab-decode: fstab-decode.o diff --git a/src/readbootlog.c b/src/readbootlog.c index a7d2a1d..f83c5d0 100644 --- a/src/readbootlog.c +++ b/src/readbootlog.c @@ -1,5 +1,7 @@ #include +#include #include +#include #include "bootlogd.h" #ifndef MAX_LINE @@ -8,7 +10,13 @@ void print_usage() { - + printf("readbootlog reads the system's boot log, stripping away\n"); + printf("control characters to make the log human readable.\n\n"); + printf("Usage for readbootlog: readbootlog [-h] [-f logfile]\n"); + printf("\t\t-h display this help message\n"); + printf("\t\t-f display a specific boot log file\n"); + printf("\t\t default is to use %s\n", LOGFILE); + printf("\n"); } /* @@ -75,6 +83,24 @@ int main(int argc, char *argv[]) char line[MAX_LINE]; char output[MAX_LINE]; char *status; + int c; + + /* check provided options */ + while ( (c = getopt(argc, argv, "hf:") ) != EOF) + { + switch (c) + { + case 'h': + print_usage(); + exit(0); + case 'f': + log_filename = optarg; + break; + default: + print_usage(); + exit(1); + } + } /* done processing arguments */ log_file = fopen(log_filename, "r"); if (log_file)