summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-07-11 01:33:27 +0200
committerKay Sievers <kay@vrfy.org>2012-07-11 01:33:27 +0200
commit0c47c44ce0a7ecc0f247d7cbac1943454d48193c (patch)
tree40e5d8203c6361f6dfe2eb5a285f85c570e1bf2d
parentfc71b22f40cd99c9f7b9b867f74d8a82f68b96e3 (diff)
downloadpatches-0c47c44ce0a7ecc0f247d7cbac1943454d48193c.tar.gz
update flags patch
-rw-r--r--kmsg-export-flags.patch84
-rw-r--r--series1
2 files changed, 27 insertions, 58 deletions
diff --git a/kmsg-export-flags.patch b/kmsg-export-flags.patch
index f520a55..4989050 100644
--- a/kmsg-export-flags.patch
+++ b/kmsg-export-flags.patch
@@ -1,31 +1,10 @@
---
- kernel/printk.c | 42 +++++++++++++++++++++++++++---------------
- 1 file changed, 27 insertions(+), 15 deletions(-)
+ kernel/printk.c | 23 +++++++++++++++++++++--
+ 1 file changed, 21 insertions(+), 2 deletions(-)
--- a/kernel/printk.c
+++ b/kernel/printk.c
-@@ -356,10 +356,28 @@ static void log_store(int facility, int
- log_next_seq++;
- }
-
-+static bool msg_wants_prefix(const struct log *msg, enum log_flags prev)
-+{
-+ if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX))
-+ return false;
-+ if ((msg->flags & LOG_CONT) && (prev & LOG_CONT) &&
-+ !(prev & LOG_NEWLINE))
-+ return false;
-+ return true;
-+}
-+
-+static bool msg_wants_newline(const struct log *msg, enum log_flags prev)
-+{
-+ if ((msg->flags & LOG_CONT) && !(msg->flags & LOG_NEWLINE))
-+ return false;
-+ return true;
-+}
-+
- /* /dev/kmsg - userspace message inject/listen interface */
+@@ -360,6 +360,7 @@ static void log_store(int facility, int
struct devkmsg_user {
u64 seq;
u32 idx;
@@ -33,50 +12,39 @@
struct mutex lock;
char buf[8192];
};
-@@ -424,6 +442,7 @@ static ssize_t devkmsg_read(struct file
- struct devkmsg_user *user = file->private_data;
+@@ -425,6 +426,7 @@ static ssize_t devkmsg_read(struct file
struct log *msg;
u64 ts_usec;
-+ char flag = '-';
size_t i;
++ char cont = '-';
size_t len;
ssize_t ret;
-@@ -462,8 +481,12 @@ static ssize_t devkmsg_read(struct file
+
+@@ -462,8 +464,25 @@ static ssize_t devkmsg_read(struct file
msg = log_from_idx(user->idx);
ts_usec = msg->ts_nsec;
do_div(ts_usec, 1000);
- len = sprintf(user->buf, "%u,%llu,%llu;",
- (msg->facility << 3) | msg->level, user->seq, ts_usec);
-+ if (!msg_wants_prefix(msg, user->prev) ||
-+ !msg_wants_newline(msg, user->prev))
-+ flag = '+';
-+ len = sprintf(user->buf,
-+ "%u,%llu,%llu,%c;", (msg->facility << 3) | msg->level,
-+ user->seq, ts_usec, flag);
++
++ /*
++ * If we couldn't merge continuation line fragments during the print,
++ * export the stored flags to allow an optional external merge of the
++ * records. Merging the records isn't always neccessarily correct, like
++ * when we hit a race during printing. In most cases though, it produces
++ * better readable output. 'c' in the record flags mark the first
++ * fragment of a line, '+' the following.
++ */
++ if (msg->flags & LOG_CONT && !(user->prev & LOG_CONT))
++ cont = 'c';
++ else if ((msg->flags & LOG_CONT) ||
++ (user->prev & LOG_CONT) && !(msg->flags & LOG_PREFIX))
++ cont = '+';
++
++ len = sprintf(user->buf, "%u,%llu,%llu,%c;",
++ (msg->facility << 3) | msg->level,
++ user->seq, ts_usec, cont);
++ user->prev = msg->flags;
/* escape non-printable characters */
for (i = 0; i < msg->text_len; i++) {
-@@ -847,21 +870,10 @@ static size_t msg_print_text(const struc
- {
- const char *text = log_text(msg);
- size_t text_size = msg->text_len;
-- bool prefix = true;
-- bool newline = true;
-+ bool prefix = msg_wants_prefix(msg, prev);
-+ bool newline = msg_wants_newline(msg, prev);
- size_t len = 0;
-
-- if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX))
-- prefix = false;
--
-- if (msg->flags & LOG_CONT) {
-- if ((prev & LOG_CONT) && !(prev & LOG_NEWLINE))
-- prefix = false;
--
-- if (!(msg->flags & LOG_NEWLINE))
-- newline = false;
-- }
--
- do {
- const char *next = memchr(text, '\n', text_size);
- size_t text_len;
diff --git a/series b/series
index f521fa0..d6822ef 100644
--- a/series
+++ b/series
@@ -1,3 +1,4 @@
#test-modules.patch
#test-console-blocked.patch
kmsg-config-no-printk.patch
+kmsg-export-flags.patch