Reformatted init code to make if/while logic more clear.
Cleaned up some output from readbootlog. Added -e flg to bootlogd. When -e is used, data saved to the boot log file does not have escape characters removed. This means colour and cursor movement codes stay in the log file. The may then look nicer when read with "less -R', but may appear cluttered or out of alignment when viewed with other, plain-text tools.
This commit is contained in:
parent
362315a997
commit
fa124114ae
@ -22,6 +22,7 @@ bootlogd \- record boot messages
|
|||||||
.B /sbin/bootlogd
|
.B /sbin/bootlogd
|
||||||
.RB [ \-c ]
|
.RB [ \-c ]
|
||||||
.RB [ \-d ]
|
.RB [ \-d ]
|
||||||
|
.RB [ \-e ]
|
||||||
.RB [ \-r ]
|
.RB [ \-r ]
|
||||||
.RB [ \-s ]
|
.RB [ \-s ]
|
||||||
.RB [ \-v ]
|
.RB [ \-v ]
|
||||||
@ -34,6 +35,10 @@ the messages will be kept in memory until it is.
|
|||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.IP \fB\-d\fP
|
.IP \fB\-d\fP
|
||||||
Do not fork and run in the background.
|
Do not fork and run in the background.
|
||||||
|
.IP \fB\-e\fP
|
||||||
|
Print escape characters to the boot log file. This turns off filtering of
|
||||||
|
escape characters and allows tools like GNU Less to see and use colour control
|
||||||
|
characters (show the log in colour).
|
||||||
.IP \fB\-c\fP
|
.IP \fB\-c\fP
|
||||||
Attempt to write to the logfile even if it does not yet exist.
|
Attempt to write to the logfile even if it does not yet exist.
|
||||||
Without this option,
|
Without this option,
|
||||||
|
@ -340,7 +340,7 @@ dontuse:
|
|||||||
/*
|
/*
|
||||||
* Write data and make sure it's on disk.
|
* Write data and make sure it's on disk.
|
||||||
*/
|
*/
|
||||||
void writelog(FILE *fp, unsigned char *ptr, int len)
|
void writelog(FILE *fp, unsigned char *ptr, int len, int print_escape_characters)
|
||||||
{
|
{
|
||||||
int dosync = 0;
|
int dosync = 0;
|
||||||
int i;
|
int i;
|
||||||
@ -363,6 +363,8 @@ void writelog(FILE *fp, unsigned char *ptr, int len)
|
|||||||
|
|
||||||
/* remove escape sequences, but do it in a way that allows us to stop
|
/* remove escape sequences, but do it in a way that allows us to stop
|
||||||
* in the middle in case the string was cut off */
|
* in the middle in case the string was cut off */
|
||||||
|
if (! print_escape_characters)
|
||||||
|
{
|
||||||
if (inside_esc == 1) {
|
if (inside_esc == 1) {
|
||||||
/* first '[' is special because if we encounter it again, it should be considered the final byte */
|
/* first '[' is special because if we encounter it again, it should be considered the final byte */
|
||||||
if (*ptr == '[') {
|
if (*ptr == '[') {
|
||||||
@ -403,7 +405,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} /* end of if we should filter escape characters */
|
||||||
|
|
||||||
if (!ignore) {
|
if (!ignore) {
|
||||||
fwrite(ptr, sizeof(char), 1, fp);
|
fwrite(ptr, sizeof(char), 1, fp);
|
||||||
@ -430,7 +432,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len)
|
|||||||
*/
|
*/
|
||||||
void usage(void)
|
void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-s] [-c] [-p pidfile] [-l logfile]\n");
|
fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-e] [-s] [-c] [-p pidfile] [-l logfile]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,14 +492,14 @@ int main(int argc, char **argv)
|
|||||||
int considx;
|
int considx;
|
||||||
struct real_cons cons[MAX_CONSOLES];
|
struct real_cons cons[MAX_CONSOLES];
|
||||||
int num_consoles, consoles_left;
|
int num_consoles, consoles_left;
|
||||||
|
int print_escape_sequence = 0;
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
logfile = LOGFILE;
|
logfile = LOGFILE;
|
||||||
pidfile = NULL;
|
pidfile = NULL;
|
||||||
rotate = 0;
|
rotate = 0;
|
||||||
dontfork = 0;
|
dontfork = 0;
|
||||||
|
|
||||||
while ((i = getopt(argc, argv, "cdsl:p:rv")) != EOF) switch(i) {
|
while ((i = getopt(argc, argv, "cdesl:p:rv")) != EOF) switch(i) {
|
||||||
case 'l':
|
case 'l':
|
||||||
logfile = optarg;
|
logfile = optarg;
|
||||||
break;
|
break;
|
||||||
@ -517,6 +519,9 @@ int main(int argc, char **argv)
|
|||||||
case 'd':
|
case 'd':
|
||||||
dontfork = 1;
|
dontfork = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
print_escape_sequence = 1;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
syncalot = 1;
|
syncalot = 1;
|
||||||
break;
|
break;
|
||||||
@ -678,8 +683,8 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (--consoles_left <= 0) got_signal = 1;
|
if (--consoles_left <= 0) got_signal = 1;
|
||||||
break;
|
break;
|
||||||
}
|
} /* end of while */
|
||||||
}
|
} /* end of going through all consoles */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Increment buffer position. Handle
|
* Increment buffer position. Handle
|
||||||
@ -693,8 +698,8 @@ int main(int argc, char **argv)
|
|||||||
inptr = ringbuf;
|
inptr = ringbuf;
|
||||||
if (outptr >= endptr)
|
if (outptr >= endptr)
|
||||||
outptr = ringbuf;
|
outptr = ringbuf;
|
||||||
}
|
} /* end of got data from read */
|
||||||
}
|
} /* end of checking select for new data */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perhaps we need to open the logfile.
|
* Perhaps we need to open the logfile.
|
||||||
@ -714,8 +719,8 @@ int main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
todo = endptr - outptr;
|
todo = endptr - outptr;
|
||||||
if (fp && todo)
|
if (fp && todo)
|
||||||
writelog(fp, (unsigned char *)outptr, todo);
|
writelog(fp, (unsigned char *)outptr, todo, print_escape_sequence);
|
||||||
}
|
} /* end of while waiting for signal */
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
if (!didnl) fputc('\n', fp);
|
if (!didnl) fputc('\n', fp);
|
||||||
|
@ -2433,7 +2433,8 @@ void check_init_fifo(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for data to appear, _if_ the pipe was opened. */
|
/* Wait for data to appear, _if_ the pipe was opened. */
|
||||||
if (pipe_fd >= 0) while(!quit) {
|
if (pipe_fd >= 0) {
|
||||||
|
while(!quit) {
|
||||||
|
|
||||||
/* Do select, return on EINTR. */
|
/* Do select, return on EINTR. */
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
@ -2504,9 +2505,9 @@ void check_init_fifo(void)
|
|||||||
default:
|
default:
|
||||||
initlog(L_VB, "got unimplemented initrequest.");
|
initlog(L_VB, "got unimplemented initrequest.");
|
||||||
break;
|
break;
|
||||||
}
|
} /* end of switch */
|
||||||
}
|
} /* end of while loop not quitting */
|
||||||
|
} /* end of if the pipe is open */
|
||||||
/*
|
/*
|
||||||
* We come here if the pipe couldn't be opened.
|
* We come here if the pipe couldn't be opened.
|
||||||
*/
|
*/
|
||||||
|
@ -58,6 +58,20 @@ int Clean_Line(char *source_line, char *output_line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* done found character to scrub */
|
} /* done found character to scrub */
|
||||||
|
else if ( (a_letter == '?') && (source_line[source_index + 1] == '?') &&
|
||||||
|
(source_line[source_index + 2] == '7') )
|
||||||
|
{
|
||||||
|
source_index += 3;
|
||||||
|
output_line[target_index] = ' ';
|
||||||
|
target_index++;
|
||||||
|
}
|
||||||
|
else if ( (a_letter == '8') && (source_line[source_index + 1] == '?') &&
|
||||||
|
(source_line[source_index + 2] == '?') )
|
||||||
|
{
|
||||||
|
source_index += 3;
|
||||||
|
output_line[target_index] = ']';
|
||||||
|
target_index++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output_line[target_index] = a_letter;
|
output_line[target_index] = a_letter;
|
||||||
|
Loading…
Reference in New Issue
Block a user