Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Oct 2021 01:15:06 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e6e348e49c0a - stable/13 - Unify console output.
Message-ID:  <202110040115.1941F6O1007850@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=e6e348e49c0af43b2aa28db7084912015ccb4172

commit e6e348e49c0af43b2aa28db7084912015ccb4172
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2021-09-04 03:13:42 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2021-10-04 01:15:03 +0000

    Unify console output.
    
    Without this change when virtual console enabled depending on buffer
    presence and state different parts of output go to different consoles.
    
    MFC after:      1 month
    
    (cherry picked from commit a264594d4ff19fd13f7c39a56c8d131296db480d)
---
 sys/kern/subr_prf.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index bbe95653919f..1106587ebbe7 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -118,6 +118,7 @@ extern	int log_open;
 
 static void  msglogchar(int c, int pri);
 static void  msglogstr(char *str, int pri, int filter_cr);
+static void  prf_putbuf(char *bufr, int flags, int pri);
 static void  putchar(int ch, void *arg);
 static char *ksprintn(char *nbuf, uintmax_t num, int base, int *len, int upper);
 static void  snprintf_func(int ch, void *arg);
@@ -296,13 +297,8 @@ _vprintf(int level, int flags, const char *fmt, va_list ap)
 
 #ifdef PRINTF_BUFR_SIZE
 	/* Write any buffered console/log output: */
-	if (*pca.p_bufr != '\0') {
-		if (pca.flags & TOLOG)
-			msglogstr(pca.p_bufr, level, /*filter_cr*/1);
-
-		if (pca.flags & TOCONS)
-			cnputs(pca.p_bufr);
-	}
+	if (*pca.p_bufr != '\0')
+		prf_putbuf(pca.p_bufr, flags, level);
 #endif
 
 	TSEXIT();
@@ -423,6 +419,22 @@ vprintf(const char *fmt, va_list ap)
 	return (retval);
 }
 
+static void
+prf_putchar(int c, int flags, int pri)
+{
+
+	if (flags & TOLOG)
+		msglogchar(c, pri);
+
+	if (flags & TOCONS) {
+		if ((!KERNEL_PANICKED()) && (constty != NULL))
+			msgbuf_addchar(&consmsgbuf, c);
+
+		if ((constty == NULL) || always_console_output)
+			cnputc(c);
+	}
+}
+
 static void
 prf_putbuf(char *bufr, int flags, int pri)
 {
@@ -435,7 +447,7 @@ prf_putbuf(char *bufr, int flags, int pri)
 			msgbuf_addstr(&consmsgbuf, -1,
 			    bufr, /*filter_cr*/ 0);
 
-		if ((constty == NULL) ||(always_console_output))
+		if ((constty == NULL) || always_console_output)
 			cnputs(bufr);
 	}
 }
@@ -445,12 +457,7 @@ putbuf(int c, struct putchar_arg *ap)
 {
 	/* Check if no console output buffer was provided. */
 	if (ap->p_bufr == NULL) {
-		/* Output direct to the console. */
-		if (ap->flags & TOCONS)
-			cnputc(c);
-
-		if (ap->flags & TOLOG)
-			msglogchar(c, ap->pri);
+		prf_putchar(c, ap->flags, ap->pri);
 	} else {
 		/* Buffer the character: */
 		*ap->p_next++ = c;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110040115.1941F6O1007850>