diff options
author | Kay Sievers <kay@vrfy.org> | 2012-07-10 13:00:57 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-07-10 13:00:57 +0200 |
commit | 45aee3b0cc20a4314e7db200a87d188493fd65c6 (patch) | |
tree | f7520ed72f846cf12dc6439651f9a39eb021d83e | |
parent | 4912b7f6508109e800f5a84ad61e2a51b3cfc8a7 (diff) | |
download | patches-45aee3b0cc20a4314e7db200a87d188493fd65c6.tar.gz |
add config-no-printk.patch
-rw-r--r-- | config-no-printk.patch | 52 | ||||
-rw-r--r-- | kmsg-export-flags.patch | 78 | ||||
-rw-r--r-- | series | 2 |
3 files changed, 123 insertions, 9 deletions
diff --git a/config-no-printk.patch b/config-no-printk.patch new file mode 100644 index 0000000..d3fc5b8 --- /dev/null +++ b/config-no-printk.patch @@ -0,0 +1,52 @@ +--- + kernel/printk.c | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +--- a/kernel/printk.c ++++ b/kernel/printk.c +@@ -216,21 +216,21 @@ struct log { + */ + static DEFINE_RAW_SPINLOCK(logbuf_lock); + +-/* the next printk record to read by syslog(READ) or /proc/kmsg */ +-static u64 syslog_seq; +-static u32 syslog_idx; +-static enum log_flags syslog_prev; +-static size_t syslog_partial; +- ++#ifdef CONFIG_PRINTK + /* index and sequence number of the first record stored in the buffer */ + static u64 log_first_seq; + static u32 log_first_idx; + + /* index and sequence number of the next record to store in the buffer */ + static u64 log_next_seq; +-#ifdef CONFIG_PRINTK + static u32 log_next_idx; + ++/* the next printk record to read by syslog(READ) or /proc/kmsg */ ++static u64 syslog_seq; ++static u32 syslog_idx; ++static enum log_flags syslog_prev; ++static size_t syslog_partial; ++ + /* the next printk record to read after the last 'clear' command */ + static u64 clear_seq; + static u32 clear_idx; +@@ -1631,9 +1631,15 @@ asmlinkage int printk(const char *fmt, . + } + EXPORT_SYMBOL(printk); + +-#else ++#else /* CONFIG_PRINTK */ + + #define LOG_LINE_MAX 0 ++static u64 syslog_seq; ++static u32 syslog_idx; ++static enum log_flags syslog_prev; ++static u64 log_first_seq; ++static u32 log_first_idx; ++static u64 log_next_seq; + static struct cont { + size_t len; + size_t cons; diff --git a/kmsg-export-flags.patch b/kmsg-export-flags.patch index 67cdbd5..f520a55 100644 --- a/kmsg-export-flags.patch +++ b/kmsg-export-flags.patch @@ -1,20 +1,82 @@ --- - kernel/printk.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) + kernel/printk.c | 42 +++++++++++++++++++++++++++--------------- + 1 file changed, 27 insertions(+), 15 deletions(-) --- a/kernel/printk.c +++ b/kernel/printk.c -@@ -462,8 +462,11 @@ static ssize_t devkmsg_read(struct file +@@ -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 */ + struct devkmsg_user { + u64 seq; + u32 idx; ++ enum log_flags prev; + struct mutex lock; + char buf[8192]; + }; +@@ -424,6 +442,7 @@ static ssize_t devkmsg_read(struct file + struct devkmsg_user *user = file->private_data; + struct log *msg; + u64 ts_usec; ++ char flag = '-'; + size_t i; + size_t len; + ssize_t ret; +@@ -462,8 +481,12 @@ 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); -+ len = sprintf(user->buf, "%u,%llu,%llu,%s%s%s;", -+ (msg->facility << 3) | msg->level, user->seq, ts_usec, -+ msg->flags & LOG_PREFIX ? "p" : "", -+ msg->flags & LOG_NEWLINE ? "n" : "", -+ msg->flags & LOG_CONT ? "c" : ""); ++ 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); /* 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; @@ -1,2 +1,2 @@ #test-modules.patch -kmsg-export-flags.patch +config-no-printk.patch |