linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] um: Fix printf usage and support quiet option
@ 2017-04-28 10:19 Masami Hiramatsu
  2017-04-28 10:21 ` [RFC PATCH 1/7] um: Use printk instead of printf in make_uml_dir Masami Hiramatsu
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:19 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

Hello,

This series fixes some boot time printf output to stderr
by default, and support "quiet" option to suppress non-
fatal error (or warning) messages in user-mode-linux.
Also the last one allows user to pass "console=" option
to kernel.



Thank you,

---

Masami Hiramatsu (7):
      um: Use printk instead of printf in make_uml_dir
      um: Use non_fatal() in check_coredump_limit
      um: Make non_fatal non-static for other files
      um: Use non_fatal() for non-fatal information/warning messages
      um: Print out fatal error in stderr
      um: Suppress non-fatal messages when quiet
      um: console: Ignore console= option


 arch/um/drivers/stdio_console.c |    3 +++
 arch/um/include/shared/os.h     |    1 +
 arch/um/kernel/physmem.c        |    8 ++++----
 arch/um/kernel/um_arch.c        |   16 +++++++++-------
 arch/um/kernel/umid.c           |    4 ++--
 arch/um/os-Linux/main.c         |   10 +++++-----
 arch/um/os-Linux/mem.c          |   24 ++++++++++++------------
 arch/um/os-Linux/start_up.c     |   23 ++++++++---------------
 arch/um/os-Linux/umid.c         |   14 ++++++++------
 arch/um/os-Linux/util.c         |   25 +++++++++++++++++++++++++
 10 files changed, 77 insertions(+), 51 deletions(-)

--
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC PATCH 1/7] um: Use printk instead of printf in make_uml_dir
  2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
@ 2017-04-28 10:21 ` Masami Hiramatsu
  2017-04-28 10:22 ` [RFC PATCH 2/7] um: Use non_fatal() in check_coredump_limit Masami Hiramatsu
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:21 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

Since this function will be called after printk buffer
initialized, use printk as other functions do.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/um/os-Linux/umid.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index c1dc892..b94a416 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -50,13 +50,15 @@ static int __init make_uml_dir(void)
 	err = -ENOMEM;
 	uml_dir = malloc(strlen(dir) + 1);
 	if (uml_dir == NULL) {
-		printf("make_uml_dir : malloc failed, errno = %d\n", errno);
+		printk(UM_KERN_ERR "make_uml_dir : malloc failed, "
+			"errno = %d\n", errno);
 		goto err;
 	}
 	strcpy(uml_dir, dir);
 
 	if ((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)) {
-	        printf("Failed to mkdir '%s': %s\n", uml_dir, strerror(errno));
+		printk(UM_KERN_ERR "Failed to mkdir '%s': %s\n",
+			uml_dir, strerror(errno));
 		err = -errno;
 		goto err_free;
 	}

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 2/7] um: Use non_fatal() in check_coredump_limit
  2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
  2017-04-28 10:21 ` [RFC PATCH 1/7] um: Use printk instead of printf in make_uml_dir Masami Hiramatsu
@ 2017-04-28 10:22 ` Masami Hiramatsu
  2017-04-28 10:23 ` [RFC PATCH 3/7] um: Make non_fatal non-static for other files Masami Hiramatsu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:22 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

Use non_fatal() instead of printf in check_coredump_limit().

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/um/os-Linux/start_up.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 22a358e..5052817 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -308,15 +308,17 @@ static void __init check_coredump_limit(void)
 		return;
 	}
 
-	printf("Core dump limits :\n\tsoft - ");
+	non_fatal("Core dump limits :\n\tsoft - ");
 	if (lim.rlim_cur == RLIM_INFINITY)
-		printf("NONE\n");
-	else printf("%lu\n", lim.rlim_cur);
+		non_fatal("NONE\n");
+	else
+		non_fatal("%lu\n", lim.rlim_cur);
 
-	printf("\thard - ");
+	non_fatal("\thard - ");
 	if (lim.rlim_max == RLIM_INFINITY)
-		printf("NONE\n");
-	else printf("%lu\n", lim.rlim_max);
+		non_fatal("NONE\n");
+	else
+		non_fatal("%lu\n", lim.rlim_max);
 }
 
 void __init os_early_checks(void)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 3/7] um: Make non_fatal non-static for other files
  2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
  2017-04-28 10:21 ` [RFC PATCH 1/7] um: Use printk instead of printf in make_uml_dir Masami Hiramatsu
  2017-04-28 10:22 ` [RFC PATCH 2/7] um: Use non_fatal() in check_coredump_limit Masami Hiramatsu
@ 2017-04-28 10:23 ` Masami Hiramatsu
  2017-04-28 10:24 ` [RFC PATCH 4/7] um: Use non_fatal() for non-fatal information/warning messages Masami Hiramatsu
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:23 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

Move non_fatal() to util.c and make it global so that
it can be used from other files.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/um/include/shared/os.h |    1 +
 arch/um/os-Linux/start_up.c |    9 ---------
 arch/um/os-Linux/util.c     |    9 +++++++++
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index de5d572..49185f4 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
@@ -242,6 +242,7 @@ extern void setup_hostinfo(char *buf, int len);
 extern void os_dump_core(void) __attribute__ ((noreturn));
 extern void um_early_printk(const char *s, unsigned int n);
 extern void os_fix_helper_signals(void);
+extern void non_fatal(const char *fmt, ...);
 
 /* time.c */
 extern void os_idle_sleep(unsigned long long nsecs);
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 5052817..f97cd36 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -81,15 +81,6 @@ static void fatal(char *fmt, ...)
 	exit(1);
 }
 
-static void non_fatal(char *fmt, ...)
-{
-	va_list list;
-
-	va_start(list, fmt);
-	vfprintf(stderr, fmt, list);
-	va_end(list);
-}
-
 static int start_ptraced_child(void)
 {
 	int pid, n, status;
diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c
index faee55e..8745f23 100644
--- a/arch/um/os-Linux/util.c
+++ b/arch/um/os-Linux/util.c
@@ -152,3 +152,12 @@ void um_early_printk(const char *s, unsigned int n)
 {
 	printf("%.*s", n, s);
 }
+
+void non_fatal(const char *fmt, ...)
+{
+	va_list list;
+
+	va_start(list, fmt);
+	vfprintf(stderr, fmt, list);
+	va_end(list);
+}

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 4/7] um: Use non_fatal() for non-fatal information/warning messages
  2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
                   ` (2 preceding siblings ...)
  2017-04-28 10:23 ` [RFC PATCH 3/7] um: Make non_fatal non-static for other files Masami Hiramatsu
@ 2017-04-28 10:24 ` Masami Hiramatsu
  2017-04-28 10:25 ` [RFC PATCH 5/7] um: Print out fatal error in stderr Masami Hiramatsu
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:24 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

Use non_fatal() for non-fatal information or warning
messages instead of printf(). This also changes these
messages output to stderr.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/um/kernel/um_arch.c |   14 ++++++++------
 arch/um/kernel/umid.c    |    4 ++--
 arch/um/os-Linux/main.c  |    6 +++---
 arch/um/os-Linux/mem.c   |   24 ++++++++++++------------
 arch/um/os-Linux/umid.c  |    8 ++++----
 5 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 64a1fd0..b3b28db 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -126,6 +126,7 @@ static const char *usage_string =
 
 static int __init uml_version_setup(char *line, int *add)
 {
+	/* Version is shown when user intended to see it, not an error */
 	printf("%s\n", init_utsname()->release);
 	exit(0);
 
@@ -154,8 +155,8 @@ __uml_setup("root=", uml_root_setup,
 
 static int __init no_skas_debug_setup(char *line, int *add)
 {
-	printf("'debug' is not necessary to gdb UML in skas mode - run \n");
-	printf("'gdb linux'\n");
+	non_fatal("'debug' is not necessary to gdb UML in skas mode - run\n");
+	non_fatal("'gdb linux'\n");
 
 	return 0;
 }
@@ -169,6 +170,7 @@ static int __init Usage(char *line, int *add)
 {
 	const char **p;
 
+	/* Usage is usually shown when user intended to see it, not an error */
 	printf(usage_string, init_utsname()->release);
 	p = &__uml_help_start;
 	while (p < &__uml_help_end) {
@@ -289,8 +291,8 @@ int __init linux_main(int argc, char **argv)
 
 	diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
 	if (diff > 1024 * 1024) {
-		printf("Adding %ld bytes to physical memory to account for "
-		       "exec-shield gap\n", diff);
+		non_fatal("Adding %ld bytes to physical memory to account for "
+			  "exec-shield gap\n", diff);
 		physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
 	}
 
@@ -330,8 +332,8 @@ int __init linux_main(int argc, char **argv)
 	end_vm = start_vm + virtmem_size;
 
 	if (virtmem_size < physmem_size)
-		printf("Kernel virtual memory size shrunk to %lu bytes\n",
-		       virtmem_size);
+		non_fatal("Kernel virtual memory size shrunk to %lu bytes\n",
+			  virtmem_size);
 
 	os_flush_stdout();
 
diff --git a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c
index f6cc3bd..0b5bc3f 100644
--- a/arch/um/kernel/umid.c
+++ b/arch/um/kernel/umid.c
@@ -16,14 +16,14 @@ static int __init set_umid_arg(char *name, int *add)
 	int err;
 
 	if (umid_inited) {
-		printf("umid already set\n");
+		non_fatal("umid already set\n");
 		return 0;
 	}
 
 	*add = 0;
 	err = set_umid(name);
 	if (err == -EEXIST)
-		printf("umid '%s' already in use\n", name);
+		non_fatal("umid '%s' already in use\n", name);
 	else if (!err)
 		umid_inited = 1;
 
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index 9d499de..659fee3 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -175,7 +175,7 @@ int __init main(int argc, char **argv, char **envp)
 	/* disable SIGIO for the fds and set SIGIO to be ignored */
 	err = deactivate_all_fds();
 	if (err)
-		printf("deactivate_all_fds failed, errno = %d\n", -err);
+		non_fatal("deactivate_all_fds failed, errno = %d\n", -err);
 
 	/*
 	 * Let any pending signals fire now.  This ensures
@@ -186,12 +186,12 @@ int __init main(int argc, char **argv, char **envp)
 
 	/* Reboot */
 	if (ret) {
-		printf("\n");
+		non_fatal("\n");
 		execvp(new_argv[0], new_argv);
 		perror("Failed to exec kernel");
 		ret = 1;
 	}
-	printf("\n");
+	non_fatal("\n");
 	return uml_exitcode;
 }
 
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 8b17676..e4850c1 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -25,13 +25,13 @@ static int __init check_tmpfs(const char *dir)
 {
 	struct statfs st;
 
-	printf("Checking if %s is on tmpfs...", dir);
+	non_fatal("Checking if %s is on tmpfs...", dir);
 	if (statfs(dir, &st) < 0) {
-		printf("%s\n", strerror(errno));
+		non_fatal("%s\n", strerror(errno));
 	} else if (st.f_type != TMPFS_MAGIC) {
-		printf("no\n");
+		non_fatal("no\n");
 	} else {
-		printf("OK\n");
+		non_fatal("OK\n");
 		return 0;
 	}
 	return -1;
@@ -61,18 +61,18 @@ static char * __init choose_tempdir(void)
 	int i;
 	const char *dir;
 
-	printf("Checking environment variables for a tempdir...");
+	non_fatal("Checking environment variables for a tempdir...");
 	for (i = 0; vars[i]; i++) {
 		dir = getenv(vars[i]);
 		if ((dir != NULL) && (*dir != '\0')) {
-			printf("%s\n", dir);
+			non_fatal("%s\n", dir);
 			if (check_tmpfs(dir) >= 0)
 				goto done;
 			else
 				goto warn;
 		}
 	}
-	printf("none found\n");
+	non_fatal("none found\n");
 
 	for (i = 0; tmpfs_dirs[i]; i++) {
 		dir = tmpfs_dirs[i];
@@ -82,7 +82,7 @@ static char * __init choose_tempdir(void)
 
 	dir = fallback_dir;
 warn:
-	printf("Warning: tempdir %s is not on tmpfs\n", dir);
+	non_fatal("Warning: tempdir %s is not on tmpfs\n", dir);
 done:
 	/* Make a copy since getenv results may not remain valid forever. */
 	return strdup(dir);
@@ -194,16 +194,16 @@ void __init check_tmpexec(void)
 
 	addr = mmap(NULL, UM_KERN_PAGE_SIZE,
 		    PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
-	printf("Checking PROT_EXEC mmap in %s...", tempdir);
+	non_fatal("Checking PROT_EXEC mmap in %s...", tempdir);
 	if (addr == MAP_FAILED) {
 		err = errno;
-		printf("%s\n", strerror(err));
+		non_fatal("%s\n", strerror(err));
 		close(fd);
 		if (err == EPERM)
-			printf("%s must be not mounted noexec\n", tempdir);
+			non_fatal("%s must be not mounted noexec\n", tempdir);
 		exit(1);
 	}
-	printf("OK\n");
+	non_fatal("OK\n");
 	munmap(addr, UM_KERN_PAGE_SIZE);
 
 	close(fd);
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index b94a416..8974eb5 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -353,7 +353,7 @@ char *get_umid(void)
 static int __init set_uml_dir(char *name, int *add)
 {
 	if (*name == '\0') {
-		printf("uml_dir can't be an empty string\n");
+		non_fatal("uml_dir can't be an empty string\n");
 		return 0;
 	}
 
@@ -364,7 +364,7 @@ static int __init set_uml_dir(char *name, int *add)
 
 	uml_dir = malloc(strlen(name) + 2);
 	if (uml_dir == NULL) {
-		printf("Failed to malloc uml_dir - error = %d\n", errno);
+		non_fatal("Failed to malloc uml_dir - error = %d\n", errno);
 
 		/*
 		 * Return 0 here because do_initcalls doesn't look at
@@ -389,8 +389,8 @@ static void remove_umid_dir(void)
 	sprintf(dir, "%s%s", uml_dir, umid);
 	err = remove_files_and_dir(dir);
 	if (err)
-		printf("remove_umid_dir - remove_files_and_dir failed with "
-		       "err = %d\n", err);
+		non_fatal("remove_umid_dir - remove_files_and_dir failed with "
+			  "err = %d\n", err);
 }
 
 __uml_exitcall(remove_umid_dir);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 5/7] um: Print out fatal error in stderr
  2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
                   ` (3 preceding siblings ...)
  2017-04-28 10:24 ` [RFC PATCH 4/7] um: Use non_fatal() for non-fatal information/warning messages Masami Hiramatsu
@ 2017-04-28 10:25 ` Masami Hiramatsu
  2017-04-29 11:26   ` Masami Hiramatsu
  2017-04-28 10:26 ` [RFC PATCH 6/7] um: Suppress non-fatal messages when quiet Masami Hiramatsu
  2017-04-28 10:27 ` [RFC PATCH 7/7] um: console: Ignore console= option Masami Hiramatsu
  6 siblings, 1 reply; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:25 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

Print out fatal error in stderr as same as fatal() does.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/um/kernel/physmem.c |    8 ++++----
 arch/um/kernel/um_arch.c |    2 +-
 arch/um/os-Linux/main.c  |    4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index 4c9861b..7f95329 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -89,8 +89,8 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
 	offset = uml_reserved - uml_physmem;
 	map_size = len - offset;
 	if(map_size <= 0) {
-		printf("Too few physical memory! Needed=%d, given=%d\n",
-		       offset, len);
+		fprintf(stderr, "Too few physical memory! Needed=%d, "
+			"given=%d\n", offset, len);
 		exit(1);
 	}
 
@@ -99,8 +99,8 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
 	err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
 			    map_size, 1, 1, 1);
 	if (err < 0) {
-		printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
-		       "failed - errno = %d\n", map_size,
+		fprintf(stderr, "setup_physmem - mapping %ld bytes of memory "
+			"at 0x%p failed - errno = %d\n", map_size,
 		       (void *) uml_reserved, err);
 		exit(1);
 	}
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index b3b28db..01817d6 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -34,7 +34,7 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0 };
 static void __init add_arg(char *arg)
 {
 	if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
-		printf("add_arg: Too many command line arguments!\n");
+		fprintf(stderr, "add_arg: Too many command line arguments!\n");
 		exit(1);
 	}
 	if (strlen(command_line) > 0)
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index 659fee3..09b44f1 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -74,8 +74,8 @@ static void install_fatal_handler(int sig)
 	action.sa_restorer = NULL;
 	action.sa_handler = last_ditch_exit;
 	if (sigaction(sig, &action, NULL) < 0) {
-		printf("failed to install handler for signal %d - errno = %d\n",
-		       sig, errno);
+		fprintf(stderr, "failed to install handler for signal %d "
+			"- errno = %d\n", sig, errno);
 		exit(1);
 	}
 }

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 6/7] um: Suppress non-fatal messages when quiet
  2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
                   ` (4 preceding siblings ...)
  2017-04-28 10:25 ` [RFC PATCH 5/7] um: Print out fatal error in stderr Masami Hiramatsu
@ 2017-04-28 10:26 ` Masami Hiramatsu
  2017-04-28 10:27 ` [RFC PATCH 7/7] um: console: Ignore console= option Masami Hiramatsu
  6 siblings, 0 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:26 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

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

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 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);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 7/7] um: console: Ignore console= option
  2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
                   ` (5 preceding siblings ...)
  2017-04-28 10:26 ` [RFC PATCH 6/7] um: Suppress non-fatal messages when quiet Masami Hiramatsu
@ 2017-04-28 10:27 ` Masami Hiramatsu
  6 siblings, 0 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-28 10:27 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger
  Cc: Masami Hiramatsu, user-mode-linux-devel, linux-kernel

Ignore linux kernel's console= option at uml's console
option handler. Since uml's con= option is only for
setting up new console, and Linux kernel's console=
option specify to which console kernel output its
message, we can use both option for different purpose.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/um/drivers/stdio_console.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 7b361f3..43b12a5 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -192,6 +192,9 @@ __uml_exitcall(console_exit);
 
 static int console_chan_setup(char *str)
 {
+	if (!strncmp(str, "sole=", 5))	/* This may passed to tty */
+		return 0;
+
 	line_setup(vt_conf, MAX_TTYS, &def_conf, str, "console");
 	return 1;
 }

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH 5/7] um: Print out fatal error in stderr
  2017-04-28 10:25 ` [RFC PATCH 5/7] um: Print out fatal error in stderr Masami Hiramatsu
@ 2017-04-29 11:26   ` Masami Hiramatsu
  0 siblings, 0 replies; 9+ messages in thread
From: Masami Hiramatsu @ 2017-04-29 11:26 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Jeff Dike, Richard Weinberger, user-mode-linux-devel, linux-kernel

On Fri, 28 Apr 2017 19:25:39 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Print out fatal error in stderr as same as fatal() does.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  arch/um/kernel/physmem.c |    8 ++++----
>  arch/um/kernel/um_arch.c |    2 +-
>  arch/um/os-Linux/main.c  |    4 ++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
> index 4c9861b..7f95329 100644
> --- a/arch/um/kernel/physmem.c
> +++ b/arch/um/kernel/physmem.c
> @@ -89,8 +89,8 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
>  	offset = uml_reserved - uml_physmem;
>  	map_size = len - offset;
>  	if(map_size <= 0) {
> -		printf("Too few physical memory! Needed=%d, given=%d\n",
> -		       offset, len);
> +		fprintf(stderr, "Too few physical memory! Needed=%d, "
> +			"given=%d\n", offset, len);

Oops, I've missed to include something for using fprintf here.
Anyway, I think we need something like um_fatal() for handling
these errors.
I'll resend v2.

Thanks,

>  		exit(1);
>  	}
>  
> @@ -99,8 +99,8 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
>  	err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
>  			    map_size, 1, 1, 1);
>  	if (err < 0) {
> -		printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
> -		       "failed - errno = %d\n", map_size,
> +		fprintf(stderr, "setup_physmem - mapping %ld bytes of memory "
> +			"at 0x%p failed - errno = %d\n", map_size,
>  		       (void *) uml_reserved, err);
>  		exit(1);
>  	}
> diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
> index b3b28db..01817d6 100644
> --- a/arch/um/kernel/um_arch.c
> +++ b/arch/um/kernel/um_arch.c
> @@ -34,7 +34,7 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0 };
>  static void __init add_arg(char *arg)
>  {
>  	if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
> -		printf("add_arg: Too many command line arguments!\n");
> +		fprintf(stderr, "add_arg: Too many command line arguments!\n");
>  		exit(1);
>  	}
>  	if (strlen(command_line) > 0)
> diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
> index 659fee3..09b44f1 100644
> --- a/arch/um/os-Linux/main.c
> +++ b/arch/um/os-Linux/main.c
> @@ -74,8 +74,8 @@ static void install_fatal_handler(int sig)
>  	action.sa_restorer = NULL;
>  	action.sa_handler = last_ditch_exit;
>  	if (sigaction(sig, &action, NULL) < 0) {
> -		printf("failed to install handler for signal %d - errno = %d\n",
> -		       sig, errno);
> +		fprintf(stderr, "failed to install handler for signal %d "
> +			"- errno = %d\n", sig, errno);
>  		exit(1);
>  	}
>  }
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-04-29 11:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-28 10:19 [RFC PATCH 0/7] um: Fix printf usage and support quiet option Masami Hiramatsu
2017-04-28 10:21 ` [RFC PATCH 1/7] um: Use printk instead of printf in make_uml_dir Masami Hiramatsu
2017-04-28 10:22 ` [RFC PATCH 2/7] um: Use non_fatal() in check_coredump_limit Masami Hiramatsu
2017-04-28 10:23 ` [RFC PATCH 3/7] um: Make non_fatal non-static for other files Masami Hiramatsu
2017-04-28 10:24 ` [RFC PATCH 4/7] um: Use non_fatal() for non-fatal information/warning messages Masami Hiramatsu
2017-04-28 10:25 ` [RFC PATCH 5/7] um: Print out fatal error in stderr Masami Hiramatsu
2017-04-29 11:26   ` Masami Hiramatsu
2017-04-28 10:26 ` [RFC PATCH 6/7] um: Suppress non-fatal messages when quiet Masami Hiramatsu
2017-04-28 10:27 ` [RFC PATCH 7/7] um: console: Ignore console= option Masami Hiramatsu

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).