Hi SamuelI found something in kmsg_putchar.
if kmsg_write_offset +1 == kmsg_read_offset (mod KMSGBUFFSIZE)
it just discards the character which leads to the previous message being
malformed.
Should it in that case also terminate the current message by setting the
previously written char (at kmsg_write_offset -1 mod KMSGBUFFERSIZE) to \n ?
There is a potential problem when KMSGBUFFERSIZE == 2 but in that case the ring
buffer idea is a bit weird anyway.
I tried this patch and it fixes the problem. Some messages are being lost but I
don't know what else to do with them. (i am reusing the offset variable that is
not needed anymore)
--8<---------------cut here---------------start------------->8---
diff --git a/device/kmsg.c b/device/kmsg.c
index e5b518e6..821bb5c1 100644
--- a/device/kmsg.c
+++ b/device/kmsg.c
@@ -237,6 +237,12 @@ kmsg_putchar (int c)
if (offset == kmsg_read_offset)
{
/* Discard C. */
+ /* Terminate the previous message with a \n */
+ offset = kmsg_write_offset - 1;
+ if (offset < 0)
+ offset += KMSGBUFSIZE;
+ kmsg_buffer[offset] = '\n';
+
if (spl_init)
simple_unlock_irq (s, &kmsg_lock);
return;
--8<---------------cut here---------------end--------------->8---
I guess I encounter this because at boot time a lot of messages are being
written to the buffer in a short time before the syslogd can start emptying
them so increasing the buffer prevents the early wraparound.