Added manual page and options for readbootlog.

This commit is contained in:
Jesse Smith
2018-11-12 20:53:52 -04:00
parent 7c1a8d932a
commit 5d3815b0ff
5 changed files with 96 additions and 55 deletions

View File

@@ -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

View File

@@ -1,5 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#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 <logfile> 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)