From: Frans Pop <elendil@planet.nl>
To: linux-kernel@vger.kernel.org
Cc: cryptsetup@packages.debian.org
Subject: [PATCH,RFC] printk: Restore to previous console_loglevel when re-enabling logging
Date: Sun, 28 Jun 2009 20:18:07 +0200 [thread overview]
Message-ID: <200906282018.08538.elendil@planet.nl> (raw)
In-Reply-To: <200906282005.12020.elendil@planet.nl>
When logging to console is disabled from userspace using klogctl
and later re-enabled, console_loglevel gets set to the default
log level instead to the previous value.
This means that if the kernel was booted with 'quiet', the boot is
suddenly no longer quiet after logging to console gets re-enabled.
Save the current console_loglevel when logging is disabled and
restore to that value. If the log level is set to a specific value
while disabled, this is interpreted as an implicit re-enabling of
the logging.
Signed-off-by: Frans Pop <elendil@planet.nl>
---
There are two variations possible on the patch below.
1) If klogctl(7) is called while logging is not disabled, then set level
to default (partially preserving current functionality):
case 7: /* Enable logging to console */
- console_loglevel = default_console_loglevel;
+ if (saved_console_loglevel == -1)
+ console_loglevel = default_console_loglevel;
+ else {
+ console_loglevel = saved_console_loglevel;
+ saved_console_loglevel = -1;
+ }
2) If klogctl(8) is called while logging is disabled, then don't enable
logging, but remember the requested value for when logging does get
enabled again:
case 8: /* Set level of messages printed to console */
[...]
- console_loglevel = len;
+ if (saved_console_loglevel == -1)
+ console_loglevel = len;
+ else
+ saved_console_loglevel = len;
Yet either option would be to ignore the request.
diff --git a/kernel/printk.c b/kernel/printk.c
index b4d97b5..acbf050 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -271,6 +271,7 @@ int do_syslog(int type, char __user *buf, int len)
int do_clear = 0;
char c;
int error = 0;
+ static int saved_console_loglevel = -1;
error = security_syslog(type);
if (error)
@@ -372,10 +373,15 @@ int do_syslog(int type, char __user *buf, int len)
logged_chars = 0;
break;
case 6: /* Disable logging to console */
+ if (saved_console_loglevel == -1)
+ saved_console_loglevel = console_loglevel;
console_loglevel = minimum_console_loglevel;
break;
case 7: /* Enable logging to console */
- console_loglevel = default_console_loglevel;
+ if (saved_console_loglevel != -1) {
+ console_loglevel = saved_console_loglevel;
+ saved_console_loglevel = -1;
+ }
break;
case 8: /* Set level of messages printed to console */
error = -EINVAL;
@@ -384,6 +390,8 @@ int do_syslog(int type, char __user *buf, int len)
if (len < minimum_console_loglevel)
len = minimum_console_loglevel;
console_loglevel = len;
+ /* Implicitly re-enable logging to console */
+ saved_console_loglevel = -1;
error = 0;
break;
case 9: /* Number of chars in the log buffer */
prev parent reply other threads:[~2009-06-28 18:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-28 18:05 Inconsistent console logging using 'quiet' with encrypted root fs Frans Pop
2009-06-28 18:18 ` Frans Pop [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=200906282018.08538.elendil@planet.nl \
--to=elendil@planet.nl \
--cc=cryptsetup@packages.debian.org \
--cc=linux-kernel@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox