LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Arvid Brodin <arvid.brodin@enea.com>
To: linux-kernel@vger.kernel.org
Subject: Re: Print long messages to console from kernel module
Date: Fri, 29 Feb 2008 15:58:46 +0100	[thread overview]
Message-ID: <47C81DA6.8040100@enea.com> (raw)
In-Reply-To: <47C2FB39.3080508@enea.com>

Things have cleared a bit. First, my problem is with printing to console.
Second, the date-time-host header is only appended when using loglevel
KERN_DEBUG. Third, the <n> tag is only appended to the beginning of the printk
printout if the last printout did not end with a '\n'. The whole printk code is
quite confuscated IMO, not the least so call_console_drivers(), so this could be
a feature, however it looks to me like the loglevel tag is for internal use and
my guess is it should never be printed on the console at all.

I'll look into filing a bug report and patch for this. At the moment the best
solution seems to be to search through the log I want to print and cut the
printout after every '\n'. That should take care of most of the "<n>"'s.

-- 
Arvid Brodin
Enea LCC


On 2008-02-25 18:30, Arvid Brodin wrote:
> I need to write messages > 1023 characters long to the console from a module*. printk() is limited to 1023 characters, and splitting the message over several printk()'s results in a line break and "Month hh:mm:ss host kernel:" being inserted in my text.
> 
> I tried including <linux/console.h> and using the console_drivers declared there, but get
> "WARNING: "console_drivers" [<path>/log.ko] undefined!" when compiling and
> "insmod: error inserting 'log.ko': -1 Unknown symbol in module" when insmodding.
> 
> I guess this is because non EXPORT_SYMBOL'd symbols are only accessible to statically linked code, and not to modules? I see in printk.c that console_drivers is set up there, and I haven't been able to find any other interface to console_drivers.
> 
> In short: is there any way to print messages to the console from a kernel module, except printk()? Is opening /dev/tty and writing to it the way to go?
> 
> 
> * I'm writing an in-memory logger to be included in a module. The log can be several megabytes. The idea is to use SysRq to print the contents of the log to console after a kernel panic or otherwise when writing to disk might not work.
> 

      parent reply	other threads:[~2008-02-29 14:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-25 17:30 Arvid Brodin
2008-02-25 22:27 ` linux-os (Dick Johnson)
2008-02-26 12:58   ` Arvid Brodin
2008-02-29 14:58 ` Arvid Brodin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47C81DA6.8040100@enea.com \
    --to=arvid.brodin@enea.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: Print long messages to console from kernel module' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).