[RFC PATCH 6/7] um: Suppress non-fatal messages when quiet

From: Masami Hiramatsu
Date: Fri Apr 28 2017 - 06:27:52 EST


Suppress non-fatal boot messages when "quiet" kernel
parameter is given.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
arch/um/os-Linux/util.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c
index 8745f23..7afcb41 100644
--- a/arch/um/os-Linux/util.c
+++ b/arch/um/os-Linux/util.c
@@ -13,6 +13,7 @@
#include <wait.h>
#include <sys/mman.h>
#include <sys/utsname.h>
+#include <init.h>
#include <os.h>

void stack_protections(unsigned long address)
@@ -153,10 +154,25 @@ void um_early_printk(const char *s, unsigned int n)
printf("%.*s", n, s);
}

+static int quiet_non_fatal;
+
+static int __init quiet_cmd_param(char *str, int *add)
+{
+ quiet_non_fatal = 1;
+ return 0;
+}
+
+__uml_setup("quiet", quiet_cmd_param,
+"quiet\n"
+" Turns off non-fatal message during boot.\n\n");
+
void non_fatal(const char *fmt, ...)
{
va_list list;

+ if (quiet_non_fatal)
+ return;
+
va_start(list, fmt);
vfprintf(stderr, fmt, list);
va_end(list);