From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753131AbdLSPRd (ORCPT ); Tue, 19 Dec 2017 10:17:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:59988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752564AbdLSPRb (ORCPT ); Tue, 19 Dec 2017 10:17:31 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3796D21893 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Tue, 19 Dec 2017 10:17:27 -0500 From: Steven Rostedt To: Sergey Senozhatsky Cc: Petr Mladek , Linus Torvalds , Fengguang Wu , Kevin Hilman , Mark Brown , Greg Kroah-Hartman , Andrew Morton , LKML , Sergey Senozhatsky Subject: Re: [PATCHv2] printk: add console_msg_format command line option Message-ID: <20171219101727.15ddb486@gandalf.local.home> In-Reply-To: <20171219084243.1549-1-sergey.senozhatsky@gmail.com> References: <20171219084243.1549-1-sergey.senozhatsky@gmail.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 19 Dec 2017 17:42:43 +0900 Sergey Senozhatsky wrote: > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 8a61d1eda677..543de386e01e 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -642,6 +642,20 @@ > console=brl,ttyS0 > For now, only VisioBraille is supported. > > + console_msg_format= > + [KNL] Change console messages format > + default > + By default we print messages on consoles in > + "[time stamp] text\n" format (time stamp may not be > + printed, depending on CONFIG_PRINTK_TIME or > + `printk_time' param). > + syslog > + Switch to syslog format: "<%u>[time stamp] text\n" > + IOW, each message will have a facility and loglevel > + prefix. The format is similar to one used by syslog() > + syscall, or to executing "dmesg -S --raw" or to reading > + from /proc/kmsg. Just to clarify. This affects all consoles, not just serial? > + > consoleblank= [KNL] The console blank (screen saver) timeout in > seconds. A value of 0 disables the blank timer. > Defaults to 0. > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index c2e713f6ae2e..16dd91260273 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -277,6 +277,13 @@ EXPORT_SYMBOL(console_set_on_cmdline); > /* Flag: console code may call schedule() */ > static int console_may_schedule; > > +enum con_msg_format { > + MSG_FORMAT_DEFAULT = 0, > + MSG_FORMAT_SYSLOG = (1 << 0), > +}; So the con_msg_format will be a flag (as denoted with the (1<<0)). Should we call it "con_msg_format_flags" to make it more obvious that these are treated as flags and not a simple number. > + > +static int console_msg_format = MSG_FORMAT_DEFAULT; > + > /* > * The printk log buffer consists of a chain of concatenated variable > * length records. Every record starts with a record header, containing > @@ -1913,6 +1920,17 @@ static int __add_preferred_console(char *name, int idx, char *options, > c->index = idx; > return 0; > } > + > +static int __init console_msg_format_setup(char *str) > +{ > + if (!strncmp(str, "syslog", 6)) > + console_msg_format = MSG_FORMAT_SYSLOG; > + if (!strncmp(str, "default", 7)) You can use strcmp() instead of strncmp(), the init code will nul terminate the string for you before calling this function. Otherwise if we add "syslog_special" or "default_extra" they will be confused with the above. -- Steve > + console_msg_format = MSG_FORMAT_DEFAULT; > + return 1; > +} > +__setup("console_msg_format=", console_msg_format_setup); > + > /* > * Set up a console. Called via do_early_param() in init/main.c > * for each "console=" parameter in the boot command line. > @@ -2215,7 +2233,10 @@ void console_unlock(void) > goto skip; > } > > - len += msg_print_text(msg, false, text + len, sizeof(text) - len); > + len += msg_print_text(msg, > + console_msg_format & MSG_FORMAT_SYSLOG, > + text + len, > + sizeof(text) - len); > if (nr_ext_console_drivers) { > ext_len = msg_print_ext_header(ext_text, > sizeof(ext_text),