console logging detour via printk
Subsystems (4)
PATCH 1/1 console logging detour via printk
Hi,
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
So in short i came up with an idea to transform console writes into printks at appropriate code place of some console drivers (the patch includes code for VT console and SERIAL_CORE console drivers). Printks eventually reach console device avoiding the patched part of the console drivers.
I find this feature very interesting for embedded devices with limited console abilities as well as for other for normal desktops using initial ram disk images and / or some splash image to beautify booting. It is always nice to have the possibility to review the complete boot output at any time.
The more detail configuration of the feature is described in the Kconfig files within the patch below.
The patch is also available here:
http://84.255.254.67/console_detour-2.6.33.3.patch
have fun, Samo
--
drivers/char/Kconfig +17 -0
@@ -66,6 +66,23 @@ config VT_CONSOLE If unsure, say Y. +config VT_CONSOLE_DETOUR + bool "Support for VT console detour via printk" + depends on VT_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages via + printk is included into VT console code. + + The feature is usefull to catch all console log. In order to use this + feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. + config HW_CONSOLE bool depends on VT && !S390 && !UML
drivers/char/vt.c +10 -0
@@ -2696,6 +2696,16 @@ static int con_write(struct tty_struct *tty, const unsigned char *buf, int count {int retval; +#ifdef CONFIG_VT_CONSOLE_DETOUR +if (console_detour) { +int idx = vt_console_driver.index -1 ; + +if ((idx >=0 ) && (idx == tty->index)) { +console_printk_detour (buf, count); +return count; + } + } +#endif retval =do_con_write (tty, buf, count);con_flush_chars (tty);
drivers/serial/Kconfig +17 -0
@@ -1031,6 +1031,23 @@ config SERIAL_CORE config SERIAL_CORE_CONSOLE bool +config SERIAL_CORE_CONSOLE_DETOUR + bool "Support for serial console detour via printk" + depends on SERIAL_CORE_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages via + printk is included into serial console code. + + The feature is usefull to catch all console log. In order to use this + feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. + config CONSOLE_POLL bool
drivers/serial/serial_core.c +6 -0
@@ -513,6 +513,12 @@ uart_write(struct tty_struct *tty, const unsigned char *buf, int count) } port = state->uart_port; +#ifdef CONFIG_SERIAL_CORE_CONSOLE_DETOUR +if (console_detour &&uart_console (port) && (port->cons->flags &CON_ENABLED )) { +console_printk_detour (buf, count); +return count; + } +#endif circ = &state->xmit;if (!circ->buf)
include/linux/console.h +6 -0
@@ -108,6 +108,12 @@ struct console {struct console *next; }; +extern int console_detour; +extern void console_printk_detour (const unsigned char *,int ); + +struct ctl_table ; +int detour_sysctl_handler (struct ctl_table *,int ,void __user *,size_t *,loff_t *); +extern int console_set_on_cmdline;extern int add_preferred_console (char *name,int idx,char *options);
init/main.c +9 -0
@@ -249,6 +249,15 @@ static int __init loglevel(char *str)early_param ("loglevel" , loglevel); +extern int console_detour; +static int __init detour (char *str) +{ + console_detour =1 ; +return 0 ; +} + +early_param ("detour" , detour); +/* * Unknown boot options get handed to init, unless they look like * unused parameters (modprobe will find them in /proc/cmdline).
kernel/printk.c +45 -0
51 lines not on this page · raw message
kernel/sysctl.c +8 -0
@@ -50,6 +50,7 @@#include <linux/ftrace.h> #include <linux/slow-work.h> #include <linux/perf_event.h> +#include <linux/console.h> #include <asm/uaccess.h> #include <asm/processor.h>
@@ -936,6 +937,13 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, },#endif + { + .procname = "console_detour", + .data = &console_detour, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &detour_sysctl_handler, + },/* * NOTE: do not add new entries to this table unless you have read * Documentation/sysctl/ctl_unnumbered.txt
Quoted 7 lines · On Sat, 01 May 2010 00:03:00 +0200 Samo Pogacnik wrote:
Hi,
drivers/char/Kconfig +0
-0
drivers/char/Kconfig config VT_CONSOLE · line 74
Quoted 9 lines
drivers/char/Kconfig +6
-0@@ -66,6 +66,23 @@ config VT_CONSOLE If unsure, say Y. +config VT_CONSOLE_DETOUR + bool "Support for VT console detour via printk" + depends on VT_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages via
If you say Y here,
drivers/char/Kconfig config VT_CONSOLE · line 77
Quoted 3 lines
drivers/char/Kconfig +3
-0+ printk is included into VT console code. + + The feature is usefull to catch all console log. In order to use this
useful log messages.
Quoted 17 lines
drivers/char/Kconfig +8
-0+ feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. + config HW_CONSOLE bool depends on VT && !S390 && !UMLdrivers/serial/Kconfig +0
-0
drivers/serial/Kconfig config SERIAL_CORE · line 1039
Quoted 9 lines
drivers/serial/Kconfig +6
-0@@ -1031,6 +1031,23 @@ config SERIAL_CORE config SERIAL_CORE_CONSOLE bool +config SERIAL_CORE_CONSOLE_DETOUR + bool "Support for serial console detour via printk" + depends on SERIAL_CORE_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages via
If you say Y here,
drivers/serial/Kconfig config SERIAL_CORE · line 1042
Quoted 3 lines
drivers/serial/Kconfig +3
-0+ printk is included into serial console code. + + The feature is usefull to catch all console log. In order to use this
useful log messages.
drivers/serial/Kconfig config SERIAL_CORE · line 1050
Quoted 8 lines
drivers/serial/Kconfig +8
-0+ feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. +
The kernel command line option needs to be added to Documentation/kernel-parameters.txt also, please.
include/linux/console.h struct console { · line 112
Quoted 13 lines
drivers/serial/Kconfig +0
-0config CONSOLE_POLL boolinclude/linux/console.h +2
-0@@ -108,6 +108,12 @@ struct console {struct console *next; }; +extern int console_detour; +extern void console_printk_detour (const unsigned char *,int );
Please include parameter names in function prototype(s).
include/linux/console.h struct console { · line 115
Quoted 3 lines
include/linux/console.h +3
-0+ +struct ctl_table ; +int detour_sysctl_handler (struct ctl_table *,int ,void __user *,size_t *,loff_t *);
ditto
include/linux/console.h struct console { · line 119
Quoted 4 lines
include/linux/console.h +1
-0+extern int console_set_on_cmdline;extern int add_preferred_console (char *name,int idx,char *options);
Looks interesting/useful to me. Thanks.
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Dne 30.04.2010 (pet) ob 15:45 -0700 je Randy Dunlap zapisal(a):
Quoted 99 lines · On Sat, 01 May 2010 00:03:00 +0200 Samo Pogacnik wrote:
Quoted 8 lines
Hi,
drivers/char/Kconfig +0
-0drivers/char/Kconfig config VT_CONSOLE · line 74
Quoted 9 lines
drivers/char/Kconfig +6
-0@@ -66,6 +66,23 @@ config VT_CONSOLE If unsure, say Y. +config VT_CONSOLE_DETOUR + bool "Support for VT console detour via printk" + depends on VT_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages viaIf you say Y here,
drivers/char/Kconfig config VT_CONSOLE · line 77
Quoted 3 lines
drivers/char/Kconfig +3
-0+ printk is included into VT console code. + + The feature is usefull to catch all console log. In order to use thisuseful log messages.
Quoted 17 lines
drivers/char/Kconfig +8
-0+ feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. + config HW_CONSOLE bool depends on VT && !S390 && !UMLdrivers/serial/Kconfig +0
-0drivers/serial/Kconfig config SERIAL_CORE · line 1039
Quoted 9 lines
drivers/serial/Kconfig +6
-0@@ -1031,6 +1031,23 @@ config SERIAL_CORE config SERIAL_CORE_CONSOLE bool +config SERIAL_CORE_CONSOLE_DETOUR + bool "Support for serial console detour via printk" + depends on SERIAL_CORE_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages viaIf you say Y here,
drivers/serial/Kconfig config SERIAL_CORE · line 1042
Quoted 3 lines
drivers/serial/Kconfig +3
-0+ printk is included into serial console code. + + The feature is usefull to catch all console log. In order to use thisuseful log messages.
drivers/serial/Kconfig config SERIAL_CORE · line 1050
Quoted 8 lines
drivers/serial/Kconfig +8
-0+ feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. +The kernel command line option needs to be added to
Documentation/kernel-parameters.txtalso, please.include/linux/console.h struct console { · line 112
Quoted 13 lines
drivers/serial/Kconfig +0
-0config CONSOLE_POLL boolinclude/linux/console.h +2
-0@@ -108,6 +108,12 @@ struct console {struct console *next; }; +extern int console_detour; +extern void console_printk_detour (const unsigned char *,int );Please include parameter names in function prototype(s).
include/linux/console.h struct console { · line 115
Quoted 3 lines
include/linux/console.h +3
-0+ +struct ctl_table ; +int detour_sysctl_handler (struct ctl_table *,int ,void __user *,size_t *,loff_t *);ditto
Quoted 3 lines
include/linux/console.h +1
-0+extern int console_set_on_cmdline;
Quoted 8 lines
include/linux/console.h struct console { · line 119
Quoted 1 line
include/linux/console.h +0
-0extern int add_preferred_console (char *name,int idx,char *options);Looks interesting/useful to me. Thanks.
---
~Randy
*** Remember to useDocumentation/SubmitChecklistwhen testing your code ***
Good morning,
Thank you for the corrections and hints. i'll catchup with an update as soon as i can.
regards, Samo
Dne 30.04.2010 (pet) ob 15:45 -0700 je Randy Dunlap zapisal(a):
Quoted 99 lines · On Sat, 01 May 2010 00:03:00 +0200 Samo Pogacnik wrote:
Quoted 8 lines
Hi,
drivers/char/Kconfig +0
-0drivers/char/Kconfig config VT_CONSOLE · line 74
Quoted 9 lines
drivers/char/Kconfig +6
-0@@ -66,6 +66,23 @@ config VT_CONSOLE If unsure, say Y. +config VT_CONSOLE_DETOUR + bool "Support for VT console detour via printk" + depends on VT_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages viaIf you say Y here,
drivers/char/Kconfig config VT_CONSOLE · line 77
Quoted 3 lines
drivers/char/Kconfig +3
-0+ printk is included into VT console code. + + The feature is usefull to catch all console log. In order to use thisuseful log messages.
Quoted 17 lines
drivers/char/Kconfig +8
-0+ feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. + config HW_CONSOLE bool depends on VT && !S390 && !UMLdrivers/serial/Kconfig +0
-0drivers/serial/Kconfig config SERIAL_CORE · line 1039
Quoted 9 lines
drivers/serial/Kconfig +6
-0@@ -1031,6 +1031,23 @@ config SERIAL_CORE config SERIAL_CORE_CONSOLE bool +config SERIAL_CORE_CONSOLE_DETOUR + bool "Support for serial console detour via printk" + depends on SERIAL_CORE_CONSOLE + default n + ---help--- + If you do say Y here, the support for writing console messages viaIf you say Y here,
drivers/serial/Kconfig config SERIAL_CORE · line 1042
Quoted 3 lines
drivers/serial/Kconfig +3
-0+ printk is included into serial console code. + + The feature is usefull to catch all console log. In order to use thisuseful log messages.
drivers/serial/Kconfig config SERIAL_CORE · line 1050
Quoted 8 lines
drivers/serial/Kconfig +8
-0+ feature, you should specify kernel command line option "detour" or write a + positive number into /proc/sys/kernel/console_detour. You can disable + the feature on-line by writing zero into the proc file. By writing a + negative value into the proc file, the feature is disabled permanently + (until next boot). + + If unsure, say N. +The kernel command line option needs to be added to
Documentation/kernel-parameters.txtalso, please.include/linux/console.h struct console { · line 112
Quoted 13 lines
drivers/serial/Kconfig +0
-0config CONSOLE_POLL boolinclude/linux/console.h +2
-0@@ -108,6 +108,12 @@ struct console {struct console *next; }; +extern int console_detour; +extern void console_printk_detour (const unsigned char *,int );Please include parameter names in function prototype(s).
include/linux/console.h struct console { · line 115
Quoted 3 lines
include/linux/console.h +3
-0+ +struct ctl_table ; +int detour_sysctl_handler (struct ctl_table *,int ,void __user *,size_t *,loff_t *);ditto
Quoted 3 lines
include/linux/console.h +1
-0+extern int console_set_on_cmdline;
Quoted 8 lines
include/linux/console.h struct console { · line 119
Quoted 1 line
include/linux/console.h +0
-0extern int add_preferred_console (char *name,int idx,char *options);Looks interesting/useful to me. Thanks.
---
~Randy
*** Remember to useDocumentation/SubmitChecklistwhen testing your code ***
Hi,
Here is the updated patch providing your hints and generalized for any console type.
regards, Samo
---
Documentation/kernel-parameters.txt +2 -0
@@ -628,6 +628,8 @@ and is between 256 and 4096 characters. It is defined in the file Defaults to the default architecture's huge page size if not specified. + detour [KNL] Enable console logging detour via printk. + dhash_entries= [KNL] Set number of hash buckets for dentry cache.
drivers/char/Kconfig +16 -0
@@ -88,6 +88,22 @@ config VT_HW_CONSOLE_BINDING information. For framebuffer console users, please refer to <file:Documentation/fb/fbcon.txt>. +config CONSOLE_DETOUR + bool "Support for console detour via printk" + default n + ---help--- + If you say Y here, the support for writing console messages via + printk is included into the console code. + + The feature is useful to catch all console log messages. + In order to use this feature, you should specify kernel command line + option "detour" or write a positive number into + /proc/sys/kernel/console_detour. You can disable the feature on-line + by writing zero into the proc file. By writing a negative value into + the proc file, the feature is disabled permanently (until next boot). + + If unsure, say N. + config DEVKMEM bool "/dev/kmem virtual device support" default y
drivers/char/tty_io.c +7 -0
@@ -1087,6 +1087,13 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf, }spin_unlock (&redirect_lock); +#ifdef CONFIG_CONSOLE_DETOUR +if (console_detour) { +console_printk_detour (buf, count); +if (!p) +return count; + } +#endif if (p) {ssize_t res; res =vfs_write (p, buf, count, &p->f_pos);
include/linux/console.h +7 -0
@@ -108,6 +108,13 @@ struct console {struct console *next; }; +extern int console_detour; +extern void console_printk_detour (const unsigned char *buf,int count); + +struct ctl_table ; +int detour_sysctl_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos); +extern int console_set_on_cmdline;extern int add_preferred_console (char *name,int idx,char *options);
init/main.c +9 -0
@@ -25,6 +25,7 @@#include <linux/bootmem.h> #include <linux/acpi.h> #include <linux/tty.h> +#include <linux/console.h> #include <linux/gfp.h> #include <linux/percpu.h> #include <linux/kmod.h>
@@ -249,6 +250,14 @@ static int __init loglevel(char *str)early_param ("loglevel" , loglevel); +static int __init detour (char *str) +{ + console_detour =1 ; +return 0 ; +} + +early_param ("detour" , detour); +/* * Unknown boot options get handed to init, unless they look like * unused parameters (modprobe will find them in /proc/cmdline).
kernel/printk.c +45 -0
51 lines not on this page · raw message
kernel/sysctl.c +8 -0
@@ -50,6 +50,7 @@#include <linux/ftrace.h> #include <linux/slow-work.h> #include <linux/perf_event.h> +#include <linux/console.h> #include <asm/uaccess.h> #include <asm/processor.h>
@@ -936,6 +937,13 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, },#endif + { + .procname = "console_detour", + .data = &console_detour, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &detour_sysctl_handler, + },/* * NOTE: do not add new entries to this table unless you have read * Documentation/sysctl/ctl_unnumbered.txt
Quoted 10 lines · Samo Pogacnik
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
Quoted 5 lines
So in short i came up with an idea to transform console writes into printks at appropriate code place of some console drivers (the patch includes code for VT console and
SERIAL_COREconsole drivers). Printks eventually reach console device avoiding the patched part of the console drivers.
What about catching /dev/console instead of VT console, SERIAL_CORE console, ...?
Then it works with whatever console= parameter you specify.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Dne 01.05.2010 (sob) ob 11:00 +0200 je Geert Uytterhoeven zapisal(a):
Quoted 17 lines · Samo Pogacnik
Quoted 10 lines
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
Quoted 5 lines
So in short i came up with an idea to transform console writes into printks at appropriate code place of some console drivers (the patch includes code for VT console and
SERIAL_COREconsole drivers). Printks eventually reach console device avoiding the patched part of the console drivers.
Quoted 3 lines
What about catching
/dev/consoleinstead of VT console,SERIAL_COREconsole, ...?
Then it works with whatever console= parameter you specify.
Could not agree more, but that was as close as i was able to detect the common code and provide something that actually works. Maybe this is already enough to cover all boot consoles?
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
regards, Samo
Dne 01.05.2010 (sob) ob 18:36 +0200 je Samo Pogacnik zapisal(a):
Quoted 18 lines
Dne 01.05.2010 (sob) ob 11:00 +0200 je Geert Uytterhoeven zapisal(a):
Quoted 17 lines · Samo Pogacnik
Quoted 15 lines
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
So in short i came up with an idea to transform console writes into printks at appropriate code place of some console drivers (the patch includes code for VT console and
SERIAL_COREconsole drivers). Printks eventually reach console device avoiding the patched part of the console drivers.
Quoted 7 lines
Quoted 3 lines
What about catching
/dev/consoleinstead of VT console,SERIAL_COREconsole, ...?
Then it works with whatever console= parameter you specify.Could not agree more, but that was as close as i was able to detect the common code and provide something that actually works. Maybe this is already enough to cover all boot consoles?
Silly me, i managed to miss the common console write method. I'll provide the change, so there is not going to be any specifics for different console types anymore.
Quoted 19 lines
Quoted 4 lines
Gr{oetje,eeting}s,
Quoted 8 lines
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvaldsregards, Samo
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
So you want to patch the kernel because you can't work out how to do this in userspace ? The distributions seem to have no problem doing this in user space that I can see. It doesn't seem to be a hard user space problem, and there are a ton of things you want to do with this sort of stuff (like network logging) that you can't do in kernel space.
Quoted 6 lines
drivers/char/vt.c +0
-0@@ -2696,6 +2696,16 @@ static int con_write(struct tty_struct *tty, const unsigned char *buf, int count {int retval;
drivers/char/vt.c static int con_write(struct tty_struct *tty, const unsigned char *buf, int count · line 2708
Quoted 10 lines
drivers/char/vt.c +10
-0+#ifdef CONFIG_VT_CONSOLE_DETOUR +if (console_detour) { +int idx = vt_console_driver.index -1 ; + +if ((idx >=0 ) && (idx == tty->index)) { +console_printk_detour (buf, count); +return count; + } + } +#endif
This requires you go around hacking up each device which is not a good idea and becomes rapidly unmaintainable.
I suspect what you actually need for such logging might be to write a very simple tty driver whose write method is implemented as printk. That works in the general case and doesn't require hacking up the code everywhere else.
However given your init stuff can trivially use openpty to set up a logged console I am not sure I see the point in doing this in kernel in the first place.
Alan
Dne 01.05.2010 (sob) ob 12:04 +0100 je Alan Cox zapisal(a):
Quoted 10 lines
Quoted 9 lines
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
Quoted 5 lines
So you want to patch the kernel because you can't work out how to do this in userspace ? The distributions seem to have no problem doing this in user space that I can see. It doesn't seem to be a hard user space problem, and there are a ton of things you want to do with this sort of stuff (like network logging) that you can't do in kernel space.
The distros have no problem logging complete console output into log files or over the network, because they simply do not do it at least for the initrd part of the boot process (i'd be glad, if i'm wrong). Anyway the proposed mechanism nicely bridges the gap between the kernel boot start and the system logging daemon start-up. It also solves the chicken and egg problem of how to log console if user space console logging facility fails.
Quoted 7 lines
Quoted 7 lines
drivers/char/vt.c +0
-0@@ -2696,6 +2696,16 @@ static int con_write(struct tty_struct *tty, const unsigned char *buf, int count {int retval;
Quoted 13 lines
drivers/char/vt.c static int con_write(struct tty_struct *tty, const unsigned char *buf, int count · line 2708
Quoted 10 lines
drivers/char/vt.c +10
-0+#ifdef CONFIG_VT_CONSOLE_DETOUR +if (console_detour) { +int idx = vt_console_driver.index -1 ; + +if ((idx >=0 ) && (idx == tty->index)) { +console_printk_detour (buf, count); +return count; + } + } +#endif This requires you go around hacking up each device which is not a good idea and becomes rapidly unmaintainable.
Agree, it should have been done within a well defined code volume.
Quoted 5 lines
I suspect what you actually need for such logging might be to write a very simple tty driver whose write method is implemented as printk. That works in the general case and doesn't require hacking up the code everywhere else.
Looks to me that some kernel code is welcome:)?
Quoted 5 lines
However given your init stuff can trivially use openpty to set up a logged console I am not sure I see the point in doing this in kernel in the first place.
As said above, how to bridge kernel boot start and logging daemon start-up without kernel help, especially when initrd is in the way? imho it would be too complicated.
Quoted 5 lines
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
thanks for the reply, with best regards, Samo
Quoted 3 lines
The distros have no problem logging complete console output into log files or over the network, because they simply do not do it at least for the initrd part of the boot process (i'd be glad, if i'm wrong).
I'd have to double check - but its trivial to move the log if so.
Quoted 6 lines
Quoted 4 lines
I suspect what you actually need for such logging might be to write a very simple tty driver whose write method is implemented as printk. That works in the general case and doesn't require hacking up the code everywhere else.
Looks to me that some kernel code is welcome:)?
I really don't see the point but if you must do it then doing it as its own driver would at least avoid making a mess in the rest of the kernel, at which point it becomes less of a problem
Quoted 8 lines
Quoted 4 lines
However given your init stuff can trivially use openpty to set up a logged console I am not sure I see the point in doing this in kernel in the first place.
As said above, how to bridge kernel boot start and logging daemon start-up without kernel help, especially when initrd is in the way? imho it would be too complicated.
Put the logging start up in the initrd, its just a ramdisk its not special in any way at all.
Dne 01.05.2010 (sob) ob 20:41 +0100 je Alan Cox zapisal(a):
Quoted 22 lines
Quoted 3 lines
The distros have no problem logging complete console output into log files or over the network, because they simply do not do it at least for the initrd part of the boot process (i'd be glad, if i'm wrong).
I'd have to double check - but its trivial to move the log if so.
Quoted 6 lines
Quoted 4 lines
I suspect what you actually need for such logging might be to write a very simple tty driver whose write method is implemented as printk. That works in the general case and doesn't require hacking up the code everywhere else.
Looks to me that some kernel code is welcome:)?
I really don't see the point but if you must do it then doing it as its own driver would at least avoid making a mess in the rest of the kernel, at which point it becomes less of a problem
Quoted 5 lines
Quoted 4 lines
However given your init stuff can trivially use openpty to set up a logged console I am not sure I see the point in doing this in kernel in the first place.
Quoted 6 lines
Quoted 3 lines
As said above, how to bridge kernel boot start and logging daemon start-up without kernel help, especially when initrd is in the way? imho it would be too complicated.
Put the logging start up in the initrd, its just a ramdisk its not special in any way at all.
I understand and can agree with everything you said, however providing an additional mechanism might not hurt. Funny enough by generalizing the patch for any console type, the essential code change is made at the same place where initial console redirection mechanism has been implemented. And again, console redirection can not log anything that has been output to console prior to redirection activation.
regards, Samo
Quoted 17 lines · Samo Pogacnik
Dne 01.05.2010 (sob) ob 12:04 +0100 je Alan Cox zapisal(a):
Quoted 10 lines
Quoted 9 lines
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
Quoted 5 lines
So you want to patch the kernel because you can't work out how to do this in userspace ? The distributions seem to have no problem doing this in user space that I can see. It doesn't seem to be a hard user space problem, and there are a ton of things you want to do with this sort of stuff (like network logging) that you can't do in kernel space.
Quoted 3 lines
The distros have no problem logging complete console output into log files or over the network, because they simply do not do it at least for the initrd part of the boot process (i'd be glad, if i'm wrong).
Mmm...It's an interesting problem. I see in my distro (openSuse) a script called boot.klog that it seems to perform that (even initrd part). In the file boot.msg I can see the initial prints of the kernel and user space scripts.
Marco
Dne 02.05.2010 (ned) ob 11:58 +0200 je Marco Stornelli zapisal(a):
Quoted 18 lines
Quoted 17 lines · Samo Pogacnik
Dne 01.05.2010 (sob) ob 12:04 +0100 je Alan Cox zapisal(a):
Quoted 15 lines
Quoted 9 lines
while i was searching for effective logging of complete console output produced by the kernel and user phase of the boot process, it turned out that only kernel messages imho get systematically cached and stored into log files (if needed). All userspace processes are on their own to use syslog, which is fine, but there are also many console messages reporting the boot status via init scripts, .... I came across the bootlogd daemo, which handles the job of redirecting console output into a log file, but i find it problematic to use especialy, when using initial ram disk image.
So you want to patch the kernel because you can't work out how to do this in userspace ? The distributions seem to have no problem doing this in user space that I can see. It doesn't seem to be a hard user space problem, and there are a ton of things you want to do with this sort of stuff (like network logging) that you can't do in kernel space.
Quoted 9 lines
Quoted 3 lines
The distros have no problem logging complete console output into log files or over the network, because they simply do not do it at least for the initrd part of the boot process (i'd be glad, if i'm wrong).
Mmm...It's an interesting problem. I see in my distro (openSuse) a script called boot.klog that it seems to perform that (even initrd part). In the file boot.msg I can see the initial prints of the kernel and user space scripts.
Thanks for the info.
Is this boot.klog script from the initrd image or from the real rootfs? As you can see, i am still suspicious about the initrd part user console messages:)
Samo
Il 02/05/2010 15:29, Samo Pogacnik ha scritto:
Quoted 8 lines
Dne 02.05.2010 (ned) ob 11:58 +0200 je Marco Stornelli zapisal(a):
Quoted 7 lines
01/05/2010 20:48, Samo Pogacnik wrote:
Mmm...It's an interesting problem. I see in my distro (openSuse) a script called boot.klog that it seems to perform that (even initrd part). In the file boot.msg I can see the initial prints of the kernel and user space scripts.
Quoted 8 lines
Thanks for the info.
Is this boot.klog script from the initrd image or from the real rootfs? As you can see, i am still suspicious about the initrd part user console messages:)Samo
In the initrd there's the script blogd.sh:
if test -z "$fboot" -a -z "$quiet" -a -z "$REDIRECT" ; then
REDIRECT=$(showconsole 2>/dev/null)
if test -n "$REDIRECT" ; then
if test "$devpts" != "yes" ; then
mount -t devpts devpts /dev/pts devpts=yes
fi
> /dev/shm/initrd.msg
ln -sf /dev/shm/initrd.msg /var/log/boot.msg mkdir -p /var/run
/sbin/blogd $REDIRECT
fi
fi
And in the rootfs the boot.klog script:
# Read all kernel messages generated until now and put them in one file.
test -s /var/log/boot.msg && mv -f /var/log/boot.msg /var/log/boot.omsg echo Creating /var/log/boot.msg
if test -x /sbin/klogd ; then
# klogd syncs out the file
/sbin/klogd -s -o -n -f /var/log/boot.msg
test -s /var/log/boot.msg
rc_status -v1 -r
elif test -x /bin/dmesg ; then
/bin/dmesg > /var/log/boot.msg
/bin/sync
test -s /var/log/boot.msg
rc_status -v1 -r
fi
if test -e /dev/shm/initrd.msg ; then
cat /dev/shm/initrd.msg >> /var/log/boot.msg
rm -f /dev/shm/initrd.msg
fi
[ --- cut here --- ]
Regards,
Marco