[PATCH 3/3] Add uncompression processing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
---
 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 <lzo/lzo1x.h>
 #endif
+#ifdef SNAPPY
+#include <snappy-c.h>
+#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



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux