kmsg - kmsg_dump() use iterator to receive log buffer content
Provide an iterator to receive the log buffer content, and convert all kmsg_dump() users to it. The structured data in the kmsg buffer now contains binary data, which should no longer be copied verbatim to the kmsg_dump() users. The iterator should provide reliable access to the buffer data, and also supports proper log line-aware chunking of data while iterating. Signed-off-by: Kay Sievers <kay@vrfy.org> Tested-by: Tony Luck <tony.luck@intel.com> Reported-by: Anton Vorontsov <anton.vorontsov@linaro.org> Tested-by: Anton Vorontsov <anton.vorontsov@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
1bd289d1e8
commit
e2ae715d66
@@ -304,32 +304,17 @@ static void find_next_position(struct mtdoops_context *cxt)
|
||||
}
|
||||
|
||||
static void mtdoops_do_dump(struct kmsg_dumper *dumper,
|
||||
enum kmsg_dump_reason reason, const char *s1, unsigned long l1,
|
||||
const char *s2, unsigned long l2)
|
||||
enum kmsg_dump_reason reason)
|
||||
{
|
||||
struct mtdoops_context *cxt = container_of(dumper,
|
||||
struct mtdoops_context, dump);
|
||||
unsigned long s1_start, s2_start;
|
||||
unsigned long l1_cpy, l2_cpy;
|
||||
char *dst;
|
||||
|
||||
if (reason != KMSG_DUMP_OOPS &&
|
||||
reason != KMSG_DUMP_PANIC)
|
||||
return;
|
||||
|
||||
/* Only dump oopses if dump_oops is set */
|
||||
if (reason == KMSG_DUMP_OOPS && !dump_oops)
|
||||
return;
|
||||
|
||||
dst = cxt->oops_buf + MTDOOPS_HEADER_SIZE; /* Skip the header */
|
||||
l2_cpy = min(l2, record_size - MTDOOPS_HEADER_SIZE);
|
||||
l1_cpy = min(l1, record_size - MTDOOPS_HEADER_SIZE - l2_cpy);
|
||||
|
||||
s2_start = l2 - l2_cpy;
|
||||
s1_start = l1 - l1_cpy;
|
||||
|
||||
memcpy(dst, s1 + s1_start, l1_cpy);
|
||||
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
|
||||
kmsg_dump_get_buffer(dumper, true, cxt->oops_buf + MTDOOPS_HEADER_SIZE,
|
||||
record_size - MTDOOPS_HEADER_SIZE, NULL);
|
||||
|
||||
/* Panics must be written immediately */
|
||||
if (reason != KMSG_DUMP_OOPS)
|
||||
@@ -375,6 +360,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
|
||||
return;
|
||||
}
|
||||
|
||||
cxt->dump.max_reason = KMSG_DUMP_OOPS;
|
||||
cxt->dump.dump = mtdoops_do_dump;
|
||||
err = kmsg_dump_register(&cxt->dump);
|
||||
if (err) {
|
||||
|
Reference in New Issue
Block a user