summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-07-08 02:56:24 +0200
committerKay Sievers <kay@vrfy.org>2012-07-08 13:52:24 +0200
commitbeed9a18aa1182fef9a8955a16735bb665e12e88 (patch)
tree67ac84acb9f9fb72f903447c17dd51bc1c6fb369
parentdb4603747af053e97fa1b6a0c20dac6574d23649 (diff)
downloadpatches-beed9a18aa1182fef9a8955a16735bb665e12e88.tar.gz
change order
-rw-r--r--kmsg-merge-cont.patch70
-rw-r--r--kmsg-syslog-1-byte-read.patch60
-rw-r--r--series2
3 files changed, 70 insertions, 62 deletions
diff --git a/kmsg-merge-cont.patch b/kmsg-merge-cont.patch
index 5503d31..1246a48 100644
--- a/kmsg-merge-cont.patch
+++ b/kmsg-merge-cont.patch
@@ -30,7 +30,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
};
struct log {
-@@ -838,8 +840,8 @@ static size_t print_prefix(const struct
+@@ -839,8 +841,8 @@ static size_t print_prefix(const struct
return len;
}
@@ -41,7 +41,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
{
const char *text = log_text(msg);
size_t text_size = msg->text_len;
-@@ -848,6 +850,8 @@ static size_t msg_print_text(const struc
+@@ -849,6 +851,8 @@ static size_t msg_print_text(const struc
do {
const char *next = memchr(text, '\n', text_size);
size_t text_len;
@@ -50,7 +50,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
if (next) {
text_len = next - text;
-@@ -857,19 +861,35 @@ static size_t msg_print_text(const struc
+@@ -858,19 +862,35 @@ static size_t msg_print_text(const struc
text_len = text_size;
}
@@ -90,7 +90,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
}
text = next;
-@@ -882,6 +902,7 @@ static int syslog_print(char __user *buf
+@@ -883,6 +903,7 @@ static int syslog_print(char __user *buf
{
char *text;
struct log *msg;
@@ -98,27 +98,31 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
int len = 0;
text = kmalloc(LOG_LINE_MAX, GFP_KERNEL);
-@@ -896,16 +917,18 @@ static int syslog_print(char __user *buf
- /* messages are gone, move to first one */
+@@ -899,6 +920,7 @@ static int syslog_print(char __user *buf
syslog_seq = log_first_seq;
syslog_idx = log_first_idx;
+ syslog_partial = 0;
+ prev = 0;
}
if (syslog_seq == log_next_seq) {
raw_spin_unlock_irq(&logbuf_lock);
- break;
- }
+@@ -907,13 +929,14 @@ static int syslog_print(char __user *buf
+
+ skip = syslog_partial;
msg = log_from_idx(syslog_idx);
- n = msg_print_text(msg, true, text, LOG_LINE_MAX);
+ n = msg_print_text(msg, prev, true, text, LOG_LINE_MAX);
- if (n <= size) {
+ if (n - syslog_partial <= size) {
+ /* message fits into buffer, move forward */
syslog_idx = log_next(syslog_idx);
syslog_seq++;
+ n -= syslog_partial;
+ syslog_partial = 0;
+ prev = msg->flags;
- } else
- n = 0;
- raw_spin_unlock_irq(&logbuf_lock);
-@@ -944,6 +967,7 @@ static int syslog_print_all(char __user
+ } else if (!len){
+ /* partial read(), remember position */
+ n = size;
+@@ -954,6 +977,7 @@ static int syslog_print_all(char __user
u64 next_seq;
u64 seq;
u32 idx;
@@ -126,7 +130,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
if (clear_seq < log_first_seq) {
/* messages are gone, move to first available one */
-@@ -957,10 +981,11 @@ static int syslog_print_all(char __user
+@@ -967,10 +991,11 @@ static int syslog_print_all(char __user
*/
seq = clear_seq;
idx = clear_idx;
@@ -139,7 +143,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
idx = log_next(idx);
seq++;
}
-@@ -968,10 +993,11 @@ static int syslog_print_all(char __user
+@@ -978,10 +1003,11 @@ static int syslog_print_all(char __user
/* move first record forward until length fits into the buffer */
seq = clear_seq;
idx = clear_idx;
@@ -152,7 +156,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
idx = log_next(idx);
seq++;
}
-@@ -980,17 +1006,19 @@ static int syslog_print_all(char __user
+@@ -990,17 +1016,19 @@ static int syslog_print_all(char __user
next_seq = log_next_seq;
len = 0;
@@ -173,7 +177,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
raw_spin_unlock_irq(&logbuf_lock);
if (copy_to_user(buf + len, text, textlen))
-@@ -1003,6 +1031,7 @@ static int syslog_print_all(char __user
+@@ -1013,6 +1041,7 @@ static int syslog_print_all(char __user
/* messages are gone, move to next one */
seq = log_first_seq;
idx = log_first_idx;
@@ -181,7 +185,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
}
}
}
-@@ -1116,18 +1145,18 @@ int do_syslog(int type, char __user *buf
+@@ -1127,18 +1156,18 @@ int do_syslog(int type, char __user *buf
*/
error = log_next_idx - syslog_idx;
} else {
@@ -203,9 +207,9 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
seq++;
+ prev = msg->flags;
}
+ error -= syslog_partial;
}
- raw_spin_unlock_irq(&logbuf_lock);
-@@ -1396,10 +1425,9 @@ asmlinkage int vprintk_emit(int facility
+@@ -1408,10 +1437,9 @@ asmlinkage int vprintk_emit(int facility
static char textbuf[LOG_LINE_MAX];
char *text = textbuf;
size_t text_len;
@@ -217,7 +221,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
int printed_len = 0;
boot_delay_msec();
-@@ -1438,7 +1466,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -1450,7 +1478,7 @@ asmlinkage int vprintk_emit(int facility
recursion_bug = 0;
printed_len += strlen(recursion_msg);
/* emit KERN_CRIT message */
@@ -226,7 +230,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
NULL, 0, recursion_msg, printed_len);
}
-@@ -1451,7 +1479,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -1463,7 +1491,7 @@ asmlinkage int vprintk_emit(int facility
/* mark and strip a trailing newline */
if (text_len && text[text_len-1] == '\n') {
text_len--;
@@ -235,7 +239,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
}
/* strip syslog prefix and extract log level or control flags */
-@@ -1461,7 +1489,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -1473,7 +1501,7 @@ asmlinkage int vprintk_emit(int facility
if (level == -1)
level = text[1] - '0';
case 'd': /* KERN_DEFAULT */
@@ -244,7 +248,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
case 'c': /* KERN_CONT */
text += 3;
text_len -= 3;
-@@ -1471,22 +1499,20 @@ asmlinkage int vprintk_emit(int facility
+@@ -1483,22 +1511,20 @@ asmlinkage int vprintk_emit(int facility
if (level == -1)
level = default_message_loglevel;
@@ -272,7 +276,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
dict, dictlen, text, text_len);
} else {
bool stored = false;
-@@ -1498,13 +1524,13 @@ asmlinkage int vprintk_emit(int facility
+@@ -1510,13 +1536,13 @@ asmlinkage int vprintk_emit(int facility
* flush it out and store this line separately.
*/
if (cont.len && cont.owner == current) {
@@ -288,7 +292,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
dict, dictlen, text, text_len);
}
printed_len += text_len;
-@@ -1603,8 +1629,8 @@ static struct cont {
+@@ -1615,8 +1641,8 @@ static struct cont {
static struct log *log_from_idx(u32 idx) { return NULL; }
static u32 log_next(u32 idx) { return 0; }
static void call_console_drivers(int level, const char *text, size_t len) {}
@@ -299,7 +303,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
static size_t cont_print_text(char *text, size_t size) { return 0; }
#endif /* CONFIG_PRINTK */
-@@ -1901,6 +1927,7 @@ void console_unlock(void)
+@@ -1913,6 +1939,7 @@ void console_unlock(void)
static u64 seen_seq;
unsigned long flags;
bool wake_klogd = false;
@@ -307,7 +311,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
bool retry;
if (console_suspended) {
-@@ -1940,6 +1967,7 @@ again:
+@@ -1952,6 +1979,7 @@ again:
/* messages are gone, move to first one */
console_seq = log_first_seq;
console_idx = log_first_idx;
@@ -315,7 +319,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
}
skip:
if (console_seq == log_next_seq)
-@@ -1963,10 +1991,11 @@ skip:
+@@ -1975,10 +2003,11 @@ skip:
}
level = msg->level;
@@ -328,7 +332,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
raw_spin_unlock(&logbuf_lock);
stop_critical_timings(); /* don't trace print latency */
-@@ -2522,8 +2551,7 @@ bool kmsg_dump_get_line(struct kmsg_dump
+@@ -2534,8 +2563,7 @@ bool kmsg_dump_get_line(struct kmsg_dump
}
msg = log_from_idx(dumper->cur_idx);
@@ -338,7 +342,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
dumper->cur_idx = log_next(dumper->cur_idx);
dumper->cur_seq++;
-@@ -2563,6 +2591,7 @@ bool kmsg_dump_get_buffer(struct kmsg_du
+@@ -2575,6 +2603,7 @@ bool kmsg_dump_get_buffer(struct kmsg_du
u32 idx;
u64 next_seq;
u32 next_idx;
@@ -346,7 +350,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
size_t l = 0;
bool ret = false;
-@@ -2585,23 +2614,27 @@ bool kmsg_dump_get_buffer(struct kmsg_du
+@@ -2597,23 +2626,27 @@ bool kmsg_dump_get_buffer(struct kmsg_du
/* calculate length of entire buffer */
seq = dumper->cur_seq;
idx = dumper->cur_idx;
@@ -376,7 +380,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
}
/* last message in next interation */
-@@ -2609,14 +2642,16 @@ bool kmsg_dump_get_buffer(struct kmsg_du
+@@ -2621,14 +2654,16 @@ bool kmsg_dump_get_buffer(struct kmsg_du
next_idx = idx;
l = 0;
diff --git a/kmsg-syslog-1-byte-read.patch b/kmsg-syslog-1-byte-read.patch
index d653e25..1cdde05 100644
--- a/kmsg-syslog-1-byte-read.patch
+++ b/kmsg-syslog-1-byte-read.patch
@@ -1,10 +1,10 @@
---
- kernel/printk.c | 35 +++++++++++++++++++++++------------
- 1 file changed, 23 insertions(+), 12 deletions(-)
+ kernel/printk.c | 28 ++++++++++++++++++++--------
+ 1 file changed, 20 insertions(+), 8 deletions(-)
--- a/kernel/printk.c
+++ b/kernel/printk.c
-@@ -219,6 +219,7 @@ static DEFINE_RAW_SPINLOCK(logbuf_lock);
+@@ -217,6 +217,7 @@ 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;
@@ -12,7 +12,7 @@
/* index and sequence number of the first record stored in the buffer */
static u64 log_first_seq;
-@@ -911,42 +912,51 @@ static int syslog_print(char __user *buf
+@@ -890,22 +891,33 @@ static int syslog_print(char __user *buf
while (size > 0) {
size_t n;
@@ -24,7 +24,6 @@
syslog_seq = log_first_seq;
syslog_idx = log_first_idx;
+ syslog_partial = 0;
- prev = 0;
}
if (syslog_seq == log_next_seq) {
raw_spin_unlock_irq(&logbuf_lock);
@@ -33,7 +32,7 @@
+
+ skip = syslog_partial;
msg = log_from_idx(syslog_idx);
- n = msg_print_text(msg, prev, true, text, LOG_LINE_MAX);
+ n = msg_print_text(msg, true, text, LOG_LINE_MAX);
- if (n <= size) {
+ if (n - syslog_partial <= size) {
+ /* message fits into buffer, move forward */
@@ -41,42 +40,37 @@
syslog_seq++;
+ n -= syslog_partial;
+ syslog_partial = 0;
- prev = msg->flags;
-- } else
-- n = 0;
-+ } else {
++ } else if (!len){
+ /* partial read(), remember position */
+ n = size;
+ syslog_partial += n;
-+ }
+ } else
+ n = 0;
raw_spin_unlock_irq(&logbuf_lock);
-
-- if (!n)
-+ if (copy_to_user(buf, text + skip, n)) {
-+ raw_spin_lock_irq(&logbuf_lock);
-+ if (syslog_partial)
-+ syslog_partial -= n;
-+ raw_spin_unlock_irq(&logbuf_lock);
-+ if (!len)
-+ len = -EFAULT;
+@@ -913,17 +925,15 @@ static int syslog_print(char __user *buf
+ if (!n)
break;
-+ }
- len += n;
- size -= n;
- buf += n;
+- len += n;
+- size -= n;
+- buf += n;
- n = copy_to_user(buf - n, text, n);
-
- if (n) {
- len -= n;
-- if (!len)
-- len = -EFAULT;
-- break;
-- }
++ if (copy_to_user(buf, text + skip, n)) {
+ if (!len)
+ len = -EFAULT;
+ break;
+ }
++
++ len += n;
++ size -= n;
++ buf += n;
}
kfree(text);
-@@ -1136,6 +1146,7 @@ int do_syslog(int type, char __user *buf
+@@ -1107,6 +1117,7 @@ int do_syslog(int type, char __user *buf
/* messages are gone, move to first one */
syslog_seq = log_first_seq;
syslog_idx = log_first_idx;
@@ -84,3 +78,11 @@
}
if (from_file) {
/*
+@@ -1129,6 +1140,7 @@ int do_syslog(int type, char __user *buf
+ idx = log_next(idx);
+ seq++;
+ }
++ error -= syslog_partial;
+ }
+ raw_spin_unlock_irq(&logbuf_lock);
+ break;
diff --git a/series b/series
index 64bf3f7..df2ac4e 100644
--- a/series
+++ b/series
@@ -1,2 +1,4 @@
#test-modules.patch
+kmsg-syslog-1-byte-read.patch
kmsg-merge-cont.patch
+