Allow kernel log messages to console with loglevel=7

Since Finit v4.0 kernel console output has been silenced just prior to
the banner being printed, unless finit.debug mode was enabled.  This
patch makes sure to check the kernel loglevel, if it's >= 7, finit no
longer disables kernel console ouput.

Consequently, you now need 'quiet' on your kernel command line, or a
loglevel < 7 for a quiet boot, at least until a syslogd takes over.

This means that you now can debug the kernel and finit independently,
which should be a great comfort to anyone doing bringup or any form of
kernel debugging.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2022-01-02 01:34:49 +01:00
parent e5fff5117d
commit 5ff27c4fe2
3 changed files with 28 additions and 1 deletions
+25
View File
@@ -87,6 +87,7 @@ fallback:
/*
* finit.debug = [on,off]
* finit.show_status = [on,off]
* finit.status_style = [old,classic,modern]
*/
static void parse_finit_opts(char *opt)
{
@@ -170,6 +171,29 @@ static void parse_kernel_cmdline(void)
#define parse_kernel_cmdline()
#endif
static void parse_kernel_loglevel(void)
{
char line[LINE_SIZE], *ptr;
FILE *fp;
int val;
fp = fopen("/proc/sys/kernel/printk", "r");
if (!fp)
return;
if (!fgets(line, sizeof(line), fp)) {
fclose(fp);
return;
}
fclose(fp);
ptr = chomp(line);
_d("%s", ptr);
val = atoi(ptr);
if (val >= 7)
kerndebug = 1;
}
/*
* Kernel gives us all non-kernel options on our cmdline
*/
@@ -179,6 +203,7 @@ void conf_parse_cmdline(int argc, char *argv[])
parse_arg(argv[i]);
parse_kernel_cmdline();
parse_kernel_loglevel();
log_init();
}
+2 -1
View File
@@ -65,6 +65,7 @@ int debug = 0; /* debug mode from kernel cmdline */
int rescue = 0; /* rescue mode from kernel cmdline */
int single = 0; /* single user mode from kernel cmdline */
int bootstrap = 1; /* set while bootrapping (for TTYs) */
int kerndebug = 0; /* set if /proc/sys/kernel/printk > 7 */
char *sdown = NULL;
char *network = NULL;
char *hostname = NULL;
@@ -86,7 +87,7 @@ static void banner(void)
* similar enabled to start emptying /dev/kmsg, but for
* our progress we want to own the console.
*/
if (!debug)
if (!debug && !kerndebug)
klogctl(6, NULL, 0);
/*
+1
View File
@@ -114,6 +114,7 @@ extern int debug;
extern int rescue;
extern int single;
extern int bootstrap;
extern int kerndebug;
extern char *rcsd;
extern char *sdown;
extern char *network;