blob: 28c09d4d76df59f02d3d57ea12f926ecb64e4ab3 [file] [log] [blame]
---
kernel/printk.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -231,6 +231,11 @@ static u32 log_first_idx;
static u64 log_next_seq;
static u32 log_next_idx;
+/* the next printk record to write to the console */
+static u64 console_seq;
+static u32 console_idx;
+static enum log_flags console_prev;
+
/* the next printk record to read after the last 'clear' command */
static u64 clear_seq;
static u32 clear_idx;
@@ -480,9 +485,9 @@ static ssize_t devkmsg_read(struct file
((user->prev & LOG_CONT) && !(msg->flags & LOG_PREFIX)))
cont = '+';
- len = sprintf(user->buf, "%u,%llu,%llu,%c;",
+ len = sprintf(user->buf, "%u,%llu,%llu,%c,XXX%u;",
(msg->facility << 3) | msg->level,
- user->seq, ts_usec, cont);
+ user->seq, ts_usec, cont, msg->flags);
user->prev = msg->flags;
/* escape non-printable characters */
@@ -1386,6 +1391,7 @@ static struct cont {
u64 ts_nsec; /* time of first print */
u8 level; /* log level of first message */
u8 facility; /* log level of first message */
+ enum log_flags flags; /* prefix, newline flags */
bool flushed:1; /* buffer sealed and committed */
} cont;
@@ -1404,6 +1410,7 @@ static void cont_flush(enum log_flags fl
*/
log_store(cont.facility, cont.level, flags | LOG_NOCONS,
cont.ts_nsec, NULL, 0, cont.buf, cont.len);
+ cont.flags = flags;
cont.flushed = true;
} else {
/*
@@ -1432,6 +1439,7 @@ static bool cont_add(int facility, int l
cont.level = level;
cont.owner = current;
cont.ts_nsec = local_clock();
+ cont.flags = 0;
cont.cons = 0;
cont.flushed = false;
}
@@ -1446,7 +1454,7 @@ static size_t cont_print_text(char *text
size_t textlen = 0;
size_t len;
- if (cont.cons == 0) {
+ if (cont.cons == 0 && (console_prev & LOG_NEWLINE)) {
textlen += print_time(cont.ts_nsec, text);
size -= textlen;
}
@@ -1461,7 +1469,8 @@ static size_t cont_print_text(char *text
}
if (cont.flushed) {
- text[textlen++] = '\n';
+ if (cont.flags & LOG_NEWLINE)
+ text[textlen++] = '\n';
/* got everything, release buffer */
cont.len = 0;
}
@@ -1559,7 +1568,7 @@ asmlinkage int vprintk_emit(int facility
* or another task also prints continuation lines.
*/
if (cont.len && (lflags & LOG_PREFIX || cont.owner != current))
- cont_flush(0);
+ cont_flush(LOG_NEWLINE);
/* buffer line if possible, otherwise store it right away */
if (!cont_add(facility, level, text, text_len))
@@ -1577,7 +1586,7 @@ asmlinkage int vprintk_emit(int facility
if (cont.len && cont.owner == current) {
if (!(lflags & LOG_PREFIX))
stored = cont_add(facility, level, text, text_len);
- cont_flush(0);
+ cont_flush(LOG_NEWLINE);
}
if (!stored)
@@ -1679,6 +1688,7 @@ static enum log_flags syslog_prev;
static u64 log_first_seq;
static u32 log_first_idx;
static u64 log_next_seq;
+static enum log_flags console_prev;
static struct cont {
size_t len;
size_t cons;
@@ -1962,11 +1972,6 @@ void wake_up_klogd(void)
this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
}
-/* the next printk record to write to the console */
-static u64 console_seq;
-static u32 console_idx;
-static enum log_flags console_prev;
-
/**
* console_unlock - unlock the console system
*
@@ -1998,7 +2003,8 @@ void console_unlock(void)
/* flush buffered message fragment immediately to console */
raw_spin_lock_irqsave(&logbuf_lock, flags);
- if (cont.len && (cont.cons < cont.len || cont.flushed)) {
+ if ((console_seq == log_next_seq && cont.len && (cont.cons < cont.len || cont.flushed)) ||
+ (cont.len && cont.cons)) {
size_t len;
len = cont_print_text(text, sizeof(text));
@@ -2046,6 +2052,7 @@ skip:
* will properly dump everything later.
*/
msg->flags &= ~LOG_NOCONS;
+ console_prev = msg->flags;
goto skip;
}