diff options
author | Alex Elder <elder@linaro.org> | 2014-07-17 12:41:05 -0500 |
---|---|---|
committer | Alex Elder <elder@linaro.org> | 2014-07-17 12:41:05 -0500 |
commit | e8e66f33277cb427ebd8ff36e1a0e84373aee0b5 (patch) | |
tree | eb843c892909bd8acb72e48d0adaf0daa6c0d0a3 | |
parent | 67f8e90ae41a63898a76a498404da5feefbcb0e8 (diff) |
printk: update previous message for LOG_PREFIX
If log_store() gets flags containing LOG_PREFIX, it indicates the
record getting stored should implicitly complete the previous log
record and start a new one.
We can also ensure the previous record is completed by keeping
track of the previously-logged record, and adding the LOG_NEWLINE
flag to it when log_store() sees a LOG_PREFIX flag.
Signed-off-by: Alex Elder <elder@linaro.org>
-rw-r--r-- | kernel/printk/printk.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e35d91a529f..6b72a777109 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -242,6 +242,9 @@ static size_t syslog_partial; static u64 log_first_seq; static u32 log_first_idx; +/* Pointer to the last record written into the log */ +static struct printk_log *log_last_msg; + /* index and sequence number of the next record to store in the buffer */ static u64 log_next_seq; static u32 log_next_idx; @@ -425,7 +428,13 @@ static int log_store(int facility, int level, log_next_idx = 0; } - /* fill message */ + /* + * If we're forcing a new log record, update the flags for + * the previous one to mark it complete. + */ + if (flags & LOG_PREFIX && log_last_msg) + log_last_msg->flags |= LOG_NEWLINE; + msg = (struct printk_log *)(log_buf + log_next_idx); memcpy(log_text(msg), text, text_len); msg->text_len = text_len; @@ -449,6 +458,9 @@ static int log_store(int facility, int level, log_next_idx += msg->len; log_next_seq++; + /* Save our previous record address for next time. */ + log_last_msg = msg; + return msg->text_len; } |