| diff --git a/kernel/printk.c b/kernel/printk.c |
| index 177fa49..0f4df08 100644 |
| --- a/kernel/printk.c |
| +++ b/kernel/printk.c |
| @@ -48,6 +48,40 @@ |
| #define CREATE_TRACE_POINTS |
| #include <trace/events/printk.h> |
| |
| +#define CATSTR_INIT(name) \ |
| + name##_len = 0 |
| + |
| +#define CATSTR_DEFINE(name, max) \ |
| + char name[max]; \ |
| + size_t name##_len = 0; \ |
| + size_t name##_max = max |
| + |
| +#define pr_cat(name, fmt, ...) \ |
| + _pr_cat(name, &name##_len, name##_max, fmt, ##__VA_ARGS__) |
| + |
| +bool _pr_cat(char *s, size_t *len, size_t size, const char *fmt, ...) |
| +{ |
| + va_list args; |
| + size_t r; |
| + |
| + if (*len == size) |
| + return false; |
| + |
| + va_start(args, fmt); |
| + r = vsnprintf(s + *len, size - *len, fmt, args); |
| + va_end(args); |
| + |
| + if (r + 1 >= size - *len) { |
| + s[*len] = '\0'; |
| + *len = size; |
| + return false; |
| + } |
| + |
| + *len += r; |
| + s[*len] = '\0'; |
| + return true; |
| +} |
| + |
| /* |
| * Architectures can override it: |
| */ |
| @@ -587,6 +621,11 @@ static int devkmsg_open(struct inode *inode, struct file *file) |
| struct devkmsg_user *user; |
| int err; |
| |
| + console_lock(); |
| + print_modules(); |
| + print_modules(); |
| + console_unlock(); |
| + |
| /* write-only does not need any file context */ |
| if ((file->f_flags & O_ACCMODE) == O_WRONLY) |
| return 0; |
| @@ -671,6 +710,59 @@ void __init setup_log_buf(int early) |
| unsigned long flags; |
| char *new_log_buf; |
| int free; |
| + int i; |
| + |
| + CATSTR_DEFINE(line, 64); |
| + CATSTR_DEFINE(line2, 16); |
| + CATSTR_DEFINE(line3, 12); |
| + |
| + pr_cat(line, "1:"); |
| + pr_cat(line, "-%i ", 12); |
| + pr_cat(line, "-%i ", 34); |
| + pr_cat(line, "-%i ", 56); |
| + pr_cat(line, "-%i ", 78); |
| + pr_info("%s-%i\n", line, 90); |
| + |
| + pr_cat(line2, "2:"); |
| + pr_cat(line2, "-%i ", 12); |
| + pr_cat(line2, "-%i ", 34); |
| + pr_cat(line2, "-%i ", 56); |
| + pr_cat(line2, "-%i ", 78); |
| + pr_info("%s-%i\n", line2, 90); |
| + |
| + pr_cat(line3, "3:"); |
| + pr_cat(line3, "-%i ", 12); |
| + pr_cat(line3, "-%i ", 34); |
| + pr_cat(line3, "-%i ", 56); |
| + pr_cat(line3, "-%i ", 78); |
| + pr_info("%s-%i\n", line3, 90); |
| + |
| + CATSTR_INIT(line3); |
| + pr_cat(line3, "4:"); |
| + pr_cat(line3, "+%i ", 12); |
| + pr_cat(line3, "+%i ", 34); |
| + pr_cat(line3, "+%i ", 56); |
| + pr_cat(line3, "+%i ", 78); |
| + pr_info("%s-%i\n", line3, 90); |
| + |
| + CATSTR_INIT(line3); |
| + pr_cat(line3, "5:"); |
| + pr_cat(line3, "~%i ", 12); |
| + pr_cat(line3, "~%i ", 34); |
| + pr_cat(line3, "~%i ", 56); |
| + pr_cat(line3, "~%i ", 78); |
| + pr_info("%s-%i\n", line3, 90); |
| + |
| + CATSTR_INIT(line); |
| + pr_cat(line, "foo:"); |
| + for (i = 0; i < 50; i++) { |
| + if (!pr_cat(line, " #%i", i)) { |
| + pr_info("%s #%i\n", line, i); |
| + CATSTR_INIT(line); |
| + pr_cat(line, "foo+:"); |
| + } |
| + } |
| + pr_info("%s\n", line); |
| |
| if (!new_log_buf_len) |
| return; |