lkml.org 
[lkml]   [2006]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Suspend2][ 09/13] [Suspend2] Serialisation of compressor configuration in image header.
Date
Routines for storing and reloading the compression configuration in an
image header.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

kernel/power/compression.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/kernel/power/compression.c b/kernel/power/compression.c
index b8005c7..1398dc5 100644
--- a/kernel/power/compression.c
+++ b/kernel/power/compression.c
@@ -416,4 +416,47 @@ static unsigned long suspend_compress_st
return 4 * sizeof(unsigned long) + strlen(suspend_compressor_name) + 1;
}

+/*
+ * suspend_compress_save_config_info
+ * @buffer: Pointer to a buffer of size PAGE_SIZE.
+ *
+ * Save informaton needed when reloading the image at resume time.
+ * Returns: Number of bytes used for saving our data.
+ */
+static int suspend_compress_save_config_info(char *buffer)
+{
+ int namelen = strlen(suspend_compressor_name) + 1;
+ int total_len;
+
+ *((unsigned long *) buffer) = bytes_in;
+ *((unsigned long *) (buffer + 1 * sizeof(unsigned long))) = bytes_out;
+ *((unsigned long *) (buffer + 2 * sizeof(unsigned long))) =
+ suspend_expected_compression;
+ *((unsigned long *) (buffer + 3 * sizeof(unsigned long))) = namelen;
+ strncpy(buffer + 4 * sizeof(unsigned long), suspend_compressor_name,
+ namelen);
+ total_len = 4 * sizeof(unsigned long) + namelen;
+ return total_len;
+}
+
+/* suspend_compress_load_config_info
+ * @buffer: Pointer to the start of the data.
+ * @size: Number of bytes that were saved.
+ *
+ * Description: Reload information needed for decompressing the image at
+ * resume time.
+ */
+static void suspend_compress_load_config_info(char *buffer, int size)
+{
+ int namelen;
+
+ bytes_in = *((unsigned long *) buffer);
+ bytes_out = *((unsigned long *) (buffer + 1 * sizeof(unsigned long)));
+ suspend_expected_compression = *((unsigned long *) (buffer + 2 *
+ sizeof(unsigned long)));
+ namelen = *((unsigned long *) (buffer + 3 * sizeof(unsigned long)));
+ strncpy(suspend_compressor_name, buffer + 4 * sizeof(unsigned long),
+ namelen);
+ return;
+}

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-06-27 07:18    [W:0.088 / U:0.220 seconds]
©2003-2011 Jasper Spaans. Advertise on this site