From 7bf06a5c3e2db2ab8a1e566dbdfcd46a57ad2a43 Mon Sep 17 00:00:00 2001 From: HATAYAMA Daisuke Date: Tue, 3 Jul 2012 11:43:30 +0900 Subject: [PATCH 3/3] Add uncompression processing Signed-off-by: HATAYAMA Daisuke --- defs.h | 3 +++ diskdump.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/defs.h b/defs.h index 8eebc52..f938c8c 100755 --- a/defs.h +++ b/defs.h @@ -51,6 +51,9 @@ #ifdef LZO #include #endif +#ifdef SNAPPY +#include +#endif #ifndef ATTRIBUTE_UNUSED #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) diff --git a/diskdump.c b/diskdump.c index 4d194c5..39f4652 100644 --- a/diskdump.c +++ b/diskdump.c @@ -874,6 +874,34 @@ cache_page(physaddr_t paddr) return READ_ERROR; } #endif + } else if (pd.flags & DUMP_DH_COMPRESSED_SNAPPY) { + + if (!(dd->flags & SNAPPY_SUPPORTED)) { + error(INFO, "%s: uncompress failed: no snappy compression support\n", + DISKDUMP_VALID() ? "diskdump" : "compressed kdump"); + return READ_ERROR; + } + +#ifdef SNAPPY + ret = snappy_uncompressed_length((char *)dd->compressed_page, + pd.size, &retlen); + if (ret != SNAPPY_OK) { + error(INFO, "%s: uncompress failed: %d\n", + DISKDUMP_VALID() ? "diskdump" : "compressed kdump", + ret); + return READ_ERROR; + } + + ret = snappy_uncompress((char *)dd->compressed_page, pd.size, + (char *)dd->page_cache_hdr[i].pg_bufptr, + &retlen); + if ((ret != SNAPPY_OK) || (retlen != block_size)) { + error(INFO, "%s: uncompress failed: %d\n", + DISKDUMP_VALID() ? "diskdump" : "compressed kdump", + ret); + return READ_ERROR; + } +#endif } else memcpy(dd->page_cache_hdr[i].pg_bufptr, dd->compressed_page, block_size); -- 1.7.7.6