Retain a value of -1 for messages with an unknown message level and pass
this to cont_add() and log_store(). This way, we can better distinguish
continuation records from non-continuation records and keep the correct
level in more cases than before. (Though, most of this level tracking
will be done in follow-up patches.)

Signed-off-by: Jan H. Schönherr <schn...@cs.tu-berlin.de>
---
v2:
- rephrased commit message to better reflect what the patch is doing
---
 kernel/printk.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 075fbd4..52ccf93 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -309,6 +309,10 @@ static void log_store(int facility, int level,
        struct log *msg;
        u32 size, pad_len;
 
+       /* store something meaningful, when no loglevel was given */
+       if (level == -1)
+               level = default_message_loglevel;
+
        /* number of '\0' padding bytes to next message */
        size = sizeof(struct log) + text_len + dict_len;
        pad_len = (-size) & (LOG_ALIGN - 1);
@@ -375,7 +379,7 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const 
struct iovec *iv,
 {
        char *buf, *line;
        int i;
-       int level = default_message_loglevel;
+       int level = -1;
        int facility = 1;       /* LOG_USER */
        size_t len = iov_length(iv, count);
        ssize_t ret = len;
@@ -1453,11 +1457,12 @@ static bool cont_add(int facility, int level, enum 
log_flags flags,
                cont_flush();
                if (cont.len)
                        return false;
+               level = cont.level;
        }
 
        if (!cont.len) {
                cont.facility = facility;
-               cont.level = level;
+               cont.level = level == -1 ? default_message_loglevel : level;
                cont.owner = current;
                cont.ts_nsec = local_clock();
                cont.flags = 0;
@@ -1567,22 +1572,23 @@ asmlinkage int vprintk_emit(int facility, int level,
 
                if (kern_level) {
                        const char *end_of_header = printk_skip_level(text);
-                       switch (kern_level) {
-                       case '0' ... '7':
-                               if (level == -1)
+                       if (level == -1) {
+                               switch (kern_level) {
+                               case '0' ... '7':
                                        level = kern_level - '0';
-                       case 'd':       /* KERN_DEFAULT */
-                               lflags |= LOG_PREFIX;
-                       case 'c':       /* KERN_CONT */
-                               break;
+                                       break;
+                               case 'd':       /* KERN_DEFAULT */
+                                       level = default_message_loglevel;
+                                       break;
+                               }
                        }
                        text_len -= end_of_header - text;
                        text = (char *)end_of_header;
                }
        }
 
-       if (level == -1)
-               level = default_message_loglevel;
+       if (level != -1)
+               lflags |= LOG_PREFIX;
 
        if (dict)
                lflags |= LOG_PREFIX|LOG_NEWLINE;
-- 
1.8.0.1.20.g7c65b2e.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to