From bd08ec33b5c23833581e5a36b2a69ccae6b39a28 Mon Sep 17 00:00:00 2001 From: Arve Hjønnevåg Date: Wed, 5 Dec 2012 21:19:51 -0800 Subject: pstore/ram: Restore ecc information block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was lost when proc/last_kmsg moved to pstore/console-ramoops. Signed-off-by: Arve Hjønnevåg Signed-off-by: John Stultz Acked-by: Kees Cook Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 12 ++++++++++-- fs/pstore/ram_core.c | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'fs') diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index a5ee252c264e..32cbd7c8a90c 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -136,6 +136,7 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, char **buf, struct pstore_info *psi) { ssize_t size; + ssize_t ecc_notice_size; struct ramoops_context *cxt = psi->data; struct persistent_ram_zone *prz; @@ -156,11 +157,18 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_nsec = 0; size = persistent_ram_old_size(prz); - *buf = kmemdup(persistent_ram_old(prz), size, GFP_KERNEL); + + /* ECC correction notice */ + ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0); + + *buf = kmalloc(size + ecc_notice_size + 1, GFP_KERNEL); if (*buf == NULL) return -ENOMEM; - return size; + memcpy(*buf, persistent_ram_old(prz), size); + persistent_ram_ecc_string(prz, *buf + size, ecc_notice_size + 1); + + return size + ecc_notice_size; } static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz) diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index c6f641c10179..59337326e288 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -235,6 +235,9 @@ ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, { ssize_t ret; + if (!prz->ecc_info.ecc_size) + return 0; + if (prz->corrected_bytes || prz->bad_blocks) ret = snprintf(str, len, "" "\n%d Corrected bytes, %d unrecoverable blocks\n", -- cgit v1.2.3