public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 10/17] setterm: make -msglevel 0 to work as is did earlier
Date: Sun, 18 May 2014 15:05:34 +0100	[thread overview]
Message-ID: <1400421941-14244-11-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1400421941-14244-1-git-send-email-kerolasa@iki.fi>

Commit 3393c136 caused regression.  The klogctl() logging range is 1-8,
but the value 0 is special according to setterm.1 manual page.  It turns
on loging, same way as '-msg on' option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 bash-completion/setterm |  2 +-
 term-utils/setterm.c    | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/bash-completion/setterm b/bash-completion/setterm
index f47debf..8e0f629 100644
--- a/bash-completion/setterm
+++ b/bash-completion/setterm
@@ -51,7 +51,7 @@ _setterm_module()
 			return 0
 			;;
 		'-msglevel')
-			COMPREPLY=( $(compgen -W "{1..8}" -- $cur) )
+			COMPREPLY=( $(compgen -W "{0..8}" -- $cur) )
 			return 0
 			;;
 		'-powersave')
diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index 3a02347..2f9151c 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -134,7 +134,7 @@ enum {
 
 /* Console log levels */
 enum {
-	CONSOLE_LEVEL_MIN = 1,
+	CONSOLE_LEVEL_MIN = 0,
 	CONSOLE_LEVEL_MAX = 8
 };
 
@@ -446,16 +446,14 @@ usage(FILE *out) {
 	fputs(_(" -append <1-NR_CONSOLES>\n"), out);
 	fputs(_(" -file dumpfilename\n"), out);
 	fputs(_(" -msg <on|off>\n"), out);
-	fputs(_(" -msglevel <0-8>\n"), out);	/* FIXME: klogctl console_log range is 1-8 */
+	fputs(_(" -msglevel <0-8>\n"), out);
 	fputs(_(" -powersave <on|vsync|hsync|powerdown|off>\n"), out);
 	fputs(_(" -powerdown <0-60>\n"), out);
 	fputs(_(" -blength <0-2000>\n"), out);
 	fputs(_(" -bfreq freqnumber\n"), out);
 	fputs(_(" -version\n"), out);
 	fputs(_(" -help\n"), out);
-
 	fprintf(out, USAGE_MAN_TAIL("setterm(1)"));
-
 	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
@@ -660,6 +658,10 @@ static void parse_option(struct setterm_control *ctl, int argc, char **argv)
 		case OPT_MSGLEVEL:
 			ctl->opt_msglevel = set_opt_flag(ctl->opt_msglevel);
 			ctl->opt_msglevel_num = parse_msglevel(optarg);
+			if (ctl->opt_msglevel_num == 0) {
+				ctl->opt_msg = set_opt_flag(ctl->opt_msg);
+				ctl->opt_msg_on |= 1;
+			}
 			break;
 		case OPT_POWERSAVE:
 			ctl->opt_powersave = set_opt_flag(ctl->opt_powersave);
@@ -1031,7 +1033,7 @@ static void perform_sequence(struct setterm_control *ctl)
 	}
 
 	/* -msglevel [0-8] */
-	if (ctl->opt_msglevel && ctl->vcterm) {
+	if (ctl->opt_msglevel_num && ctl->vcterm) {
 		/* 8 -- Set level of messages printed to console */
 		result = klogctl(SYSLOG_ACTION_CONSOLE_LEVEL, NULL, ctl->opt_msglevel_num);
 		if (result != 0)
-- 
1.9.2


  parent reply	other threads:[~2014-05-18 14:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-18 14:05 [PATCH 00/17] pull: almost complete setterm refactoring Sami Kerola
2014-05-18 14:05 ` [PATCH 01/17] setterm: clean up includes Sami Kerola
2014-05-18 14:05 ` [PATCH 02/17] setterm: use getopt_long_only() for option parsing Sami Kerola
2014-05-19  9:29   ` Karel Zak
2014-05-18 14:05 ` [PATCH 03/17] setterm: use string utils to numeric parsing Sami Kerola
2014-05-19  9:24   ` Karel Zak
2014-05-18 14:05 ` [PATCH 04/17] setterm: move show_tabs() and screendump() functions Sami Kerola
2014-05-18 14:05 ` [PATCH 05/17] setterm: remove usage comment segment Sami Kerola
2014-05-18 14:05 ` [PATCH 06/17] setterm: add option control structure Sami Kerola
2014-05-19  9:38   ` Karel Zak
2014-05-19  9:48   ` Karel Zak
2014-05-18 14:05 ` [PATCH 07/17] setterm: add init_terminal() to make main() shorter Sami Kerola
2014-05-18 14:05 ` [PATCH 08/17] setterm: clean up screendump() Sami Kerola
2014-05-18 14:05 ` [PATCH 09/17] setterm: remove devfs and /dev/vcsa0 support Sami Kerola
2014-05-19  9:52   ` Karel Zak
2014-05-18 14:05 ` Sami Kerola [this message]
2014-05-18 14:05 ` [PATCH 11/17] setterm: correct usage() bright color argument Sami Kerola
2014-05-19  9:57   ` Karel Zak
2014-05-18 14:05 ` [PATCH 12/17] setterm: improve perform_sequence() coding style Sami Kerola
2014-05-18 14:05 ` [PATCH 13/17] setterm: tell user when options does not effect Sami Kerola
2014-05-19 10:02   ` Karel Zak
2014-05-18 14:05 ` [PATCH 14/17] setterm: improve error messages Sami Kerola
2014-05-18 14:05 ` [PATCH 15/17] setterm: various visual terminal effects are not console specific Sami Kerola
2014-05-18 14:05 ` [PATCH 16/17] setterm: mark some options to be exclusive with each other Sami Kerola
2014-05-18 14:05 ` [PATCH 17/17] setterm: add set_blanking() action Sami Kerola
2014-05-19 21:51 ` [PATCH 00/17] pull: almost complete setterm refactoring Sami Kerola
2014-05-20  8:11   ` Benno Schulenberg
2014-05-20 10:02     ` Karel Zak

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=1400421941-14244-11-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@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